📄 rtsec.cpp
字号:
double rtsec(double x1,double x2,double xacc)
{
int maxit,j;
double fl,f,temp,xl,swap,dx;
maxit = 30;
fl = func(x1);
f = func(x2);
if (fabs(fl) < fabs(f) )
{
temp = x1;
xl = x2;
swap = fl;
fl = f;
f = swap;
}
else
{
xl = x1;
temp = x2;
}
for (j = 1; j<= maxit; j++)
{
dx = (xl - temp) * f / (f - fl);
xl =temp;
fl = f;
temp = temp + dx;
f = func(temp);
if ((fabs(dx) < xacc) ||(f == 0))
{
return temp;
break;
}
}
cout<< "rtsec exceed maximum iterations"<<endl;
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -