Experiment 4 Eigenvalues and Diagonalization
Experiment 4 Eigenvalues and Diagonalization
Experiment 4 Eigenvalues and Diagonalization
Experiment 4
Eigenvalues and Diagonalization of Square
Matrices
Department of Mathematics
January 7, 2020
Eigenvalues and Diagonalization Experiment 4
1 Aim
2 Mathematical Description
Ax = λ x, (2.1)
where λ is a scalar. The values of λ , for which nontrivial solutions x 6= 0 exist, are
called eigenvalues of A, and the corresponding nontrivial solutions are eigenvectors
of A.
3 Matlab Code
clc
clear
A= input ( 'A = ' )
dim= length ( A ) ;
l = eig ( A )
for i = 1 : dim
disp ( [ ' E i g e n v e c t o r X ' , num2str ( i ) ] )
disp ( n u l l ( A − l ( i ) *eye ( dim ) ) )
end
Remark 3.1.
This code is useful for
Example 3.1.
2 −2 3
Verify the above code for A = 1 1 1 ·
1 3 −1
Input
Enter the matrix A = [ 2 −2 3 ; 1 1 1 ; 1 3 −1]
Output
A =
2 −2 3
1 1 1
1 3 −1
l =
3.0000
1.0000
−2.0000
E i g e n v e c t o r X1
−0.5774
−0.5774
−0.5774
E i g e n v e c t o r X2
0.5774
−0.5774
−0.5774
E i g e n v e c t o r X3
−0.6168
−0.0561
0.7851
Example 3.2.
2 1 −5
Verify the above code for A = 0 1 −2 ·
0 0 2
Input
Enter the matrix A = [ 2 1 −5;0 1 −2;0 0 2 ]
Output
A =
2 1 −5
0 1 −2
0 0 2
l =
2
1
2
E i g e n v e c t o r X1
1
0
0
E i g e n v e c t o r X2
0.7071
−0.7071
0.0000
E i g e n v e c t o r X3
1
0
0
Example 3.3.
1 −1 0
Verify the above code for A = −1 2 −1 ·
0 −1 1
Input
Enter the matrix A = [ 1 −1 0; −1 2 −1;0 −1 1 ]
Output
A =
1 −1 0
−1 2 −1
0 −1 1
l =
0.0000
1.0000
3.0000
E i g e n v e c t o r X1
0.5774
0.5774
0.5774
E i g e n v e c t o r X2
−0.7071
−0.0000
0.7071
E i g e n v e c t o r X3
0.4082
−0.8165
0.4082
4 Self-check Exercises
Exercise 4.1.
Find the eigenvalues and the corresponding eigenvectors of each of the following
matrices:
1 1
1. A =
−2 4
2 0
2. A =
1 2
2 2 0
3. A = 2 1 1
−7 2 −3
1 2 1
4. A = 6 −1 0
−1 −2 −1
Concept-based Exercise
Exercise 4.2.
Write a matlab code to find the distinct integer-eigenvalues and eigenvectors of
a square matrix, using the definition.
Code.
clc
clear
close a l l
A= input ( ' Enter the matrix to be d i a g o n a l i z e d A = ' )
[ P D ] = eig ( A )
disp ( ' D i a g o n a l form o f A i s ' )
diA = inv ( P ) *A*P ;
disp ( diA )
Here, D is the diagonal matrix with eigenvalues of A as the diagonal entries, and P
is the modal matrix with the corresponding eigenvectors of A as its column vectors,
such that P ∗ D = A ∗ P or D = P−1 AP.
Remark 5.1.
This code applies to only matrices with distinct eigenvalues.
Example 5.1.
−1 4
Verify the above code for A = ·
2 1
Input
Enter the matrix to be d i a g o n a l i z e d A = [−1 4 ; 2 1 ]
Output
A =
−1 4
2 1
P =
−0.8944 −0.7071
0.4472 −0.7071
D =
−3 0
0 3
D i a g o n a l form o f A i s
−3.0000 0.0000
0 3.0000
Example 5.2.
0 −1 −3
Diagonalize A = 2 3 3 ·
−2 1 1
Input
Enter the matrix to be d i a g o n a l i z e d A = [ 0 −1 −3;2 3 3; −2 1 1 ]
Output
A =
0 −1 −3
2 3 3
−2 1 1
P =
0.5774 0.5774 −0.5774
Self-check Exercises
Exercise 5.1.
Reduce each of the following matrices into a diagonal form D, using a nonsingular
matrix P such that P ∗ D = A ∗ P:
6 5
1. A =
3 4
1 −2 3
2. A = 0 2 5
0 0 3
1 −2 2
3. A = −2 1 −2
2 2 1
The diagonal form of symmetric matrix is obtained through the orthogonal modal
matrix by the following code:
clc
clear
close a l l
A= input ( ' Enter the s y m e t r i c matrix A : ' )
[ P D ] = eig ( A )
N=normc ( P )
disp ( ' D i a g o n a l form o f A i s : ' )
DM=N' *A*N
Here, D = DM is the diagonal matrix with eigenvalues of A as the diagonal entries,
and P is the modal matrix with the corresponding eigenvectors of A as its column
vectors, such that P ∗ D = A ∗ P or D = P−1 AP. The eigen vectors in N are in the
normalized form, and are pairwise orthogonal. That is, the norm of each column
is 1, and transpose(P(:, i)) ∗ P(:, j) = 0 for i 6= j.
Remark 6.1.
This code applies to symmetric matrices with distinct eigenvalues.
Example 6.1.
−3 4
Verify the above code for A = ·
4 3
Input
Enter the s y m e t r i c matrix A:[ −3 4 ; 4 3 ]
Output
A =
−3 4
4 3
P =
−0.8944 0.4472
0.4472 0.8944
D =
−5 0
0 5
N =
−0.8944 0.4472
0.4472 0.8944
D i a g o n a l form of A i s :
DM =
−5.0000 0
0 5.0000
Self-check Exercises
Exercise 6.1.
Reduce each of the following matrices into a diagonal form D, using an orthogonal
matrix P such that P ∗ D = A ∗ P:
1 9
1. A =
9 1
1 3
2. A =
3 9
1 2 1
3. A = 2 1 1
1 1 2
1 2 0
4. A = 2 −1 0
0 0 1
Concept-based Exercise
Exercise 6.2.
Let A be a square matrix with distinct integer-eigenvalues. Develop a matlab code
to diagonalize through an appropriate nonsingular matrix P.
Exercise 6.3.
Let A be a symmetric matrix with distinct integer-eigenvalues. Develop a matlab
code to diagonalize it through orthogonal modal matrix.