5.7 函数极值点
5.7.1 一元函数的极小值点
5.7.2 多元函数的极小值点
【 * 例 5.7.2 -1 】求
的极小值点。它即
著名的 Rosenbrock's "Banana" 测试函数。该测试函数有一片浅谷,许多算法难以越过此谷。
(1)从三维等位线图初步观察测试函数
x=-3:0.1:3;y=-2:0.1:4;
[X,Y]=meshgrid(x,y);
F=100*(Y-X.^2).^2+(1-X).^2;
contour3(X,Y,F,300),
xlabel('x'),ylabel('y'),axis([-3,3,-2,4,0,inf]),view([161,22])
hold on,plot3(1,1,0,'.r','MarkerSize',20),hold off
图 5.7.2 -1-0 三维等位线图显示出一条香蕉形浅谷
(2)本例采用内联函数表示测试函数如下
ff=inline('100*(x(2)-x(1)^2)^2+(1-x(1))^2','x');
(3)用单纯形法求极小值点
x0=[-1.2,1];[sx,sfval,sexit,soutput]=fminsearch(ff,x0)
Optimization terminated successfully:
the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-004
and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-004
sx =
1.0000 1.0000
sfval =
8.1777e-010
sexit =
1
soutput =
iterations: 85
funcCount: 159
algorithm: 'Nelder-Mead simplex direct search'
(4)用拟牛顿法求极小值点
[ux,sfval,uexit,uoutput,grid,hess]=fminunc(ff,x0)
Warning: Gradient must be provided for trust-region method;
using line-search method instead.
> In D:\MAT53\toolbox\optim\fminunc.m at line 202
Optimization terminated successfully:
Current search direction is a descent direction, and magnitude of
directional derivative in search direction less than 2*options.TolFun
ux =
1.0000 1.0000
sfval =
1.9118e-011
uexit =
1
uoutput =
iterations: 26
funcCount: 162
stepsize: 1.2992
firstorderopt: 5.0023e-004
algorithm: 'medium-scale: Quasi-Newton line search'
grid =
1.0e-003 *
-0.5002
-0.1888
hess =
820.4031 -409.5497
-409.5497 204.7720

激光扫描服务技术具有很高的经济意...

(资料图片)“中国载人航天飞行任务试验用车”、“航天员凯旋礼宾车”、“神舟七号飞...

针对级进模排样的特点以及人工智能技术在工程领域应用的研究,提出了适用于级进模排样...

目前,北京现代汽车有限公司发动机厂拥有两个工厂,分别于2004年和2007年投产,年生产...

9月8日,石家庄兆通金刚石工贸有限公司销售经理王金龙先生在向笔者介绍金刚石制品行业...