KeytoMatlabExercise4SchoolofMathematicalSciencesXiamenUniversityhttp:/gdjpkc.xmu.edr Key to MATLAB Exercise 4-Eigenvalue >>A=[323-2l,[vdj=eig(A) 0.8944-0.3162 0.44720.9487 0 >> det(v) ans 0.9899 The eigenvalues of A are 4 and-3, and the corresponding eigenspaces are V4=(a(0.8944,0.4472), for any a in R) and V-3=a(-0.3162, 0.9487) for any a in) A isn 't defective, i. e. A is diagonalizable because the determinant of v is not zero The keys to 2)to 9)are omitted >>A=[200.040,102]B=[200.040-362] > eig(A) ans 2 >> eig(B) 2 2 Notice As 2 are multiple eigenvalues, we can't judge whether A is similar to B only by their eigenvalues. That is, we may say A is similar to b if a and b have the same Jordan normal forms >>XA, JordanA=jordan(A) XA= 0 0 0 0 JordanA= >>XB, JordanB =jordan(B XB= Key to Ex4-1
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex41 Key to MATLAB Exercise 4 – Eigenvalue 1. 1) >> A=[3 2;3 2]; [v,d]=eig(A) v = 0.8944 0.3162 0.4472 0.9487 d = 4 0 0 3 >> det(v) ans = 0.9899 The eigenvalues of A are 4 and 3, and the corresponding eigenspaces are V4={a (0.8944,0.4472)’| for any a in R} and V3= {a (0.3162, 0.9487)’| for any a in R}. A isn't defective, i.e. A is diagonalizable, because the determinant of v is not zero. The keys to 2) to 9) are omitted. 2. >> A=[2 0 0;0 4 0;1 0 2]; B=[2 0 0;0 4 0;3 6 2]; >> eig(A) ans = 2 2 4 >> eig(B) ans = 2 2 4 Notice As 2 are multiple eigenvalues, we can’t judge whether A is similar to B only by their eigenvalues. That is, we may say A is similar to B if A and B have the same Jordan normal forms. >> [XA, JordanA] = jordan(A) XA = 0 0 1 1 0 0 0 1 0 JordanA = 4 0 0 0 2 1 0 0 2 >> [XB, JordanB] = jordan(B) XB = 0 0 2
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed 00 Jordan 400 A is similar to B because JordanA is equal to JordanB >>VA, DA=eig(A) 00.0000 0 0 0000-1.0000 0 DA= 200 0 020 >>VB, DBFeig(B) VB 00.0000 0 00.3162 1.00001.0000 200 020 >> rank( VA)rank(VB) C, 2, 4 are the eigenvalues of A and B, and the rank of va equals that of VB, which means that a has the same jordan normal form as b. therefore a is similar to b >> A=rand(4 4) P.poly(A) 1.0000-1.54300.0898-0.03100.1878 It means that the characteristic polynomial is x-1.543x+0.0898x-003 1x+0.1878 14313 -0.2427+0.40lll -0.2427-040llil The eigenvalues (or characteristic roots ) of A are 1. 4313, 0.5970.-02427+0.401li and Key to Ex4-2
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex42 1 0 0 3 6 3 JordanB = 4 0 0 0 2 1 0 0 2 A is similar to B because JordanA is equal to JordanB. Or >> [VA, DA]=eig(A) VA = 0 0.0000 0 0 0 1.0000 1.0000 1.0000 0 DA = 2 0 0 0 2 0 0 0 4 >> [VB, DB]=eig(B) VB = 0 0.0000 0 0 0 0.3162 1.0000 1.0000 0.9487 DB = 2 0 0 0 2 0 0 0 4 >> rank(VA)==rank(VB) ans = 1 2, 2, 4 are the eigenvalues of A and B, and the rank of VA equals that of VB, which means that A has the same Jordan normal form as B. Therefore A is similar to B. 3. >> A=rand(4); >> P=poly(A) P = 1.0000 1.5430 0.0898 0.0310 0.1878 It means that the characteristic polynomial is 4 3 2 x -1.543x + 0.0898x - 0.031x + 0.1878 >> roots(P) ans = 1.4313 0.5970 0.2427 + 0.4011i 0.2427 0.4011i The eigenvalues (or characteristic roots ) of A are 1.4313, 0.5970. 0.2427+0.4011i and
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed 0.2427-0.40ll >>A=[01;10}[X1,D=eig(A) -0.70710.7071 0.70710.7071 > rank(X1size(X1, 1) ans The answer is Xl= 0707107071//-10 -0.70710.7071 Here Xl is an invertible matrix We may check Xl by other functions such as det, rref and so on [X2, -0.70710.7071 ans 0 Therefore X2 is the answer too 0.50000.5000 0.50000.5000 0 ans Therefore X3 is also the answer The keys to 2)to 6)are omitted
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex43 0.2427 0.4011i. 4. 1) >> A=[0 1;1 0]; [X1, D]=eig(A) X1= 0.7071 0.7071 0.7071 0.7071 D = 1 0 0 1 >> rank(X1)==size(X1, 1) ans = 1 The answer is 0.7071 0.7071 1 0.7071 0.7071 X Ê - ˆ = Á ˜ Ë ¯ , 1 0 0 1 D Ê- ˆ = Á ˜ Ë ¯ . Here X1 is an invertible matrix. We may check X1 by other functions such as det, rref and so on. Or >> [X2, S]=schur(A) X2 = 0.7071 0.7071 0.7071 0.7071 S = 1 0 0 1 >> X2*S*inv(X2) ans = 0 1.0000 1.0000 0 Therefore X2 is the answer, too. Or >> [X3,J]=jordan(A) X3 = 0.5000 0.5000 0.5000 0.5000 J = 1 0 0 1 >> X3*J*inv(X3) ans = 0 1 1 0 Therefore X3 is also the answer. The keys to 2) to 6) are omitted
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed >>A=2 1; -2 1: v, d=eig(A): B=v'sqrt(d)*inv(v) 1.51190.3780 -0.75591.1339 B= 2.000010000 2.000 1.0000 The key to 2)is omitted 6 > format rational; A=01-1; 120: -103: >> U, T=schur(A) 1661/6691-1573/4601 1573/4601 755/833-1661/6691 1661/66911573/4601 755/833 T 655/1006 0 00 665/1172 0 2874/851 >>A=[ll:2310; >>u,S, v]=svd(A) -0.35830.2312-0.9045 -0.9208-0.24740.3015 -0.15410.94090.3015 3.9090 00.8485 0.60220.7983 -0.7983-0.6022 > Singular ValuesOfA=diag(s) 3.9090 0.8485 > RootofAA-roots(poly(A*A)) Rootofaa= 15.2801 0.7199 Key to Ex4-4
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex44 5. 1) >> A=[2 1;2 1];[v, d]=eig(A);B= v*sqrt(d)* inv(v) B = 1.5119 0.3780 0.7559 1.1339 >> B*B ans = 2.0000 1.0000 2.0000 1.0000 The key to 2) is omitted. 6. >> format rational; A=[0 1 1;1 2 0;1 0 3]; >> [U, T]=schur(A) U = 755/833 1661/6691 1573/4601 1573/4601 755/833 1661/6691 1661/6691 1573/4601 755/833 T = 655/1006 0 0 0 2665/1172 0 0 0 2874/851 7. >> A=[1 1;2 3;1 0]; >> [u, s, v]=svd(A) u = 0.3583 0.2312 0.9045 0.9208 0.2474 0.3015 0.1541 0.9409 0.3015 s = 3.9090 0 0 0.8485 0 0 v = 0.6022 0.7983 0.7983 0.6022 >> SingularValuesOfA = diag(s) SingularValuesOfA = 3.9090 0.8485 >> RootOfAA=roots(poly(A’*A)) RootOfAA = 15.2801 0.7199
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed >> abs( Singular ValuesOfA. 2-RootOfAA)>A=[4 3 12; -17-110: 1 12 3 Poly=poly(A); roots( PolyA) 16.8781 2.4391+10.695li 2.4391-10.6951i eig(A) ans 2.4391+10.695li 2.4391-10.6951i ans -16.87812.1204-124708 0243917.7919 14679924391 ans 218740 14.6390 6.3427 >>svd(A)2 478.4705 40.2293 40.2293 214.3003 478.4705 The above show that we may use functions eig and roots to calculate the eigenvalues of a matrix. The result of function schur is in real that is. it will not show the eigenvalues of A if there are complex eigenvalues. And svd provides the values which are the square roots of th eigenvalues ofA'A >>Alrand(4): bl=A1+Al generate a symmetric matrix B Key to Ex4-5
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex45 >> abs(SingularValuesOfA.^2RootOfAA) > A=[4 3 12; 17 11 0; 1 12 3]; PolyA=poly(A); roots(PolyA) ans = 16.8781 2.4391 +10.6951i 2.4391 10.6951i >> eig(A) ans = 16.8781 2.4391 +10.6951i 2.4391 10.6951i >> schur(A) ans = 16.8781 2.1204 12.4708 0 2.4391 7.7919 0 14.6799 2.4391 >> svd(A) ans = 21.8740 14.6390 6.3427 >> svd(A)^2 ans = 478.4705 214.3003 40.2293 >> eig(A'*A) ans = 40.2293 214.3003 478.4705 The above show that we may use functions eig and roots to calculate the eigenvalues of a matrix. The result of function schur is in real, that is, it will not show the eigenvalues of A if there are complex eigenvalues. And svd provides the values which are the square roots of the eigenvalues of A’A. 9. >> A1=rand(4); B1=A1+A1'; % generate a symmetric matrix B1
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen Univer http:/edjpkc.xmu.ed > A2=10*rand(4): B2-A2*A2, generate a symmetric matrix B2 We omitted the following for it is similar to that of exlo > P=fix(10*rand(3)); >>Dl=diag(0,1,2]),D2=diag(1:3); JordanI=100,021;002] > Singular Matrix*DI for Dl is a singular matrix > NotSingularMatrix=P*D2 >>Diagonal Matrix P any symmetric matrix is diagonal >>Qr=qr(P); >>NotDiagonalMatrixQ"*Jordani*Q 11. Omitted Key to Ex4-6
Key to MATLAB Exercise 4 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Key to Ex46 >> A2=10*rand(4); B2=A2*A2'; % generate a symmetric matrix B2 We omitted the following for it is similar to that of Ex10. 10. >> P=fix(10*rand(3)); >> D1=diag([0, 1, 2]); D2=diag(1:3); Jordan1=[1 0 0; 0 2 1; 0 0 2]; >> SingularMatrix=P*D1; % for D1 is a singular matrix >> NotSingularMatrix=P*D2; >> DiagonalMatrix=P’ *P; % any symmetric matrix is diagonal. >> [Q r]=qr(P); >> NotDiagonalMatrix=Q’*Jordan1*Q; 11. Omitted