Scientific Computing QR Factorization Part 2 – Algorithm to Find Eigenvalues
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
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)
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)
QR Algorithm Example Example: Use the slow_qr algorithm to find the iterates A m for
QR Algorithm Example >> A=[4 2/3 -4/3 4/3; 2/ ; -4/ ; 4/ ]; >> [q r] = slow_qr(A); >>A1= r*q A1 =
QR Algorithm Example >> [q r] = slow_qr(A1); >> A2 = r*q A2 =
QR Algorithm Example >> [q r] = slow_qr(A2); >> A3 = r*q A3 =
QR Algorithm Example >> [q r] = slow_qr(A3); >> A4 = r*q A4 =
QR Algorithm Example >> [q r] = slow_qr(A4); >> A5 = r*q A5 =
QR Algorithm Example >> [q r] = slow_qr(A5); >> A6 = r*q A6 = Note: Off diagonal elements are -> 0 and eigenvalues appear to be 6, 4, 8, 2 (One can show these are the exact values)
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 *.
QR Algorithm Example Example: Find the eigenvectors for:
QR Algorithm Example >> A=[4 2/3 -4/3 4/3; 2/ ; -4/ ; 4/ ]; >> [q r] = slow_qr(A); >> q1 = q q1 =
QR Algorithm Example >> A1=r*q; >> [q r] = slow_qr(A1); >> q2 = q1*q q2 =
QR Algorithm Example >> A2 = r*q; >> [q r] = slow_qr(A2); >> q3 = q2*q q3 =
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.
QR Algorithm Example >> [Q Am] = eigenQ(A, 15) Q = Ak =
QR Algorithm Example Check: >> A*Q(1:4,1)-6*Q(1:4,1) ans = 1.0e-06 *