construc matrix D by OD process?

3 visualizaciones (últimos 30 días)
Le Xuan Thang
Le Xuan Thang el 3 de Jul. de 2019
Comentada: Le Xuan Thang el 7 de Jul. de 2019
If i have matrix A=[ 1 -2 2
-2 4 -4
2 -4 4 ];
Then i want find S is orthogonal(construct by eigenbasis) and D is orthogonal diagonalization(diagonal matrix).
I construct D like this:
char=charpoly(A);
eigenvalues=roots(char);
eigenvalues=flipud(eigenvalues);
%This is matrix D
D=diag(eigenvalues);
Am i right?
Plz fix me.
Many thank
  2 comentarios
John D'Errico
John D'Errico el 3 de Jul. de 2019
Are you right? Well, D is diagonal. It will contain the eigenvalues, because you managed to find them via a different scheme based on the character istic polynomial. But, did you obtain it by an orthogonal diagonization process? No. So are you right? Not really.
Le Xuan Thang
Le Xuan Thang el 3 de Jul. de 2019
I want construct D like D=S'*A*S. Is that matrix D i need? like i construct it.

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 3 de Jul. de 2019
Editada: John D'Errico el 3 de Jul. de 2019
I suppose I'll make this an answer instead of just a comment, since nobody has answered yet.
If all you wanted is to construct the diagonal matrix of eigenvalues, then if the matrix has a complete set of eigenvalues (i.e., it is not a defective matrix) then yes, you will have created the matrix D.
Interestingly, what you did was partly of no use. For example, the call to flipud does not do as much as you think. I assume you wanted the eigenvalues in some special sequence, but roots does not guarantee any special order for the result. They are usually ROUGHLY in sequence. For example...
roots(rand(1,6))
ans =
-0.89835 + 0.90816i
-0.89835 - 0.90816i
0.55269 + 0.84217i
0.55269 - 0.84217i
-0.13261 + 0i
You can see they were initially sorted so the roots with largest magnitude come out first. But that need not always happen. Higher degree polynomials may find that sequence is only approximately sorted in magnitude.
Is your matrix always symmetric? Perfectly so? If not, then expect complex eigenvalues are probable. But you can use sort instead of flipud to gain a more accurately sorted set of eigenvalues.
But note that what you are doing does NOT give you a set of eigenvectors, thus the matrix S.
Anyway, a fine point is that as you want to construct the eigenvalues, IF your goal is for some strange reason NOT to use eig? That reason fails miserably here. Why? Because you are STILL going to use eig in the end. The point is, you seem to want to use roots to avoid using eig. But you STILL use eig, because roots calls eig! That is, roots converts the polyynomial coefficient into a matrix, then calls eig on that matrix.
So honestly, it seems silly. You take a matrix, convert it into a characteristic polynomial, then call roots. But roots then converts that polynomial BACK into a matrix. Then calls eig. Do you see the problem here? Why bother? Your subterfuge does nothing, except waste CPU cycles. MATLAB still calls eig in the end.
Finally, it is a bad idea to name your variable char, because at some point, you will find the function char is a useful one, and having a variable with that name can cause your code to fail with strange looking bugs.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by