作业帮 > 综合 > 作业

C++程序牛顿法解方程,求纠正

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/25 12:13:10
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
/*
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