ps4solution

# ps4solution - 13.002 Introduction to Numerical Methods for...

This preview shows pages 1–4. Sign up to view the full content.

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 13.002 Introduction to Numerical Methods for Engineers Solution to Problem Set 4 e'“ 1 .0 2:1 1 —1 e‘“ —1 2:; = e'“ 1 e‘“ ——2 :3 e'“ [-11 i :2” “[35 (f :2], ‘4 l [ 1.a=0 where Lc = b and Ux = c was used. For a —> oo 0 1 0 —1 0 —1 1 0 —-2 After swithching coulmns 1 and 2 and adding row3 to row2 1 0 0 \$2 1 0 0 —1 —1 xx = 0 :1; = 1’ O 0 —3 1:3 0 O- 2. See attach. 3. For a large the soluton becomes ill-conditioned as can be seen from the results attached. 4. Partial pivoting reduced that problem. 5.F‘rom the original set of the equations by interchanging colums 1 and 2 1 6—“ 0 1:2 - l 6—“ —1 —1 21 = 6-“ . e'“ 1 —2 2:3 8"“ This particular rearrangement yields a stable solution due to the connection to the physical background of the problem. See attach. % Gaussian elimination clear % Examples %[a]=[2 1 0 0; ['b]=[2;l;4;8]=[1 -1 o; —i 2 —1; o —i 2] ,%L01=[1:0;0; %[a]=[0 1 0; -1 O -1; l 0 —2] *[b}=[1;0;0; 1 2 l 0; 0 1 2 1; 0 0 1 2] n=3; %alpha is p‘ [exp(—p) 1 0;-1 exp(-p) —1;1 exp(—p) —2] [1;exp(-p);eXP(-p)l %partial pivoting 1&2 row for j=l:n dum=a(2,j); 8(2.j)=a(1,j); a(1,j)=dum; end dum=b(2); b(2)=b(l); b(1)=dum; a b h . . . elimination c k=1:n for i=k+1:n m(i,k)=a(i,k)/a(k.k); for j=k:n a(i.j)=a(i.j)— m(i,k)*a(k,j); end ‘ ‘ b(i)=b(i)— m(i.k)*b(k); end end a b % Back substitution x(n)=b(n)/a(n,n): for i=n—1:-l:l sum=b(i) ; for k=i+1=n sum=sum—a(i,k)*x(k); end xti)=sum/a(i,i): _snd r ki)=sum/a(i,i) >> hwk4_3 %alpha is p p = O a = l l O -1 1 -1 l 1 -2 b = l 1 l l l O O 2 -1 O 0 -2 0 l 0 >> hwké_3 p = 5 a = 0.0067 1.0000 0 148.4l99 O O b = 1.0000 148.4199 0 -l.0000 -2.9999 >> hwk4_4 %alpha is p p = 0 a = l l 0 -1 l -1 l l -2 b = l l 1 % patial pivoting rows 1&2 a = -l l -l l l O l l -2 b = l l l % eliminacon a = -l l -1. 0 2 -1 O O —2 b : l 2 O % Back substitution x = O l 0 >> hwk4_4 ...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern