24小时热门版块排行榜    

CyRhmU.jpeg
查看: 479  |  回复: 2

zidingxiang

金虫 (小有名气)

[求助] 运行结果与设置精度不符,结果应与初值接近才对已有1人参与

1.首先建立函数myfun,储存方程组编程如下将myfun.m保存到工作路径中:  
function F = myfun( x )
%this function designed for solving nonlinear equations
a = x(1);
b = x(2);
c = x(3);
d = x(4);
e = x(5);
f = x(6);

F = [a+b*10+c*10^2+(d+e*10)/(0.6438^2-f^2)-2*1.620015/(1.620015^2-1)*(-0.87+2.6);
a+b*10+c*10^2+(d+e*10)/(0.6328^2-f^2)-2*1.620507/(1.620507^2-1)*(-0.87+2.7);
a+b*10+c*10^2+(d+e*10)/(0.5893^2-f^2)-2*1.622702/(1.622702^2-1)*(-0.87+2.8);
a+b*10+c*10^2+(d+e*10)/(0.5461^2-f^2)-2*1.625401/(1.625401^2-1)*(-0.87+2.9);
a+b*10+c*10^2+(d+e*10)/(0.4800^2-f^2)-2*1.631029/(1.631029^2-1)*(-0.88+3.3);
a+b*10+c*10^2+(d+e*10)/(0.4358^2-f^2)-2*1.636369/(1.636369^2-1)*(-0.88+3.6)];


end

2.运行程序
x0=[-3e-005,-1.5e-008,-5.0e-011,3.0e-007,2.0e-010,0];
options=optimset('Display','iter','TolFun',1e-020,'TolX',1e-020,'MaxIter',1e100);
format long;
[x,fval]=fsolve(@myfun,x0,options)
运行结果显示如下:


                                         Norm of      First-order   Trust-region
Iteration  Func-count     f(x)          step         optimality    radius
     0          7         106.837                      2.5e+003               1
     1         14         1.58981      0.0393664           28.2               1
     2         21       0.0425606      0.0513838           36.8               1
     3         28       0.0198142    0.000578732          0.414               1
     4         35       0.0194798    0.000755402          0.541               1
     5         42       0.0194749   8.50804e-006        0.00609               1
     6         49       0.0194748   1.11053e-005        0.00795               1
     7         56       0.0194748   1.25077e-007      8.95e-005               1
     8         63       0.0194748    1.6325e-007       0.000117               1
     9         70       0.0194748   1.84156e-009      1.32e-006               1
    10         77       0.0194748   2.41651e-009      1.58e-006               1
    11         84       0.0194748   2.49273e-011      1.22e-008               1
Optimizer appears to be converging to a point which is not a root.
Relative function value changing by less than max(options.TolFun^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.

x =

   0.000167225746880   0.001972242468804   0.019722574638040   0.006232656757062   0.062323567700574   0.000000000137224


fval =

   0.060290300323624
  -0.083434220551602
  -0.030535103096213
   0.083729176350573
  -0.030583681232919
   0.000533528265654

注:函数精度远远小于设定精度值;参数值应接近于设定值,但相差很远。
回复此楼
violet
已阅   关注TA 给TA发消息 送TA红花 TA的回帖

zidingxiang

金虫 (小有名气)

为什么没有人帮忙?
violet
2楼2014-07-08 08:23:19
已阅   关注TA 给TA发消息 送TA红花 TA的回帖

dingd

铁杆木虫 (职业作家)

【答案】应助回帖

该方程组本身就没有精确解的。

还有方程本身有问题吧?方程两两相减,“a+b*10+c*10^2”项全消失,就变成5个式子组成的方程组,但却只有三个未知数(d,e,f),成超越方程了,一般无精确解。
3楼2014-07-08 09:14:23
已阅   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zidingxiang 的主题更新
信息提示
请填处理意见