Eigenvalues by power method

25 visualizaciones (últimos 30 días)
Sofy
Sofy el 1 de Jun. de 2022
Editada: John D'Errico el 1 de Abr. de 2024 a las 19:39
hello everyone, is there's anyone could help me to solve this problem using matlab code
  3 comentarios
James Tursa
James Tursa el 1 de Jun. de 2022
What have you done so far? What specific problems are you having with your code?
Sofy
Sofy el 2 de Jun. de 2022
actually it wasn't home work I'm just try to know the way of coding this issue coz I'm beginner in matlab

Iniciar sesión para comentar.

Respuesta aceptada

Hiro Yoshino
Hiro Yoshino el 1 de Jun. de 2022
See eig and eigs. Looks like eigs is more suitable for you though ...
I suppose u represents an eigen vector but the initial point seems to have to be u_0. In this case you may need to keep the norms of the eigen vectors <= 1.
  3 comentarios
Hiro Yoshino
Hiro Yoshino el 1 de Jun. de 2022
Agreed
Sofy
Sofy el 1 de Jun. de 2022
Thx for your comments

Iniciar sesión para comentar.

Más respuestas (1)

Kashish
Kashish el 1 de Abr. de 2024 a las 10:13
Editada: Voss el 1 de Abr. de 2024 a las 16:29
function [m,y_final]=power_method(A,x);
m=0;
n=length(x);
y_final=zeros(n,1);
y_final=x;
tol=1e-3;
while(1)
mold=m;
y_final=A*y_final;
m=max(y_final);
y_final=y_final/m;
if (m-mold)<tol
break;
end
end
end
  1 comentario
John D'Errico
John D'Errico el 1 de Abr. de 2024 a las 16:08
Editada: John D'Errico el 1 de Abr. de 2024 a las 19:39
I'm sorry, but this code is terribly poor as an answer to the question. It will fail far too often. (I'm not even sure it will ever work correctly. My guess is, under a specific set of circumstances, it MAY produce an estimate of an eigenvalue.) In fact, there are multiple flaws in the code I can see. If I tell you what you did wrong, you won't learn anything. You need to spend some time understanding what you did.
A = rand(3) - 3*eye(3)
A =
-2.1537 0.59001 0.50669
0.45027 -2.5355 0.19874
0.08948 0.47973 -2.5368
eig(A)
ans =
-1.6144 + 0i
-2.8058 + 0.13422i
-2.8058 - 0.13422i
I've created a simple 3x3 matrix. Surely power_method might find even one of the eigenvalues? How hard can that be? Yes, two of the eigenvalues were complex, but the other is not.
power_method(A,ones(3,1))
ans =
-1.057
I would suggest you consider why the code failed, even on that simple example. If it bothers you that my example matrix had complex eigenvalues, then I'll do this:
A = A + A'
A =
-4.3073 1.0403 0.59617
1.0403 -5.071 0.67847
0.59617 0.67847 -5.0736
That simple operation insures all of the eigenvalues are real. We can test that claim easily enough.
eig(A)
ans =
-5.8925
-5.387
-3.1725
So purely real eigenvalues. But surely your code should work now?
power_method(A,ones(3,1))
ans =
-2.6709
So strange. It still fails miserably.
Ok, maybe your code will only work on symmetric, positive definite matrices? Anyway, that was what was requested in the homework assignment as posted. Sigh. It does not. I can swap the signs on the eigenvalues of A simply enough.
A = -A
A =
4.3073 -1.0403 -0.59617
-1.0403 5.071 -0.67847
-0.59617 -0.67847 5.0736
eig(A)
ans =
3.1725
5.387
5.8925
Surely with 3 positive eigenvalues on a symmetric matrix, surely it will work?
power_method(A,ones(3,1))
ans =
5.2965
How strange. It still fails completely, even on what should be a trivially simple problem now. It came a little closer this time, but really...
Again, you should seriously look at your code, and think about what happened, why it failed. Use the debugger, running on that last example matrix and think about why your code is failing.

Iniciar sesión para comentar.

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by