C++程序牛顿法解方程,求纠正#include #include #include double root(int n,double x){double t;while(fabs(root(n + 1,x) - root(n,x)) > 1e-6){root(n + 1,x) = root (n,x) - (cos(root(n,x)) - root(n,x)) / (sin((root(n,x))-1);t = (root(n,x);}return
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/21 13:05:41
![C++程序牛顿法解方程,求纠正#include #include #include double root(int n,double x){double t;while(fabs(root(n + 1,x) - root(n,x)) > 1e-6){root(n + 1,x) = root (n,x) - (cos(root(n,x)) - root(n,x)) / (sin((root(n,x))-1);t = (root(n,x);}return](/uploads/image/z/5944361-41-1.jpg?t=C%2B%2B%E7%A8%8B%E5%BA%8F%E7%89%9B%E9%A1%BF%E6%B3%95%E8%A7%A3%E6%96%B9%E7%A8%8B%2C%E6%B1%82%E7%BA%A0%E6%AD%A3%23include+%23include+%23include+double+root%28int+n%2Cdouble+x%29%7Bdouble+t%3Bwhile%28fabs%28root%28n+%2B+1%2Cx%29+-+root%28n%2Cx%29%29+%3E+1e-6%29%7Broot%28n+%2B+1%2Cx%29+%3D+root+%28n%2Cx%29+-+%28cos%28root%28n%2Cx%29%29+-+root%28n%2Cx%29%29+%2F+%28sin%28%28root%28n%2Cx%29%29-1%29%3Bt+%3D+%28root%28n%2Cx%29%3B%7Dreturn)
C++程序牛顿法解方程,求纠正#include #include #include double root(int n,double x){double t;while(fabs(root(n + 1,x) - root(n,x)) > 1e-6){root(n + 1,x) = root (n,x) - (cos(root(n,x)) - root(n,x)) / (sin((root(n,x))-1);t = (root(n,x);}return
C++程序牛顿法解方程,求纠正
#include
#include
#include
double root(int n,double x)
{
double t;
while(fabs(root(n + 1,x) - root(n,x)) > 1e-6)
{
root(n + 1,x) = root (n,x)
- (cos(root(n,x)) - root(n,x))
/ (sin((root(n,x))-1);
t = (root(n,x);
}
return t;
}
void main()
{
double t;
t = root(5000,3.14159 / 4);
cout
C++程序牛顿法解方程,求纠正#include #include #include double root(int n,double x){double t;while(fabs(root(n + 1,x) - root(n,x)) > 1e-6){root(n + 1,x) = root (n,x) - (cos(root(n,x)) - root(n,x)) / (sin((root(n,x))-1);t = (root(n,x);}return
/*
x = 0.739085
Press any key to continue
*/
#include
//#include
#include
void main() {
double xo,x1,f,f1;
x1 = 3.1415927/4;
do {
xo = x1;
f = cos(xo) - xo;
f1 = -sin(xo) - 1;
x1 = xo - f/f1;
}while(fabs(x1 - xo) >= 1.0E-6);
cout