7.2 Lab B

advertisement
MAT 2401 Discovery Lab 7.2 B Names___________________________________
Objectives
 To explore the computational cost of matrix multiplications.
 To explore the relationship between diagonalization and eigenvalues/eigenvectors.
 Use SageMath to facilitate the computations for large matrices.
Instructions
 Do not look up any references including the textbook and internet.
 Do not use a calculator. You are supposed to learn SageMath.
 Use SageMath for all your calculations.
 Use correct notations and do not skip steps.
 Two persons per group. Do not communicate with other groups.
SageMath Codes
Eigenvalues
E=Matrix([[..],...,[..]]);show(E);
show(E.eigenvalues());
The following SageMath codes give the eigenvalues and eigenvectors. The results are
listed in the form of
  ,  x, y  , m 
E=Matrix([[..],...,[..]]);show(E);
show(E.eigenvectors_right());
1
Computational Cost
Let A be an n  n matrix, where n  2 is an integer. Suppose that A  PDP1 , where
P and D are n  n matrices and D is a diagonal matrix. We can compute Ak by
using the formula
(1)
Ak  PDk P 1 ,
where k  2 is an integer.
In 7.2 Lab A and HW 7.2 A, we compared the operations needed for computing Ak
directly and via the formula (1). We see that it is a lot more efficient to use the formula (1)
especially when n and k is large.
In general, multiplications are a lot more time consuming than additions. When n is
large, the total computational cost is dominated the cost of multiplications. In the light of
this information, we can summarize what we know about computational cost in the table
below.
Computational Method
Ak  A  A 
A
k copies
Ak  PDk P 1
Number of Operations
Approximately Proportional to k and n3
Approximately Proportional to k and n
Hidden Cost
Of course, in order to use formula (1), we need to take into account of the cost of
computing matrices P , D and P1 which we are not going into details in this class.
Note that because we only need to compute these matrices once. So the associated cost is
negligible when the size of the matrix is large.
2
How to Find the Matrices P and D ?
1
Recall from 7.2 Lab A, problem 5. If A  
2
D can be given by
1 2 
P
 and
1 1 
4
, the corresponding matrices P and
3
5 0 
D
.
0 1
The following explorations will lead you to the method of finding P and D .
1 4
1. Let A  
.
 2 3
(a) Use SageMath to compute the eigenvalues 1 and 2 . To distinguish between the
two values, let us assume 1  2 .
(b) Rewrite D in terms of the eigenvalues 1 and 2 .
(c) Use SageMath to compute the eigenvector x1 of 1
(d) How is x1 related to P ?
3
(e) Use SageMath to compute the eigenvector x2 of 2 .
Your answer in (e) does not fit in the pattern similar to what you have in part (d). Fear not,
eigenvectors are unique up to a scalar. We can rescale the eigenvector by multiplying the
vector by 2 . Now, choose
 2 
x2    .
1
(f) Rewrite P in terms of the eigenvectors x1 and x2 .
Note that if we choose x2 as the original un-scaled vector, we would have a different P .
But the scaling would not affect the resulting product PDk P1 . See problem 2 below.
(g) Generalization based on your experience above with a 2  2 matrix.
Let A be an n  n matrix, where n  2 is an integer. Suppose the eigenvalues of A
are given by
1 , 2 , , n
and the corresponding eigenvectors are respectively
x1 , x2 , , xn
Suppose that we want to find the n  n matrices P and D such that
A  PDP1 ,
where D is a diagonal matrix. Write P and D in terms of i and xi .
4
1 1 
1 4
1 2 
 and D  5 0  .
2. Let A  
, P
, P1  
1


0 1
1  
 2 3
1 1 


2

(a) Compute P1 , PDP 1 , and PD6 P1 .
(b) Compute P11 , P1 DP11 , and P1 D 6 P11
As a conclusion, we see that depends on the scalars we choose for the eigenvectors, the
form of the matrix P varies. But all forms of P give us the same the product
Ak  PDk P 1 .
5
Download