How to remember the eigendecomposition formula?
Let be a semi definite matrix with (positive) eigenvalues and corresponding column eigenvectors , i.e.
for . Then we have the eigendecomposition formula
where
- is a matrix of size .
- is a diagonal matrix of size .
- denotes the transpose of .
Proof. We have
Thus,
Since each is a column vector.
Hence we obtain
or
Note. To remember how to derive we may use the clue
which is a matrix formulation of .
Code Example.
Simulation
import numpy as np
from math import pi
alpha = pi/12
U = np.array([[np.cos(alpha), -np.sin(alpha)], [np.sin(alpha), np.cos(alpha)]])
D = np.diag([1., 2.])
A = U @ D @ U.T
print(f"U={U}")
print(f"D={D}")
print(f"A=UDU^T={A}")
result
U=[[ 0.96592583 -0.25881905] [ 0.25881905 0.96592583]]
D=[[1. 0.] [0. 2.]]
A=UDU^T=[[ 1.0669873 -0.25 ] [-0.25 1.9330127]]
eigendecomposition with numpy
L, U2 = np.linalg.eig(A)
print(f"L={L}")
print(f"U2={U}")
result
L=[1. 2.]
U2=[[ 0.96592583 -0.25881905] [ 0.25881905 0.96592583]]
We can clearly see that U
and U2
are the same, this confirms our formula.