hw3sol - MIT 18.335, Fall 2007: Homework 3, Solutions 1....

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 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...
View Full Document

Page1 / 9

hw3sol - MIT 18.335, Fall 2007: Homework 3, Solutions 1....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online