Download presentation
Presentation is loading. Please wait.
Published byTrevion Brougham Modified over 9 years ago
1
Scientific Computing QR Factorization Part 2 – Algorithm to Find Eigenvalues
2
Similar Matrices Definition: A and B are similar matrices if and only if there exists a nonsingular matrix P such that B = P -1 AP. (or PBP -1 =A) Theorem: Similar matrices have the same set of eigenvalues. Proof: Since Ap = p PBP -1 p = p P -1 (PBP -1 p) = P -1 ( p) B(P -1 p) = (P -1 p). Then, is an eigenvalue of A (with eigenvector p) is an eigenvalue of B (with eigenvector P -1 p). QED
3
QR Algorithm Given square matrix A we can factor A = QR where Q is orthogonal and R is upper triangular. Algorithm to find eigenvalues: Start: A 0 = A= QR (note: R = Q t A) A 1 = RQ = Q t A Q (A and A 1 are similar) Factor: A 1 =Q 1 R 1 A 2 =R 1 Q 1 = Q 1 t Q t A Q Q 1 (similar to A 1 ) General: Given A m Factor: A m =Q m R m A m+1 =R m Q m (similar to A m, …, A 1, A)
4
QR Algorithm Note: If the eigenvalues of A satisfy | 1 |> | 2 |> … >| n | Then, the iterates A m converge to an upper triangular matrix having the eigenvalues of A on the diagonal. (Proof omitted)
5
QR Algorithm Example Example: Use the slow_qr algorithm to find the iterates A m for
6
QR Algorithm Example >> A=[4 2/3 -4/3 4/3; 2/3 4 0 0; -4/3 0 6 2; 4/3 0 2 6]; >> [q r] = slow_qr(A); >>A1= r*q A1 = 5.6000 0.2769 -0.3819 -1.1034 0.2769 3.9148 0.1175 0.3395 -0.3819 0.1175 7.4099 -1.7047 -1.1034 0.3395 -1.7047 3.0753
7
QR Algorithm Example >> [q r] = slow_qr(A1); >> A2 = r*q A2 = 5.9512 0.0541 -0.0401 0.4338 0.0541 3.9703 0.0220 -0.2377 -0.0401 0.0220 7.9498 0.5429 0.4338 -0.2377 0.5429 2.1286
8
QR Algorithm Example >> [q r] = slow_qr(A2); >> A3 = r*q A3 = 5.9945 0.0092 -0.0035 -0.1476 0.0092 3.9922 0.0029 0.1241 -0.0035 0.0029 7.9967 -0.1399 -0.1476 0.1241 -0.1399 2.0165
9
QR Algorithm Example >> [q r] = slow_qr(A3); >> A4 = r*q A4 = 5.9994 0.0015 -0.0003 0.0494 0.0015 3.9980 0.0004 -0.0624 -0.0003 0.0004 7.9998 0.0351 0.0494 -0.0624 0.0351 2.0028
10
QR Algorithm Example >> [q r] = slow_qr(A4); >> A5 = r*q A5 = 5.9999 0.0003 -0.0000 -0.0165 0.0003 3.9995 0.0000 0.0312 -0.0000 0.0000 8.0000 -0.0088 -0.0165 0.0312 -0.0088 2.0006
11
QR Algorithm Example >> [q r] = slow_qr(A5); >> A6 = r*q A6 = 6.0000 0.0000 -0.0000 0.0055 0.0000 3.9999 0.0000 -0.0156 -0.0000 0.0000 8.0000 0.0022 0.0055 -0.0156 0.0022 2.0001 Note: Off diagonal elements are -> 0 and eigenvalues appear to be 6, 4, 8, 2 (One can show these are the exact values)
12
QR Algorithm- Eigenvectors How do we compute the eigenvectors? Note: A m = Q m-1 t … Q 1 t Q t A Q Q 1 … Q m-1 Let Q * = Q Q 1 … Q m-1 Then, A m = Q *t A Q * If A m becomes diagonal, the eigenvectors of A m are e 1, e 1, …, e n. Since A m and A are similar, the eigenvectors of A are (Q *t ) -1 e i =Q * I, that is the eigenvectors of A are the columns of Q *. Thus, if A is symmetric (A t = A) then the eigenvectors of A are the columns of Q *.
13
QR Algorithm Example Example: Find the eigenvectors for:
14
QR Algorithm Example >> A=[4 2/3 -4/3 4/3; 2/3 4 0 0; -4/3 0 6 2; 4/3 0 2 6]; >> [q r] = slow_qr(A); >> q1 = q q1 = -0.8944 0.1032 -0.1423 -0.4112 -0.1491 -0.9862 0.0237 0.0685 0.2981 -0.0917 -0.8758 -0.3684 -0.2981 0.0917 -0.4606 0.8310
15
QR Algorithm Example >> A1=r*q; >> [q r] = slow_qr(A1); >> q2 = q1*q q2 = 0.7809 -0.0770 0.0571 -0.6173 0.2082 0.9677 -0.0131 0.1415 -0.4165 0.1697 0.7543 -0.4782 0.4165 -0.1697 0.6539 0.6085
16
QR Algorithm Example >> A2 = r*q; >> [q r] = slow_qr(A2); >> q3 = q2*q q3 = -0.7328 0.0424 -0.0159 -0.6789 -0.2268 -0.9562 0.0043 0.1850 0.4536 -0.2048 -0.7187 -0.4856 -0.4536 0.2048 -0.6952 0.5187
17
QR Algorithm Example Class Discussion: Create a matlab function function [Q* Ak] = eigenQ(A,k) that will carry out this iteration and return the matrix Q* and the matrix Ak that you get by iterating the QR algorithm k times.
18
QR Algorithm Example >> [Q Am] = eigenQ(A, 15) Q = -0.7071 0.0000 -0.0000 -0.7071 -0.2357 -0.9428 0.0000 0.2357 0.4714 -0.2357 -0.7071 -0.4714 -0.4714 0.2357 -0.7071 0.4714 Ak = 6.0000 0.0000 0.0000 -0.0000 0.0000 4.0000 -0.0000 0.0000 0.0000 -0.0000 8.0000 -0.0000 -0.0000 0.0000 -0.0000 2.0000
19
QR Algorithm Example Check: >> A*Q(1:4,1)-6*Q(1:4,1) ans = 1.0e-06 * 0.1971 -0.0657 0.1314 -0.1314
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.