필터 지우기
필터 지우기

Inverse Power Method Doesnt Work

조회 수: 8 (최근 30일)
Filippos Georgios Sarakis
Filippos Georgios Sarakis 2023년 1월 19일
답변: Harsh Sanghai 2023년 3월 21일
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개)

Harsh Sanghai
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

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by