牛顿迭代求方程根的问题。
RT 求ax3+bx2+cx+d=0在1附近的根。代码如下:#include <stdio.h>
#include <math.h>
int main( void )
{
float a, b, c, d;
float x0, x1, fx0, dfx0;
printf("Please input four coeficient a b c d:");
scanf("%f,%f,%f,%f", &a, &b, &c, &d);
printf("Now the original equation is : \n");
printf("%5.2f * x * x * x + %5.2f * x * x + %5.2f * x + %5.2f = 0\n", a, b, c, d);
x1 = 1.0;
do{
x0 = x1;
fx0 = (((a * x0 + b)) * x0 + c ) * x0 + d;
dfx0 = (3 * a * x0 * x0 + b) * x0 + c;
x1 = x0 - fx0 / dfx0;
} while (fbab(x0 - x1) >= 1e-5);
printf("The equation root is : %f", x1);
return 0;
}
编译没有问题,但是连接有错误:
牛顿迭代.obj : error LNK2001: unresolved external symbol _fbab
Debug/牛顿迭代.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
牛顿迭代.exe - 1 error(s), 0 warning(s)
这怎么解决?