Function Repository Resource:

DiagonalizeMatrix

Source Notebook

Get the diagonalized matrix of a given matrix

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["DiagonalizeMatrix"][mat]

returns the diagonalized matrix for the matrix mat.

Examples

Basic Examples (1) 

Return the diagonalized matrix for a matrix:

In[1]:=
ResourceFunction["DiagonalizeMatrix"][{{1, 2}, {3, 4}}]
Out[1]=
In[2]:=
ResourceFunction["DiagonalizeMatrix"][{{0, 1}, {1, 0}}]
Out[2]=

Scope (2) 

DiagonalizeMatrix works with complex-valued matrices:

In[3]:=
ResourceFunction["DiagonalizeMatrix"][{{I, 0}, {0, 1 - I}}]
Out[3]=

DiagonalizeMatrix works with matrices containing symbolic elements:

In[4]:=
ResourceFunction["DiagonalizeMatrix"][{{a, b}, {c, d}}]
Out[4]=

Properties and Relations (2) 

When the matrix is diagonalizable, DiagonalizeMatrix returns the diagonal matrix from JordanDecomposition:

In[5]:=
M = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; 
ResourceFunction["DiagonalizeMatrix"][M] === Last[JordanDecomposition[M]]
Out[5]=

The Eigenvalues of the matrix appear along the diagonal of DiagonalizeMatrix:

In[6]:=
Complement @@ Simplify@{Diagonal[ResourceFunction["DiagonalizeMatrix"][M]], Eigenvalues[M]} == {}
Out[6]=

Possible Issues (2) 

The function returns unevaluated when the matrix is not square:

In[7]:=
ResourceFunction["DiagonalizeMatrix"][{{1, 2, 3}, {4, 5, 6}}]
Out[7]=

The function returns unevaluated when the matrix is not diagonalizable:

In[8]:=
ResourceFunction[
 "DiagonalizeMatrix"][{{2, 4, -6, 0}, {4, 6, -3, -4}, {0, 0, 4, 0}, {0, 4, -6, 2}}]
Out[8]=

For non-diagonalizable square matrices, a form that is "almost" diagonalized exists, having zeros and ones on the superdiagonal and zeros elsewhere than the main diagonal. It can be found using JordanDecomposition:

In[9]:=
JordanDecomposition[{{2, 4, -6, 0}, {4, 6, -3, -4}, {0, 0, 4, 0}, {0, 4, -6, 2}}][[2]]
Out[9]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 3.0.0 – 23 March 2023
  • 2.0.1 – 02 February 2021
  • 2.0.0 – 02 October 2020
  • 1.0.0 – 24 March 2020

Related Resources

License Information