|
%Given a ill-posed problem: Af=g where A has a very large condition number
%a) singular values
sigma=svd(A);
figure;
plot(sigma,'b-','linewidth',1.5);
title('Singular values');
%b) condition number
k=cond(A,2);
disp('The condition number of A is:');
disp(k);
%c) pseudosolution
%fs=sum(Vk*Uk'*g/sigma)
[u,s,v]=svd(A);
sigma=diag(s);
fs=zeros(size(g));
for ii=1:rank(s);
temp=(1/sigma(ii))*v(:,ii)*u(:,ii)'*g;
fs=fs+temp;
end
figure;
plot(fs,'b-','linewidth',1.5);
title('Pseudosolution');
%Alternatively
%r=rank(A); %sinv=diag(1./sigma); %fs=v(:,1:r)*sinv(1:r,1:r)*u(:,1:r)'*g;
% discrepancy
%epsillon=sqrt(Af-g);
eps=abs(A*fs-g);
figure;
plot(eps,'b-','linewidth',1.5);
title('Discrepancy');
% energy E
E=fs.^2;
figure;
plot(E,'b-','linewidth',1.5);
title('Energy');
%Note the problem can also be solved by QR factorization or householder reflectors. But SVD is more preferable inasmuch it is robust to noise, able to hand rank-deficiency and efficient in computation as well.
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-5 04:12
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社