Math 125, Fall 2005 N. Kerzman DIAGONALIZATION AND FUNCTIONS OF MATRICES. A ROAD MAP INVOLVING MATLAB. We use MatLab notation without warning. Sometimes we use A*B for matrix multiplication (in MatLab style), and sometimes we just write AB (in math style). Matrices A are n by n. Their entries may be real or complex. The eigenvalues and eigenvectors of A are often complex even when A is real. We only consider n by n matrices A that have n distinct eigenvalues. This is the “most frequent” case, as explained in class. A need not be symmetric. References: Linear Algebra by Otto Bretscher, Prentice Hall. A nice undergraduate textbook. Matrix Theory , Vols. I, II, by F. Gantmacher, Chelsea. A thorough graduate level classic and reference. Very useful. -------1. Diagonalization of A. What is it? Starting with any n by n matrix A, the command (1.1) [V,R]=eig(A) produces two n by n matrices V and R. The 1st. column of V is an eigenvector of A, called v1. It corresponds to an eigenvalue r1 of A. Similarly for the second column, etc. R is a diagonal matrix. Its main diagonal has entries, r1, r2, …, rn. They are the eigenvalues of A. What we have just said can be written down more compactly as (1.2) AV VR 1 This is an immediate consequence of the definitions of an eigenvalue, an eigenvector, and of matrix multiplication. (Please verify it!) Notice: a) R is called R as a reminder that it goes on the right of V in (1.2). b) Even if A has all real entries, V and R often have complex entries. When A has n distinct eigenvalues r1,…,rn, the n eigenvectors v1,…,vn are linearly independent and hence V has an inverse V^(-1)=inv(V). This is basic linear algebra. See, e.g., Reference 1. Hence (1.2) can be rewritten A VRV 1 (1.3) Conclusion: An arbitrary matrix A need not be diagonal, of course. But if it has n distinct eigenvalues, then A can be expressed via (1.3) in terms of an associated diagonal matrix R. In the main diagonal of R sit precisely the eigenvalues of A. In mathematics language: “A has been diagonalized to R via the matrix V and (1.3)” Example 1.1 A = 7 2 0 2 6 2 -1 2 8 >> [V,R]=eig(A) V = 0.5524 -0.7580 0.3467 0.7071 -0.0000 -0.7071 0.1283 0.5611 0.8177 0 8.0000 0 0 0 9.3723 R = 3.6277 0 0 2 Checking now, we see that (1.3) holds: >> V*R*inv(V) ans = 7.0000 2.0000 0.0000 2.0000 6.0000 2.0000 -1.0000 2.0000 8.0000 The answer is A. Example 1.2. A = 0 -1 1 0 >> [V,R]=eig(A) V = 0.7071 0 + 0.7071i 0.7071 0 - 0.7071i R = 0 + 1.0000i 0 0 0 - 1.0000i Checking (1.3): >> V*R*inv(V) ans = 0 -1 1 0 This example shows how starting with a very simple real matrix, you may end up having to deal with complex eigenvalues and eigenvectors. In this case the eigenvalues are r1=i, r2=-i. -------- 3 2. What’s the point of diagonalization. What do you gain with it? When a matrix D is diagonal , it is extremely easy to write D^2, D^3,…, inv(D), and more . Namely, if D diag ([ d1 , d 2 ,..., d n ]) , then D 2 diag ([d1 , d 2 ,..., d n ]) , 2 2 2 D 3 diag ([d1 , d 2 ,..., d n ]) 3 3 3 D 1 diag ([1 / d1 ,1 / d 2 ,...,1 / d n ]) --the last one assuming that all the d j 0 , which is the only situation in which D 1 exists. Also expm( D) e D diag ([ e d 1 , e d 2 ,..., e d 3 ]) . All this is obvious when you focus your attention on what matrix multiplication means. Hence, for diagonal matrices D, the function f(D) of the matrix D, e.g., f ( D) D 2 , is obtained by simply replacing each d j by f ( d j ) . When the n by n matrix A is not diagonal, but it has n distinct eigenvalues, then (1.3), allows you to obtain f(A) working in the easiest possible way with R, exactly as we did with D above. SOMETHING IMPORTANT TO NOTICE : (2.1) (1.3) implies A2 VRV 1VRV 1 VR 2V 1 because VV 1 I Similarly, (2.2) A3 VR 3V 1 , A4 VR 4V 1 , etc. And A1 VR 1V 1 ,…, (2.3) that R 1 exists A4 VR 4V 1 , Please verify these formulas by yourself. understand each step. etc. -- assuming Make sure you Also for the exponential matrix e A , that by definition is A A2 ... , using (2.1) and (2.2) you get the series e I 1! 2! A e A Ve RV 1 4 Example 2.1 Find as many square roots as you can of the matrix A in Example 1.1. Here the function f ( A) is A. This looks difficult because A is not diagonal. But R is diagonal. R has many (eight) obvious square roots. You get them by taking the square root of each R(1,1), R(2,2), R(3,3). There are two choices for each , e.g., For each choice of (2.4) R(1,1) . (of the eight possible ones), the matrix R(1,1) M V * 0 0 0 R( 2,2) 0 0 1 0 *V R(3,3) is a square root of A. Reason: when you do M 2 M * M , you get M * M V * R * V 1 * V * R * V 1 VRV 1 A . -------- 3. An m-file for Example 2.1 %square roots of a 3 by 3 matrix A=[7 2 -1;2 6 2;0 2 8]; [V,R]=eig(A); %A=V*R*inv(V) %Compute the eight sqrt(R), call them S1, S2, etc. %S1=diag(w1); w1=[sqrt(R(1,1),sqrt(R(2,2),sqrt(R(3,3)], etc. w1=[sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))]; S1=diag(w1);M1=V*S1*inv(V); w2=[sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))];S2=diag(w2);M2=V*S2*inv(V); w3=[sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))];S3=diag(w3);M3=V*S3*inv(V); w4=[sqrt(R(1,1)),-sqrt(R(2,2)),sqrt(R(3,3))];S4=diag(w4);M4=V*S4*inv(V); w5=[sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))]; S5=diag(w5);M5=V*S5*inv(V); w6=[-sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))];S6=diag(w6);M6=V*S6*inv(V); 5 w7=[-sqrt(R(1,1)),sqrt(R(2,2)),sqrt(R(3,3))];S7=diag(w7);M7=V*S7*inv(V); w8=[-sqrt(R(1,1)),-sqrt(R(2,2)),sqrt(R(3,3))];S8=diag(w8);M8=V*S8*inv(V); -------- 4. Questions and answers a) Are the eight roots of A we got, namely different? M1, M2,…, M8 all Yes. Reason: say,e.g, M1=M2. Then S1=S2 necessarily because S1=inv(V)*M1*V and S2=inv(V)*M2*V. But the eight matrices S1, S2,…,S8 are different because they arise from different vectors w1,w2,…,w8. (the signs are different in some slot). Hence the Mk are also different. b) Are there any other square roots of A thay we did not think of? No: there are only these eight, but this is more difficult to show and we won’t do it here. 5. Complex numbers: roots and logarithms The matrix A in Example 1.2 has complex eigenvalues i and –i. If you want to get square roots of A, you will need to know what are i . See the Notes on Complex Numbers on this web page. i and After this hurdle, you proceed exactly as before and get the four square roots of A as i A V * 0 with i e i / 4 * inv (V ) i 0 i e i / 4 , Similarly, if you want to obtain log(A) 0 log( i ) log( A) V * * inv (V ) log( i ) 0 with log( i ) i 2 i 2k , log( i ) i 6 2 i 2q , k 0, 1, 2,.... and q 0, 1, 2,.... can be chosen independently of where each other. We have written only four square roots of A but infinitely many logarithms of A!! 7