用matlab求非线性方程组的解,但是求得的解代入第2、3、4个方程后,其方程都不等于0,为什么?
第一步,myfun.m如下:
function F = myfun(x)
F=9.1-(6.02)*(1+x(2)*exp(4*x(3)))*(x(4)^1.5-1)/(x(1)*x(2)*exp(4*x(3)));
14.2-(16.82)*(1+x(2)*exp(14*x(3)))*(x(4)^1.5-1)/(x(1)*x(2)*exp(14*x(3)));
8.4-(44.02)*(1+x(2)*exp(22*x(3)))*(x(4)^1.5-1)/(x(1)*x(2)*exp(22*x(3)));
10.4-(127.39)*(1+x(2)*exp(32*x(3)))*(x(4)^1.5-1)/(x(1)*x(2)*exp(32*x(3)));
第二步:
x0 = [1;1;0.01;1];
options=optimset('Display','iter');
[x,fval] = fsolve(@myf,x0,options) % Call solver
结果为:
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt
algorithm instead.
> In fsolve at 314
First-Order Norm of
Iteration Func-count Residual optimality Lambda step
0 5 82.81 161 0.01
1 10 1.17548 23.6 0.001 0.513936
2 15 0.0031149 1.14 0.0001 0.0342564
3 20 2.61253e-008 0.0033 1e-005 0.00195934
4 25 1.85746e-018 2.78e-008 1e-006 5.70737e-006
5 30 3.15544e-030 3.62e-014 1e-007 4.81251e-011
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
x =
1.0116
1.0057
0.0328
1.4889
fval =
1.7764e-015
第三步:代入第二个方程
r2=(16.82)*(1.0057+1.0057*exp(14*0.0328))*(1.4889^1.5-1)/((1.0116*1.0057)*exp(14*0.0328))
r2 =
22.1604
根据第二个方程这个值应当是14.2。所以有问题?为什么呢?
谢谢了