advertisement

MATH 267 Use of MATLAB to solve ODEs, Part 2 Eigenvalues and eigenvectors: 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. Laplace transform: MATLAB also contains easy to use commands for both the Laplace transform and the inverse Laplace transform. These require that the Symbolic Toolbox be installed1 . Enter the following commands for a simple demonstration: >> syms t s >> f=t*exp(-2*t) >> laplace(f) 1 See me if you are not sure about this 1 The answer will be the Laplace transform of f (t) = te−2t , expressed in the MATLAB syntax. Next if you type >> F=1/(sˆ3-sˆ2+s-1) >> ilaplace(F) the answer will be the inverse Laplace transform of F (s) = 1/(s3 − s2 + s − 1). The first MATLAB command above establishes t,s as symbolic expressions. Other expressions defined in terms of t,s, such as f, F are then automatically symbolic expressions also. Complicated symbolic expressions may be constructed from simpler ones, for example >> F1=3+exp(-s) >> F2=sˆ2-4 >> F=F1/F2 If F is any symbolic expression the command >> pretty(F) may be used to display an expression for F in a more easily readable format. 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 the laplace command to find the Laplace transform of f (t) = 2t2 e−t cos (4t) + 5) Use the ilplace command to find the inverse Laplace transform of F (s) = √ t. e−4s (2s+1) . s3 (s2 +2s+5) 6) Use MATLAB Laplace transform capabilities as much as possible to solve the initial value problem y 000 + 6y 00 + 15y 0 + 50y = te−5t + t3 y(0) = 2 y 0 (0) = 1 y 00 (0) = 0 In 4-6, your final answer should be written out and expressed in ordinary mathematical notation, not the MATLAB syntax. Note that Matlab uses the word ’Heaviside’ to denote the unit step function. 2