解非线性方程的双点弦截法的c程序
源代码在线查看: chord2m.c
/* chord2m.c: two points chord iterative method */
#define MI 100
#include "chord2.c"
double f(double x);
extern int chord2(double x[2]);
void main()
{
int k;
double x[2];
system("cls");
printf("Two points Chord iterative method:\n");
x[0]=2.0*atan(1.0);
x[1]=2.0*x[0];
k=chord2(x);
if(k>=MI) printf("%d times iterative isn't success!\n",k);
else printf("Ok! k=%d root=%15.8f\n",k,x[1]);
getch();
}
/****function f()****/
double f(double x)
{
double y;
y=sin(x)-x/2.0;
return(y);
}