Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematica matrix diagonalization

I'm considering a matrix A such that A=PDP^-1.

The way I solve this using Mathematica is:

a={{0, -1}, {-1, 0}}
d = DiagonalMatrix[Eigenvalues[a]]
{{-1,0}, {0,1}}
p = Transpose[Eigenvectors[a]]

p.d.Inverse[p]
{{0, -1}, {-1, 0}}

Which is correct.

Problem is, the P matrix is not what I expected it to be. The matrix that Mathematica generates is

p={{1, -1}, {1, 1}}

But I am looking for

p2={{1/Sqrt[2], 1/Sqrt[2]}, {1/Sqrt[2], -(1/Sqrt[2])}}
p2.d.Inverse[p2]
{{0,-1}, {-1,0}}

Which also solves the equation. Is there a way for me to force Mathematica to show me different answers when executing Transpose[Eigenvectors[a]]?

like image 608
CHM Avatar asked Dec 02 '22 00:12

CHM


1 Answers

What you need to do is normalize the answer you get. There is a function called Normalize, which can be used like this:

Normalize /@ {{1, -1}, {1, 1}}

Mathematica graphics

like image 101
C. E. Avatar answered Jan 24 '23 13:01

C. E.