⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chord2.c

📁 解非线性方程的双点弦截法的c程序
💻 C
字号:
/* chord2.c: two points chord iterative method */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#ifndef EPSILON
#define EPSILON 1.0e-8
#endif
double f(double x);
int chord2(double x[2])
{
  int k;
  double xx,y0,y1;
  k=1;
  y0=f(x[0]);
  printf("  0  %12.8f\n",x[0]);
  again:printf("%3d %12.8f\n",k,x[1]);
        k=k+1;
		y1=f(x[1]);
		if(fabs(y1)<EPSILON) {xx=x[1];k=k-1;goto endd;}
		if(fabs(y1-y0)>EPSILON*EPSILON)
		          xx=x[1]-y1*(x[1]-x[0])/(y1-y0);
	     else
		 {
		   printf("f'(x) to small absolutely!Strike any key to exit,\n");
		   getch(); exit(1);
		 }
		 y0=y1;
		 x[0]=x[1];
		 if(fabs(x[1]-xx)<EPSILON) goto endd;
		 x[1]=xx;
		 if(k<MI) goto again;
  endd:  x[1]=xx;
  return(k);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -