1 / 19

Scientific Computing

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 )

hans
Télécharger la présentation

Scientific Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Scientific Computing QR Factorization Part 2 – Algorithm to Find Eigenvalues

  2. Similar Matrices Definition: A and B are similar matricesif and only if there exists a nonsingular matrix P such that B = P-1AP. (or PBP-1 =A) Theorem: Similar matrices have the same set of eigenvalues. Proof: Since Ap = pPBP-1p = p P-1(PBP-1p) = P-1(p)B(P-1p) = (P-1p). Then,  is an eigenvalue of A (with eigenvector p)   is an eigenvalue of B (with eigenvector P-1p). 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: A0 = A= QR (note: R = Qt A) A1 = RQ = Qt A Q (A and A1 are similar) Factor: A1 =Q1 R1 A2 =R1 Q1 = Q1t Qt A Q Q1 (similar to A1) General: Given Am Factor: Am =Qm Rm Am+1 =Rm Qm (similar to Am , …, A1, A)

  4. QR Algorithm Note: If the eigenvalues of A satisfy |1|> |2|> … >|n| Then, the iterates Am 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 Am 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: Am = Qm-1t … Q1t Qt A Q Q1 … Qm-1 Let Q* = Q Q1 … Qm-1 Then, Am = Q*t A Q* If Am becomes diagonal, the eigenvectors of Am are e1, e1, …, en. Since Am and A are similar, the eigenvectors of A are (Q*t )-1 ei =Q*I, that is the eigenvectors of A are the columns of Q*. Thus, if A is symmetric (At = 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

More Related