2%3第n次结束参数计算33d=x(n,:)-x0;x(n+1,:)=2*x(n,:)-x0;[Delta_m,j]=max(Delta);F2=F(n);F3=ff(x(n+1,1),x(n+1,2));%3333%44搜索方向是否进行替换44ifF3<F0&(F0-2*F2+F3)*(F0-F2-Delta_m)^2>=Delta_m/2*(0-F3)^2x01=x(n,1);x02=x(n,2);alpha=goldmethod2(x01,x02,d,h0);%确定最优步长alphaalphax(n+1,:)=x(n,:)+alpha*d;e(j,:)=[];e(n,:)=d;x0=x(n+1,:);elseifF2<F3x0=x(n,:);elsex0=x(n+1,:);endend%44444x0xendfunction[a,b]=search(x01,x02,d,h0)%search为外推法确定搜索区间函数%h0为初始试探步长%[a,b]为搜索区间%%%%%%%%%%第一次搜索%%%%%%%%%a1=0;y1=ff(x01+d(1)*a1,x02+d(2)*a1);h=h0;a2=h;y2=ff(x01+d(1)*a2,x02+d(2)*a2);ify2>y1%反向搜索h=-h;a3=a1;y3=y1;a1=a2;y1=y2;a2=a3;y2=y3;enda3=a2+h;y3=ff(x01+d(1)*a3,x02+d(2)*a3);%%%%%%%%%%继续搜索%%%%%%%%%%whiley3<y2h=2*h;a1=a2;y1=y2;a2=a3;y2=y3;a3=a2+h;y3=ff(x01+d(1)*a3,x02+d(2)*a3);end%%%%%%%%%%确定搜索区间%%%%%%%%%%ifh>0a=a1;b=a3;elsea=a3;b=a1;end%a,b