C++程序牛顿法解方程,求纠正
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/19 11:14:22
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
#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++程序牛顿法解方程,求纠正](/uploads/image/z/3178053-45-3.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)
/*
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
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