求助--熟悉用fsolve解非线性方程组的高手帮忙分析一个程序
方程通式见M文件m文件:'myfun'
初值:x0=[-2.4887 0.4162-0.0202]
答案:x=[-2.36930.3845-0.0181]
=================================
function F = myfun(x,d,p)
d=;
p=;
F(1)=(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))*d(1)+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))*d(2)+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))*d(3)+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))*d(4)+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))*d(5)+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6))*d(6))/ ...
(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6)))-sum(p.*d);
F(2)=(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))*d(1)^2+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))*d(2)^2+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))*d(3)^2+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))*d(4)^2+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))*d(5)^2+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6))*d(6)^2)/ ...
(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6)))-sum(p.*d.^2);
F(3)=(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))*d(1)^3+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))*d(2)^3+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))*d(3)^3+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))*d(4)^3+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))*d(5)^3+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6))*d(6)^3)/ ...
(exp(-x(3)*d(1)^3-x(2)*d(1)^2-x(1)*d(1))+ ...
exp(-x(3)*d(2)^3-x(2)*d(2)^2-x(1)*d(2))+ ...
exp(-x(3)*d(3)^3-x(2)*d(3)^2-x(1)*d(3))+ ...
exp(-x(3)*d(4)^3-x(2)*d(4)^2-x(1)*d(4))+ ...
exp(-x(3)*d(5)^3-x(2)*d(5)^2-x(1)*d(5))+ ...
exp(-x(3)*d(6)^3-x(2)*d(6)^2-x(1)*d(6)))-sum(p.*d.^3);
=====================================================
执行部分:
x0=[-2.4887 0.4162 -0.0202];
options=optimset('Display','iter');
=fsolve(@myfun,x0,options)
=====================================================
结果:
Optimization terminated: first-order optimality is less than options.TolFun.
x =
-1.4799 0.1720 -0.0034
favl =
1.0e-012 *
-0.0044 -0.0462 -0.4832
exitflag =
1
==============================================
不知错在哪里,是否迭代步长或精度没设置好
回复
如果方程组没有输入错误的话,似乎没有问题. 1.0e-012这么小了还不可以看成0么?exitflag =1
这种问题我也遇到过,是不是如果返回1就是答案不对阿 ?
明白指点一下吧:@L 原帖由 huqingwan 于 2006-12-28 10:46 发表
1.0e-012这么小了还不可以看成0么?
exitflag =1
这种问题我也遇到过,是不是如果返回1就是答案不对阿 ?
明白指点一下吧:@L
exitflag > 0
表示得到了满足要求的解
页:
[1]