Piecewise Quadratic approximations h x 3 x 1 x n 1 Composite Simpsons 13 Rule

Piecewise quadratic approximations h x 3 x 1 x n 1

This preview shows page 16 - 27 out of 31 pages.

Piecewise Quadratic approximations h x 3 x 1 x n-1
Image of page 16
Composite Simpson’s 1/3 Rule Applicable only if the number of segments is even
Image of page 17
Composite Simpson’s 1/3 Rule Applicable only if the number of segments is even Substitute Simpson’s 1/3 rule for each integral For uniform spacing (equal segments) - + + + = n 2 n 4 2 2 0 x x x x x x dx x f dx x f dx x f I ) ( ) ( ) ( 6 x f x f 4 x f h 2 6 x f x f 4 x f h 2 6 x f x f 4 x f h 2 I n 1 n 2 n 4 3 2 2 1 0 ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( + + + + + + + + + = - - + + + - = - = - = 1 n 5 3 1 i 2 n 6 4 2 j n j i 0 x f x f 2 x f 4 x f n 3 a b I , , , , ) ( ) ( ) ( ) ( ) (
Image of page 18
Simpson’s 1/3 Rule Truncation error (single application) Exact up to cubic polynomial ( f ( 4 ) = 0) Approximate error for multiple applications 2 a b h ; f 2880 a b f h 90 1 E 4 5 4 5 t - = - - = - = ) ( ) ( ) ( ) ( ) ( ξ ξ f n 180 a b E 4 4 3 a ) ( ) ( - - =
Image of page 19
Composite Simpson’s 1/3 Rule Evaluate the integral n = 2, h = 2 n = 4, h = 1 dx xe I 4 0 x 2 = [ ] [ ] % . . ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( 70 8 975 5670 e 4 e 3 4 e 2 2 e 4 0 3 1 4 f 3 f 4 2 f 2 1 f 4 0 f 3 h I 8 6 4 2 - = = + + + + = + + + + = ε [ ] [ ] % . . ) ( ) ( ) ( ) ( 96 57 411 8240 e 4 e 2 4 0 3 2 4 f 2 f 4 0 f 3 h I 8 4 - = = + + = + + = ε
Image of page 20
function I = Simp(f, a, b, n) % integral of f using composite Simpson rule % n must be even h = (b - a)/n; S = feval(f,a); for i = 1 : 2 : n-1 x(i) = a + h*i; S = S + 4*feval(f, x(i)); end for i = 2 : 2 : n-2 x(i) = a + h*i; S = S + 2*feval(f, x(i)); end S = S + feval(f, b); I = h*S/3; Composite Simpson’s 1/3 Rule
Image of page 21
Simpson’s 1/3 Rule
Image of page 22
Composite Simpson’s 1/3 Rule
Image of page 23
» x=0:0.04:4; y=example(x); » x1=0:2:4; y1=example(x1); » c=Lagrange_coef(x1,y1); p1=Lagrange_eval(x,x1,c); » H=plot(x,y,x1,y1, 'r*' ,x,p1, 'r' ); » xlabel('x'); ylabel('y'); title('f(x) = x*exp(2x)'); » set(H,'LineWidth',3,'MarkerSize',12); » x2=0:1:4; y2=example(x2); » c=Lagrange_coef(x2,y2); p2=Lagrange_eval(x,x2,c); » H=plot(x,y,x2,y2, 'r*' ,x,p2, 'r' ); » xlabel( 'x' ); ylabel( 'y' ); title( 'f(x) = x*exp(2x)' ); » set(H, 'LineWidth' ,3, 'MarkerSize' ,12); » » I=Simp( 'example' ,0,4,2) I = 8.2404e+003 » I=Simp( 'example' ,0,4,4) I = 5.6710e+003 » I=Simp( 'example' ,0,4,8) I = 5.2568e+003 » I=Simp( 'example' ,0,4,16) I = 5.2197e+003 » Q=Quad8( 'example' ,0,4) Q = 5.2169e+003 n = 2 n = 4 n = 8 n = 16 MATLAB fun
Image of page 24
Multiple applications of Simpson’s rule with odd number of intervals Hybrid Simpson’s 1/3 & 3/8 rules
Image of page 25
Newton-Cotes Closed Integration Formulae ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ' ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ξ ξ ξ ξ ξ 6 7 5 4 3 2 1 0 6 7 4 3 2 1 0 4 5 3 2
Image of page 26
Image of page 27

You've reached the end of your free preview.

Want to read all 31 pages?

  • Spring '09
  • RAPHAELHAFTKA
  • dx, Romberg's method, Composite Simpson

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes