弦截法.cpp
来自「定步长辛普森公式计算.二分法.列主高斯消去法.龙贝格.牛顿迭代法.弦截法.逐次超」· C++ 代码 · 共 21 行
CPP
21 行
#include "math.h"
#include "stdio.h"
double Func(double x)
{
return (x*x*x-3*x-1);
}
void main()
{
double x0,x1,t,eps;
x0=1.9;x1=2;eps=0.0001;
for(int i=1;i<5;i++)
{
t=x1;
x1=x1-(Func(x1)*(x1-x0))/(Func(x1)-Func(x0));
x0=t;
}
printf("%.4f\n",x1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?