# How to find a diagonalizing basis of a matrix by using Mathematica? [closed]

I have a $$3\times 3$$ matrix which I want to diagonalize, $$A$$.

So I want to find the matrix $$P$$ such that $$A=P^{-1}DP$$, where $$D$$ is the diagonal matrix such that the eigenvalues of $$A$$ appear in the diagonal of $$D$$.

How do I find $$P$$ via Mathematica? Is there a suitable command?

Thanks! I checked the help section in Mathematica and didn't find such a command.

• JordanDecomposition[$A$] returns $\{P^{-1},D\}$. (See DiagonalizableMatrixQ.) Jan 31, 2021 at 9:08
• To make Sneeze's hint more explicit: unless you're absolutely sure your matrix is diagonalizable (symmetric, normal, etc.), use JordanDecomposition[]. Jan 31, 2021 at 12:30
• Check. Documentation. For. Eigensystem. Jan 31, 2021 at 15:52

example:

m = {{1, 0, 0, 1}, {0, -1, 1, 0}, {0, 1, -1, 0}, {1, 0, 0, 1}};
DiagonalizableMatrixQ@m
True

{d, pt} = Eigensystem@m;
p = Transpose@pt;
p . DiagonalMatrix[d] . Inverse[p]
{{1, 0, 0, 1}, {0, -1, 1, 0}, {0, 1, -1, 0}, {1, 0, 0, 1}}

{s, j} = JordanDecomposition@m;(* returns {P^-1,D} *)
s . j . Inverse@s (* P^(-1).D.P *)
{{1, 0, 0, 1}, {0, -1, 1, 0}, {0, 1, -1, 0}, {1, 0, 0, 1}}