|
By: Neil E. Cotter |
Linear Algebra |
|
|
Eigenvals and eigenvecs |
|
|
Diagonalization |
|
|
Matlab® Example |
|
|
|
Ex: The following Matlab® code shows how to diagonalize a matrix A:
where
S has eigenvectors as its columns
Λ is diagonal with eigenvalues on its diagonal
syms a b c d
syms A S D
A = [a, b; c, d]
A =
[ a, b]
[ c, d]
[V,D] = eig(A)
V =
[ -(-1/2*a+1/2*d-1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2))/c, -(-1/2*a+1/2*d+1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2))/c]
[ 1, 1]
D =
[ 1/2*a+1/2*d+1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2), 0]
[ 0, 1/2*a+1/2*d-1/2*(a^2-2*a*d+d^2+4*b*c)^(1/2)]
Snum = [-1,1;1,0]'
Snum =
-1 1
1 0
Dnum = [2, 0; 0, 3]
Dnum =
2 0
0 3
Anum = Snum * Dnum * inv(Snum)
Anum =
3 1
0 2
[Vnum,Dnum] = eig(Anum)
Vnum =
1 -0.70711
0 0.70711
Dnum =
3 0
0 2