フィルターのクリア

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 Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by