求方程cos(x)-x=0的一个实根
#include <math.h>
#include <stdio.h>
double fun()
{
double x0,x1=0.0;
while(fabs((float)x0-x1)>0.000001){
x0=x1;
x1=cos(x0);
}
return x1;
}
main()
{
printf("Root =%f\n",fun());
}
求方程cos(x)-x=0的一个实根
#include <math.h>
#include <stdio.h>
double fun()
{
double x0,x1=0.0;
while(fabs((float)x0-x1)>0.000001){
x0=x1;
x1=cos(x0);
}
return x1;
}
main()
{
printf("Root =%f\n",fun());
}