matlab 梯度法(最速下降法)


norm(A,p)
当A是向量时
norm(A,p) Returns sum(abs(A).^zhip)^(/p), for any <= p <= ∞.
norm(A) Returns norm(A,)
norm(A,inf) Returns max(abs(A)).
norm(A,-inf) Returns min(abs(A)).
当A是矩阵时
n = norm(A) returns the largest singular value of A, max(svd(A))
n = norm(A,) The -norm, or largest column sum of A, max(sum(abs(A)).
n = norm(A,) The largest singular value (same as norm(A)).
n = norm(A,inf) The infinity norm, or largest row sum of A, max(sum(abs(A')))
n = norm(A,'fro') The Frobenius-norm of matrix A, sqrt(sum(diag(A'*A))).

A'*A的n个非负特征值的平du方根叫作矩阵A的奇异值

 

 

解 (i)∇f (x) =(2x(1) ,50x(2) )T
编写 M 文件detaf.m,定义函数 f (x)及其梯度列向量如下
function [f,df]=detaf(x);
f=x(1)^2+25*x(2)^2;
df=[2*x(1)
50*x(2)];
(ii)编写主程序文件zuisu.m如下:
clc
x=[2;2];
[f0,g]=detaf(x);
while norm(g)>0.000001
p=-g/norm(g);
t=1.0;f=detaf(x+t*p);
while f>f0
t=t/2;
f=detaf(x+t*p);
end
x=x+t*p;
[f0,g]=detaf(x);
end
x,f0

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM