Hello. I am learning in Mathematica how to obtain the unitary operator that allows us to diagonalize the matrix M. Although with U^{-1}.M.U am able to obtain the answer: why doesn't the program deliver it diagonally? (I had to verify that such a matrix is diagonal) Thank you.
1 Answer
why doesn't the program deliver it diagonally?
Mathematica does not simplify automatically (for good reasons). So you just need to simplify the result. That is all.
ClearAll["Global`*"]
M = {{2, 3}, {3, 7}}
{lambda, v} = Eigensystem[M]
U = Transpose[v]
(Inverse[U] . M . U) // Simplify // MatrixForm
-
$\begingroup$ You're right. By simplifying you could lose information. Thank you so much. $\endgroup$ Mar 27 at 17:46
-
2$\begingroup$ @eraldcoil if you are coming from system not symbolic (like Matlab) then
Simplify
will be new to you which is OK. in Matlab, since everything is numerical (vs. mix of numerical and Symbolics like in Mathematica), the concept ofSimplify
does not really apply as it is done automatically in Matlab and other systems like it (Fortran, etc..), since things are all numbers. But in CAS systemSimplify
becomes more important. Be careful thatFullSimplify
if overdone can slow down things in long computation. But you can addTimeConstrained
to avoid being stuck. $\endgroup$– NasserMar 27 at 17:49
Eigensystem[]
on an exact matrix does not (usually) produce normalized eigenvectors. So you need toNormalize[]
them, if you want to construct a unitary matrix from them. $\endgroup$Map
(/@
):u = Transpose[Normalize /@ v]
. Or search for "normalize" in the documentation forEigensystem
; they show how to use it to diagonalize a matrix, more or less what you're doing here. $\endgroup$