{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw3sol - MIT 18.335 Fall 2007 Homework 3 Solutions...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
MIT 18.335, Fall 2007: Homework 3, Solutions 1. (Trefethen/Bau 11.3) The following lines of code creates the matrices, computes the six different least squares approximations, and shows the result in a way that makes it easy to compare each of the coefficients. m=50; n=12; t=linspace(0,1,m)’; A=vander(t); A=fliplr(A(:,m-n+1:m)); b=cos(4*t); xa=(A’*A)\(A’*b); [Q,R]=mgs(A); xb=R\(Q’*b); [W,R]=house(A); Q=formQ(W); xc=R\(Q(:,1:n)’*b); [Q,R]=qr(A,0); xd=R\(Q’*b); xe=A\b; [U,S,V]=svd(A,0); xf=V*(S\(U’*b)); format long coeffs=[xa xb xc xd xe xf]’ format short The printout is Columns 1 through 4 1.00000000261118 -0.00000097548021 -7.99995921914247 -0.00065762300158 0.99999999859093 0.00000027088201 -8.00000704985626 0.00005898516353 1.00000000099660 -0.00000042274292 -7.99998123568615 -0.00031876324278 1.00000000099661 -0.00000042274316 -7.99998123568337 -0.00031876324997 1.00000000099661 -0.00000042274332 -7.99998123567749 -0.00031876333094 1.00000000099661 -0.00000042274317 -7.99998123568300 -0.00031876325403 Columns 5 through 8 10.67211753087116 -0.02630342671309 -5.61079800311668 -0.14317854424735 10.66655515934153 -0.00090455925668 -5.68354616965529 -0.00876156857361 10.66943079603079 -0.01382028866396 -5.64707562539748 -0.07531602783445 10.66943079596514 -0.01382028807910 -5.64707562752298 -0.07531602343290 10.66943079654419 -0.01382029054076 -5.64707562089245 -0.07531603505147 10.66943079598727 -0.01382028814670 -5.64707562740522 -0.07531602353876 Columns 9 through 12 1.77528406414325 -0.05507362221192 -0.34838900741980 0.08331520196694 1.61521325639978 0.06358015838896 -0.39818374763656 0.09235164808582 1.69360696748984 0.00603210593626 -0.37424170232631 0.08804057587879 1.69360696192797 0.00603211018556 -0.37424170413275 0.08804057620718 1.69360697513982 0.00603210078168 -0.37424170032592 0.08804057553828 1.69360696194714 0.00603211023566 -0.37424170417595 0.08804057621838 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The wrong digits are marked with underlines. The normal equations are very inaccurate, the coefficient with the largest relative error is more than a magnitude too large, indicating that the normal equations exhibit instability. The condition number of A * A is 1 . 39 · 10 16 , and it is indeed hard to get good accuracy with 16 digits precision. The solution with the modified Gram-Schmidt algorithm is also very bad. The other four methods produce results with essentially the same accuracy, although the solutions differ in several of the last digits since the problem is ill-conditioned. 2. (Trefethen/Bau 12.1) We have that bardbl A bardbl 2 = σ 1 = 100 where σ 1 is the largest singular value of A , and bardbl A bardbl F = radicalbig tr( A * A ) = radicaltp radicalvertex radicalvertex radicalbt 202 summationdisplay i =1 λ i ( A * A ) = radicaltp radicalvertex radicalvertex radicalbt 202 summationdisplay i =1 σ i ( A ) 2 = 101 where λ i ( A * A ) is the i :th eigenvalue of A * A and σ i ( A ) is the i :th singular value of A . This gives radicaltp radicalvertex radicalvertex radicalbt 100 2 + 202 summationdisplay i =2 σ i ( A ) 2 = 101 202 summationdisplay i =2 σ i ( A ) 2 = 101 2 - 100 2 = 201 A lower bound on κ ( A ) is achieved when the smallest singular value σ 202 ( A ) is as large as possible. This is obviously the case when all singular values except the first are equal, and the last equation then gives that σ 202 ( A ) = 1, and finally that κ ( A ) = σ 1 σ 202 100 1 = 100 The matrix diag(100 , 1 , 1 , . . . , 1) is an example which gives equality. 3. (Trefethen/Bau 13.1) IEEE single and double precision have base β = 2 and precision t = 24 and t = 53, respec- tively. Therefore, there are 2 53 - 24 - 1 = 536870911 double precision numbers between an adjacent pair of nonzero single precision numbers (not including the numbers themselves). 4. (Trefethen/Bau 13.2a) It is obvious from the definition of F that the number β t - 1 belongs to F . This is also true for the number β t , since it is an exact power of the base. However, the number β t + 1 does not belong to F . To represent it, t + 1 digits are needed, where both the most significant and the least significant bits are nonzero. Therefore, the number will be truncated.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}