//14.
#include<stdio.h>
#include<math.h>
int main()
{
int i = 0;
double x1 = 1.5, x2 = 0;//迭代初值
while(fabs(x2-x1)>=pow(10,-5))
{
x1 = x1 - (2 * x1*x1*x1 - 4 * x1*x1 + 3 * x1 - 6) / (6 * x1*x1 - 8 * x1 + 3);
x2 = x1 - (2 * x1*x1*x1 - 4 * x1*x1 + 3 * x1 - 6) / (6 * x1*x1 - 8 * x1 + 3);
#include<stdio.h>
#include<math.h>
int main()
{
int i = 0;
double x1 = 1.5, x2 = 0;//迭代初值
while(fabs(x2-x1)>=pow(10,-5))
{
x1 = x1 - (2 * x1*x1*x1 - 4 * x1*x1 + 3 * x1 - 6) / (6 * x1*x1 - 8 * x1 + 3);
x2 = x1 - (2 * x1*x1*x1 - 4 * x1*x1 + 3 * x1 - 6) / (6 * x1*x1 - 8 * x1 + 3);
i++;
printf("第%d次迭代 x1=%9.8f\tx2=%9.8f\n", i, x1, x2);
}
printf("\nx=%9.8f\t共迭代:%d次\n", x2, i);
return 0;
}
printf("第%d次迭代 x1=%9.8f\tx2=%9.8f\n", i, x1, x2);
}
printf("\nx=%9.8f\t共迭代:%d次\n", x2, i);
return 0;
}
牛顿迭代法求根示例
本文通过一个C语言程序实例介绍了如何使用牛顿迭代法来求解方程的根。该程序采用了一个特定的多项式方程,并设定了迭代终止条件为误差小于10的-5次方。

被折叠的 条评论
为什么被折叠?



