#include <stdio.h>
#include <math.h>
/*该程序的是针对上图所示的方程求根。*/
void main()
{
float f, f1, x, x0; // x0是方程的真实根,x是方程的假设根;f是方程的函数式,f1是函数的导函数表达式;
x = 1;
do
{
x0 = x;
f = ((4 * x - 3) * x + 2) * x - 6;
f1 = (12 * x - 6) * x + 2;
x0 = x - f/f1;
} while (fabs(x0 - x) >= 1e-5);
printf("%f.\n", 1e-9);
printf("the root of the equation is %9.8f.\n",x0);
system("pause");
}
版权声明:本文为yuyantai1234原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。