/* x
/*The Bisection Method to solve cosxxe ***********/
#include<stdio.h>
#include<conio.h>
#include<math.h>
float c(float x );
float f(float x);
main()
{
float a,b,y,r1,r2,r3;
do{
printf("\nenter approximate interval");
scanf("%f%f",&a,&b);
r1=f(a);
r2=f(b);
}while(r1*r2>0);
printf("a\t\tb x=(a+b)/2 f(x)\n\n");
do{
r1=f(a);
r2=f(b);
y= (a+b)/2.0;
r3=f(y);
printf( "%.4f %.4f %.4f %.4f",a,b,y,r3);
if(r1*r3<0)
b=y;
else
a=y;
printf("\n");
}while(fabs(r3)>0.0001);
printf("\n The approx sol is %f",y);
getch();
return 0;
}
float c(float x)
{
float rad;
rad=((3.1416)/180.0) *x;
return(cos(rad));
}
float f(float x )
{
float f1;
f1=c(x)(x*pow(2.7183,x));
return(f1);
}
you can change the function f to solve some other polynomial.
