MATLAB实现最速下降法

MATLAB实现最速下降法

ID:70216937

大小:21.50 KB

页数:4页

时间:2021-11-17

MATLAB实现最速下降法_第1页
MATLAB实现最速下降法_第2页
MATLAB实现最速下降法_第3页
MATLAB实现最速下降法_第4页
资源描述:

《MATLAB实现最速下降法》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、MATLAB实现最速下降法这个程序是一本美国的数值方法教材上提供的,程序清单如下:function[p0,y0,err,P]=grads(F,G,P0,maxl,delta,epsilon,show)%input-Fistheobjectfunctioninputasstring'F'%      -G=(-1/norm)(gradF)*gradF;thesearchdirection%      inputasastring'G'%      -P0istheinitialstratingpoint  %  

2、    -maxlisthemaximumnumberofinteractions%      -deltaisthetoleranceforthehmininthesingle%      parameterminuizationinthesearchdirection%      -epsilonisthetolerancefortheerroriny0%      -show;ifshow==1theiterationsaredisplay%Output-P0isthepointofminium%      -y0isthefunctionvalueF(P0)%      -

3、erriserrorboundfory0%      -Pisavectorcontainingtheiterationsifnargin==5,show=0;end[m,n]=size(P0);maxj=10;big=1e8;h=1;P=zeros(maxj,n+1);len=norm(P0);y0=feval(F,P0);if(len>1e4),h=len/le4;enderr=1;cnt=0;cond=0;P(cnt+1,:)=[P0y0];while(cnt<maxl&cond~=5&(h>delta

4、

5、err<epsilon))    %Computesearchdirection    S=feval(G,P0);    %Startsingleparameterquadraticminimization    P1=P0+h*S;    P2=P0+2*h*S;    y1=feval(F,P1);    y2=feval(F,P2);    cond=0;j=0;    while(j<maxj&cond==0)        len=norm(P0);        if(y0<y1)            P2

6、=P1;            y2=y1;            h=h/2;            P1=P0+h*S;            y1=feval(F,P1);        else            if(y2<y1)                P1=P2;                y1=y2;                h=2*h;                P2=P0+2*h*S;                y2=feval(F,P2);            else                cond=-1;

7、            end        end        j=j+1;        if(h<delta),cond=1;end        if(abs(h)>big

8、len>big),cond=5;end    end        if(cond==5)        Pmin=P1;        ymin=y1;    else        d=4*y1-2*y0-2*y2;       

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。