P17_2 - f test1 = test1 f(i t end e comptrapn4 =(b-a(f(a 2*test1 f(b(2*n c mid =(a b/2 m simp =(b-a(f(a 4*f(mid f(b/6 s compsimp =(b-a(f(a 4(f(a h

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
%Problem 17.2 % function P17_2 f a = 0; b = 4; b analytic = 4 + exp(-8)/2 - (0 + exp(0)/2) a trap = (b-a)*(f(a) + f(b))/2 t n = 2; n test1 = 0; t h = (b-a)/n; h for i = a+h:h:b-h f test1 = test1 + f(i); t end e comptrapn2 = (b-a)*(f(a) + 2*test1 + f(b))/(2*n) c %Etcomptrapn2 = -(((b-a)^3)/(12*n^3))* % n = 4; n test1 = 0; t h = (b-a)/n; h for i = a+h:h:b-h
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: f test1 = test1 + f(i); t end e comptrapn4 = (b-a)*(f(a) + 2*test1 + f(b))/(2*n) c mid = (a+b)/2; m simp = (b-a)*(f(a) + 4*f(mid) + f(b))/6 s compsimp = (b-a)*(f(a) + 4*(f(a+h) + f(a+3*h)) + 2*f(a+2*h) + f(b))/(3*n) c function new = f(x) f new = 1 - exp(-2*x); n...
View Full Document

This note was uploaded on 09/21/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online