修正牛顿法matlab程序
时间: 2023-11-06 17:57:02 浏览: 129
以下是一个用Matlab编写的修正牛顿法的程序:
```matlab
function [x,val,k] = revisenm(fun,gfun,Hess,x0)
maxk=100;
rho=0.55;
sigma=0.4;
tau=0.0;
n=length(x0);
k=0;
e=1e-5;
while(k<maxk)
gk=feval(gfun,x0);
muk=norm(gk)^(1-tau);
if(norm(gk)<=e)
break;
end
Gk=feval(Hess,x0);
Ak=Gk + muk*eye(n);
dk=-Ak\gk;
m=0;
mk=0;
while(m<20)
if(feval(fun,x0 + rho^m*dk)<feval(fun,x0) + sigma*rho^m*gk'*dk)
mk=m;
break;
end
m=m+1;
end
x0=x0 + dk*rho^mk;
k=k+1;
end
x=x0;
val=feval(fun,x0);
end
```
阅读全文