Inverse Power Method Doesnt Work
8 次查看(过去 30 天)
显示 更早的评论
I try to find the smallest eigenvalue of a matrix using the Power Method to approximate its conditional number but it doesnt work. I can find the biggest eigenvector but not the smallest.
function [dk1,dkinf]=fun(x)
n = numel(x)-1;
psi = @(x)exp(-3*x.^2);
L = zeros(n+1);
for i = 1:n+1
L(i,:) = psi(x(1:n+1)-x(i));
end
format long
L
antL=inv(L)
A=max(sum(abs(L)))
B=max(sum(abs(antL)))
dk1=A*B
C=max(sum(abs(L')))
D=max(sum(abs(antL')))
dkinf=C*D
xold = 0.5*ones(n+1,1);
t=7
for i = 1:t
xnew=L*xold;
X=xnew/norm(xnew,2);
xold=xnew;
end
trX=transpose(X);
lmax=(trX*L*X)/(trX*X)
max(eig(L))
xold3 = 0.5*ones(n+1,1);
s=4
for i = 1:s
xnew2=L\xold3;
antX=xnew2/norm(xnew2,2);
xold3=xnew2;
end
trantX=transpose(antX);
antlmax=(trantX*(L\antX))/(trantX*antX)
lmin=1/antlmax
CN=lmax/lmin
end
1 个评论
Suman Sahu
2023-3-10
Similar questions have been asked by other users. Please go through these answers to see if they may be helpful to your case.
回答(1 个)
Harsh Sanghai
2023-3-21
Hi,
The Power Method is typically used to find the largest eigenvalue and its associated eigenvector of a matrix. To find the smallest eigenvalue, you can use the Inverse Power Method, which is a variant of the Power Method.
Here is the modified code that implements the Inverse Power Method to find the smallest eigenvalue:
function [dk1, dkinf, CN] = fun(x)
n = numel(x)-1;
psi = @(x)exp(-3*x.^2);
L = zeros(n+1);
for i = 1:n+1
L(i,:) = psi(x(1:n+1)-x(i));
end
antL = inv(L);
A = max(sum(abs(L)));
B = max(sum(abs(antL)));
dk1 = A*B;
C = max(sum(abs(L')));
D = max(sum(abs(antL')));
dkinf = C*D;
% Inverse Power Method to find the smallest eigenvalue
xold = ones(n+1, 1);
mu = 0; % initial guess for eigenvalue
tol = 1e-10; % tolerance for convergence
maxiter = 100; % maximum number of iterations
for k = 1:maxiter
xnew = L\xold;
mu_new = (xnew'*xold)/(xold'*xold);
if abs(mu_new - mu) < tol
break;
end
xold = xnew;
mu = mu_new;
end
lmin = mu;
CN = lmax/lmin;
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!