MATH 267 Use of MATLAB to solve ODEs, Part 2

advertisement
MATH 267
Use of MATLAB to solve ODEs, Part 2
MATLAB can be used to do the tedious work of finding the eigenvalues and eigenvectors of
large matrices. The command
>> [v,d]=eig(A)
returns eigenvalues and eigenvectors of the matrix A. Here d is a matrix for which the diagonal
element d(k,k) is the k’th eigenvalue of A and v is a matrix whose k’th column is an eigenvector
corresponding to the k’th eigenvalue. For example to find the eigenvalues and eigenvectors of


3
2
2
4
1
A= 1
−2 −4 −1
we enter
>> A=[3 2 2;1 4 1;-2 -4 -1]
>> [v d]=eig(A)
to which MATLAB responds
v =
0.7071
-0.0000
-0.7071
0.8944
-0.4472
0.0000
-0.0000
0.7071
-0.7071
1.0000
0
0
0
2.0000
0
0
0
3.0000
d =
So the eigenvalues are r = 1, 2, 3 with each of the columns of v giving a corresponding eigenvector.
Why the oddball numbers in v? MATLAB insists on defining v so that each column is a
unit vector, i.e. the sum of the squares of the entries is always 1. The eigenvectors are thus
normalized
to p
have length 1. For example, the 3rd column, corresponding to r = 3 is really
p
col(0, 1/2, − 1/2). However you should recognize that for the purpose of writing down the
solution of x0 = Ax it would be a lot neater to use the equivalent eigenvector col(0, 1, −1).
Similarly the first two columns could be ’unnormalized’ to give col(1, 0, −1) and col(2, −1, 0).
If the eigenvalues are complex, MATLAB will still return the eigenvalues and (complex)
eigenvectors.
As long as the Symbolic toolbox is installed, MATLAB also has the capability to compute
the fundamental matrix eAt for any square matrix A, as follows:
>> syms t
>> X=expm(A*t)
The columns of X can then be read off to provide a fundamental set for x0 = Ax.
1
Homework
In 1 and 2, use the eig command as much as possible to find the general solution of the
system x0 = Ax. Always try to use ’unnormalized’ eigenvectors when expressing the solution,
and in the case of complex eigenvalues express the solution in real form.
1.
2.


4 1 1 7
1 4 10 1

A=
1 10 4 1
7 1 1 4


1
1
0
A = −2 1 −1
0 −1 1
3. What does the eig command seem to do when A has repeated eigenvalues? (Try a couple of
examples in which you know what the eigenvalues and eigenvectors should be. Consider both
the case when algebraic and geometric multiplicity are the same, and when they are different.)
4. Use MATLAB to obtain the fundamental matrix eAt for


0 −1 1
A = 2 −3 1 
1 −1 −1
(Notice there is a repeated eigenvalue in this example, with geometric multiplicity unequal to
algebraic multiplicity, but we still get a fundamental matrix this way.)
2
Download