0$房天下问答|程序设之优化设计 MATLAB(2)$https://m.fang.com/ask/ask_1175441.html$https://static.soufunimg.com/common_m/m_public/201511/images/asksharedefault.png
packc/pages/ask/detail/detail?askid=1175441
共1个回答
-
-
-
zx9012
丨Lv 0
解:(i) 编写M文件detaf.m如下:function [f,df]=detaf(x);f=1.5*x(1)^2+0.5*x(2)^2+x(1)*x(2)-2*x(1);df(1)=3*x(1)+x(2)-2;df(2)=x(2)+x(1);(ii)编写M文件zuisu.mclcx=[-2;4];[f0,g]=detaf(x);while norm(g)>0.01 p=-g'/norm(g); t=1.0;f=detaf(x+t*p); while f>f0 t=t/2;f=detaf(x+t*p); endx=x+t*p[f0,g]=detaf(x)end在命令窗口输入zuisux = -1.1056 3.5528f0 = 6.4279g = -1.7639 2.4472x = -0.5208 2.7416f0 = 3.7788g = -0.8210 2.2207x = -0.1741 1.8036f0 = 1.7061g = -0.7187 1.6295x = 0.2294 0.8886f0 = 0.2188g = -0.4230 1.1181x = 0.5833 -0.0467f0 = -0.6824g = -0.2967 0.5367x = 1.0671 -0.9218f0 = -0.9849g = 0.2796 0.1453x = 0.9562 -0.9795f0 = -0.9978g = -0.1108 -0.0232x = 1.0174 -0.9666f0 = -0.9984g = 0.0856 0.0508x = 0.9905 -0.9826f0 = -0.9999g = -0.0110 0.0079x = 1.0032 -0.9917f0 = -0.9999g = 0.0179 0.0115x = 0.9966 -0.9959f0 = -1.0000g = -0.0061 0.0007
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。

关注成功