rtnewt.cpp
来自「工程算法 这是一个很有用的工程数值算法集锦」· C++ 代码 · 共 27 行
CPP
27 行
double rtnewt(double x1, double x2,double xacc)
{
int jmax,j;
double temp1,f,df,dx;
jmax = 20;
temp1 = 0.5 * (x1 + x2);
for (j = 1; j<=jmax; j++)
{
funcd(temp1, f, df);
dx = f / df;
temp1 = temp1 - dx;
if ((x1 - temp1) * (temp1 - x2) < 0 )
{
cout<< "jumped out of brackets"<<endl;
return temp1;
_c_exit();
}
if (fabs(dx) < xacc)
{
return temp1;
_c_exit();
}
}
cout<< "rtnewt exceeding maximum iterations."<<endl;
return 1;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?