3
$\begingroup$

enter image description here

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.

$\endgroup$
5
  • $\begingroup$ People here generally like users to post code as copyable Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find the meta Q&A, How to copy code from Mathematica so it looks good on this site, helpful $\endgroup$
    – Michael E2
    Mar 27, 2023 at 17:38
  • $\begingroup$ @Michael From now on I will copy the code. $\endgroup$
    – eraldcoil
    Mar 27, 2023 at 17:47
  • $\begingroup$ Note that Eigensystem[] on an exact matrix does not (usually) produce normalized eigenvectors. So you need to Normalize[] them, if you want to construct a unitary matrix from them. $\endgroup$
    – Michael E2
    Mar 27, 2023 at 18:04
  • $\begingroup$ Would that mean adding Normalize[v]? $\endgroup$
    – eraldcoil
    Mar 27, 2023 at 20:11
  • $\begingroup$ To normalize each vector use Map (/@): u = Transpose[Normalize /@ v]. Or search for "normalize" in the documentation for Eigensystem; they show how to use it to diagonalize a matrix, more or less what you're doing here. $\endgroup$
    – Michael E2
    Mar 27, 2023 at 21:36

1 Answer 1

4
$\begingroup$

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

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ You're right. By simplifying you could lose information. Thank you so much. $\endgroup$
    – eraldcoil
    Mar 27, 2023 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 of Simplify 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 system Simplify becomes more important. Be careful that FullSimplify if overdone can slow down things in long computation. But you can add TimeConstrained to avoid being stuck. $\endgroup$
    – Nasser
    Mar 27, 2023 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.