Message Boards Message Boards

11 Replies
0 Total Likes
View groups...
Share this post:

how to diagonolize this matrix?

Posted 10 years ago
m = {{0, 0, w}, {0, t, -w}, {w, -w, r}}

use equation P^(?1)A P, how to obtain P with Mathematica? Thanks!

POSTED BY: Kouhei Mori
11 Replies
Posted 10 years ago

Hello everyone!

Actually I used the answer from another friend (as he wrote):

{vals, vects} = Eigensystem[m = {{0, 0, w}, {0, t, -w}, {w, -w, r}}, Cubics -> True];

P = Transpose@vects;

dd = Inverse@Transpose@vects.m.Transpose@vects;

By the way, it is really confused for a beginner of mathematica to get familiar with something like this:'Root[-q^2 v + s^2 v + 2 s t v + t^2 v + 4 q^2 w + (q^2 - s^2 - 2 s t - t^2 + 2 q v - 4 q w) #1 + (-2 q - v) #1^2 + #1^3 &, 1]'

POSTED BY: Kouhei Mori

I did this one by hand and had to complete the square to get two of the eigenvalues. You wind up with a polynomial in t and can move the m variable to the other side. Then you complete the square to get (Lambda by itself). The answer is a mess and I cannot see how you can work with this answer or how mathematica can know you have to complete the square. I do not know how the program works to do this, but I cannot see mathematica doing this. The eigenvalues have at the least three terms in them. I could not see trying to find the eigenvectors since the eigenvalues have three terms in them. I have never seen a problem like this come up in a real life situation. Even for Electromagnetism the B and E values are a tensor so you do not run into this problem.

POSTED BY: Russell Barry

If you want to see a (very large) solution in terms of radicals, try Eigensystem[mat[t, w, r],Cubics->True]

POSTED BY: Daniel Lichtblau

Problems like this arise all over the place. A 3 by 3 matrix is not that unusual. In the general case Mathematica presumably uses the general solution to the cubic. One can do it, similarly, by hand by taking down one's trusty dog-eared copy of Abramowitz & Stegun and plug in the values:

POSTED BY: David Reiss

I gather that you are looking to diagonalize your matrix using a similarity transform. One approach is to use the SingularValueDecomposition function in Mathematica:

Analytically, since the eigenvalue problem requires solving a cubic, the expressions in the symbolic case will involve Root expressions... they can be converted to analytical expressions using ToRadicals.

However, assuming your parameters are real here is an equivalent approach. I am changing some of your notation to make things clear.

First define a function to generate your matrix in general:

mat[t_, w_, r_] := {{0, 0, w}, {0, t, -w}, {w, -w, r}}

You can find the symbolic expressions for the eigenvalues and eigenvectors using something like

Eigensystem[mat[t, w, r]]

and you can change the Root objects to algebraic expressions using, for example,

 ToRadicals[Eigensystem[mat[t, w, r]]], {t \[Element] Reals, 
  w \[Element] Reals, r \[Element] Reals}]

However, to illustrate the diagonalizatoin process let's play with numerical values. Let's first create a random example of your matrix:

testMatrix = mat[Random[], Random[], Random[]]

Now generate the eigenvalues and eigenvectors for this matrix using


The similarity transform is the matrix of eigenvectors

pMatrix = eigens[[2]]

and you can see this by executing

pMatrix.testMatrix.ConjugateTranspose[pMatrix] // Chop

the Chop is there to remove machine number leftovers.

This is also the same as

pMatrix.testMatrix.Inverse[pMatrix] // Chop

The same set of computations can (more generally) be done using SingularValueDecomposition.

And I see that Ivan Morozov pointed you to JordanDecomposition, which is, of course, a simpler path... ;-)

POSTED BY: David Reiss

SVD is not really a similarity transform. The left and right m,ultipliers are not in general related.

Eigensystem is the function for this. JordanDecomposition can be used to get one as close as possible, in cases where the matrix is not diagonalizable.

POSTED BY: Daniel Lichtblau

Hi, Kouhei,

Use JordanDecomposition[] function, here is a simple example:

M = {{-1, 3, -1}, {-3, 5, -1}, {-3, 3, 1}} ;
{P, A} = JordanDecomposition[M] ;


POSTED BY: Ivan Morozov

You gave the matrix in Wolfram Language syntax, a good start.

Your question is not completely clear. An equation has one side equal to the other side. Did you mean

m == P^(?1)  A  P

What is A?

POSTED BY: Moderation Team

He is trying to diagonalize a matrix. In his format A would be the original matrix. P would be the matrix with the eigenvectors in it and inverse P is the inverse of the P matrix. I could not even get mathematica to give me the eigenvalues of this matrix, which would also be the values along the diagonal, since P^(?1)A P=(The diagonal eigenvalues). Numbers work but with letters, mathematica gives back answers that does not make sense. If he could just get the eigenvalues, that would be all he would need. If the original matrix does not have an inverse then it cannot be diagonalized.

POSTED BY: Russell Barry

Take a look at my examples below. Mathematica does give eigenvalues in terms of Root objects which can be converted to algebraic expressions using ToRadicals.

POSTED BY: David Reiss

Thanks, I want to also know how to do this in mathematica. By hand it would take a long time, because we are working with letters and not numbers. I want to learn more about mathematica.

POSTED BY: Russell Barry
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract