Has anyone wrote a program solve this f(x) = sin (2x/5) -x +1 =0

with bisection method and newtons method?

I haven't a clue and any help would be appreciated.

Thanks

Amanda

double left = 0 ,right = 0;

double size, mid,root, tol = .00001, zero_check = .0001;

int done = 0;

float finish;

printf("Please enter a range of values ");

scanf ("%lf ", &left);

scanf ("%lf", &right);

size = right - left;

while((size >=tol) && (!done))

{

mid = (right+left)/2;

printf("f(%f) = %9.6f f(%f) = %9.6f f(%f) = %9.6f\n",

left, f(left),mid,f(mid),right,f(right));

if(fabs(f(mid)) <zero_check)

done = 1;

else if (f(mid) * f(left)<0)

right = mid;

else

left = mid;

size = right - left;

}

if(size >tol)

root = mid;

else

root = (left +right)/2;

printf("The root is %lf\n", root);

}

double f(double x)

{

return(x*x -4 +exp(-1.0*x));

}

I want to know why do you use the function double f. Can you not just check the values without applying them to this function?And when you take the right from the left what is that value called and when do you compare it the tol?