{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw17_solutions

# hw17_solutions - Section 4.10 1 4 Section5.2 6a section 5.2...

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

Section 4.10 1

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

View Full Document
4
Section5.2 6a The slope is roughly 4, which matches the fact that the corrected trapezoid rule is O(h^4) accurate. Matlab code is as below a = 0; b = 2; h = (b-a)*(1/2).^(1:11); n = (b-a)./h; I = 2 - 10*exp(-2); % actual integration value Err = zeros(1,11); for k = 1:11 x = a:h(k):b; fx = x.^2.*exp(-x); % f(x) Tn = 0.5*h(k)*(sum(fx)+sum(fx(2:end-1))); % trapezoid Tnc = Tn - h(k)/24*(3*fx(end)-4*fx(end-1)+fx(end-2)+3*fx(1)-4*fx(2)+fx(3)); % improved trapezoid Err(k) = abs(I - Tnc); % error end figure(1) plot(log10(n),log10(Err)); grid on xlabel( 'log10(n)' ) ylabel( 'log10(Error)' ) title( 'section 5.2 prob 6a' ) 0 0.5 1 1.5 2 2.5 3 3.5 -14 -12 -10 -8 -6 -4 -2 0 log10(n) log10(Error) section 5.2 prob 6a

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

View Full Document
6d The slope is also roughly 4, which matches the fact that the corrected trapezoid rule is O(h^4) accurate. Matlab code is as below a = 0; b = pi; h = (b-a)*(1/2).^(1:11); n = (b-a)./h; I = 4/17*(1-exp(-pi)); % actual integration value Err = zeros(1,11); for k = 1:11 x = a:h(k):b; fx = exp(-x).*sin(4*x); % f(x) Tn = 0.5*h(k)*(sum(fx)+sum(fx(2:end-1))); % trapezoid Tnc = Tn - h(k)/24*(3*fx(end)-4*fx(end-1)+fx(end-2)+3*fx(1)-4*fx(2)+fx(3)); % improved trapezoid Err(k) = abs(I - Tnc); % error end figure(2) plot(log10(n),log10(Err));
This is the end of the preview. Sign up to access the rest of the 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