I am implementing the bisection method, and as a first step I need to evaluate the polynomial function, but I do not get the correct result.
The polynomial used is 3(x^2)+7(x)+1
with x=2
, the result should be 27
public static double evaluaFx(int []coef, int grade, int x) {
//int x viene siendo los x0,xf.xmenter code here
double Fx=0;
//System.out.println("grade"+grade+"x"+x);
//for (int i = grade; i >=0; i--) {
// System.out.println(coef[i]);
//}
for (int i = grade; i>=0; i--) {
Fx= Math.pow((coef[i]*x), grade);
// System.out.println(Fx+"mas"+"("+coef[i]+x+") a la grado"+grade);
}
return Fx;
}
What's wrong with above algorithm ?