Docsity

Homework 5 Solutions for Numerical Analysis | MATH 128A, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
1
Math128B
Feb. 19, 2005
Jonathan Dorfman
Homework 5 Solutions
file function
Hmwk5Main.m cooks up random matrix A, symmetrizes it to B, and also predefined 3x3 symmetric C
calls Householder on Bto reduce to symmetric tridiagonal
calls Householder on Ato reduce to Upper Hessenberg
call QRShift on Cto reduce to diagonal (tol = 10โˆ’5)
Householder.m implements Householder Method according to p.630 of Mathews & Fink
(Program 11.4 with slight modification using recursion)
QRShift.m implements QR algorithm with Shifts according to p.636 of Mathews & Fink
(Program 11.5 with slight modification using recursion)
A diary of the output follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hmwk5Main
%%%%%%%%%%%%Householder: Symmetric to (similar) Tridiagonal%%%%%%%%%%%%
random 5x5 symmetric matrix is:
B =
1.8850 1.2741 0.9089 1.3232 0.9983
1.2741 1.2582 0.9233 1.2368 1.1131
0.9089 0.9233 0.4376 0.3865 0.6835
1.3232 1.2368 0.3865 0.4496 1.5624
0.9983 1.1131 0.6835 1.5624 0.6269
reduction to (symmetric) tridiagonal form is:
X =
1.8850 -2.2797 0.0000 0 0.0000
-2.2797 3.7048 -0.6686 0.0000 -0.0000
0.0000 -0.6686 -0.9055 -0.3082 -0.0000
0 0.0000 -0.3082 0.0317 -0.2156
0.0000 -0.0000 -0.0000 -0.2156 -0.0589
comparison with Matlabs Hess(B):
ans =
0.2227 0.1349 0 0 0
0.1349 -0.0479 -0.3699 0 0
0 -0.3699 0.0702 1.4659 0
0 0 1.4659 3.7853 -2.2680
0 0 0 -2.2680 0.6269
pf2

Partial preview of the text

Download Homework 5 Solutions for Numerical Analysis | MATH 128A and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Math128B

Feb. 19, 2005 Jonathan Dorfman Homework 5 Solutions

file function Hmwk5Main.m cooks up random matrix A, symmetrizes it to B, and also predefined 3x3 symmetric C calls Householder on B to reduce to symmetric tridiagonal calls Householder on A to reduce to Upper Hessenberg call QRShift on C to reduce to diagonal (tol = 10โˆ’^5 ) Householder.m implements Householder Method according to p.630 of Mathews & Fink (Program 11.4 with slight modification using recursion) QRShift.m implements QR algorithm with Shifts according to p.636 of Mathews & Fink (Program 11.5 with slight modification using recursion)

A diary of the output follows:

Hmwk5Main %%%%%%%%%%%%Householder: Symmetric to (similar) Tridiagonal%%%%%%%%%%%% random 5x5 symmetric matrix is:

B = 1.8850 1.2741 0.9089 1.3232 0. 1.2741 1.2582 0.9233 1.2368 1. 0.9089 0.9233 0.4376 0.3865 0. 1.3232 1.2368 0.3865 0.4496 1. 0.9983 1.1131 0.6835 1.5624 0.

reduction to (symmetric) tridiagonal form is:

X = 1.8850 -2.2797 0.0000 0 0. -2.2797 3.7048 -0.6686 0.0000 -0. 0.0000 -0.6686 -0.9055 -0.3082 -0. 0 0.0000 -0.3082 0.0317 -0. 0.0000 -0.0000 -0.0000 -0.2156 -0.

comparison with Matlabs Hess(B):

ans = 0.2227 0.1349 0 0 0 0.1349 -0.0479 -0.3699 0 0 0 -0.3699 0.0702 1.4659 0 0 0 1.4659 3.7853 -2. 0 0 0 -2.2680 0.

%%%%%%%%%%%%Householder: Arbitrary to (similar) Upper Hessenberg%%%%%%%%%%%% random 5x5 matrix is:

A = 0.9425 0.5039 0.1715 0.4570 0. 0.7701 0.6291 0.1307 0.7881 0. 0.7374 0.7926 0.2188 0.2811 0. 0.8663 0.4486 0.1055 0.2248 0. 0.9909 0.5244 0.1414 0.9089 0.

reduction to Upper Hessenberg form is:

X = 0.9425 -0.5417 -0.1415 0.0894 -0. -1.6939 1.8315 -0.0111 0.3537 0. 0 0.3629 0.0611 -0.1052 0. 0.0000 -0.0000 0.3602 -0.1529 -0. -0.0000 0.0000 0.0000 -0.1518 -0.

comparison with Matlabs Hess(A):

ans = 0.9425 -0.5417 -0.1730 0.0245 -0. -1.6939 1.8315 -0.0111 -0.5080 0. 0 0.3629 0.0611 -0.1052 0. 0 0 0.3602 -0.1529 -0. 0 0 0 -0.1518 -0.

%%%%%%%%%%%%QR (with shifts): Symmetric to (similar) Diagonal%%%%%%%%%%%% specified symmetric 3x3 matrix is:

C = 2 -1 0 -1 -1 - 0 -2 3

eiqenvalues resulting from reduction to diagonal form using tol=.00001 is: -2.041 2.1295 3. comparison with Matlabs eig(A): -2.041 2.1295 3.