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/11/25 20:35:30
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