Lecture 35 - Composite Trapezoidal Rule 0 2 x sin( 2 x )dx...

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

View Full Document Right Arrow Icon
Composite Trapezoidal Rule function f = example1(x) % a = 0, b = pi f=x.^2.*sin(2*x); dx x 2 sin x 0 2 ) ( π
Background image of page 1

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

View Full DocumentRight Arrow Icon
» a=0; b=pi; dx=(b-a)/100; » x=a:dx:b; y=example1(x); » I=trap( 'example1' ,a,b,1) I = -3.7970e-015 » I=trap( 'example1' ,a,b,2) I = -1.4239e-015 » I=trap( 'example1' ,a,b,4) I = -3.8758 » I=trap( 'example1' ,a,b,8) I = -4.6785 » I=trap( 'example1' ,a,b,16) I = -4.8712 » I=trap( 'example1' ,a,b,32) I = -4.9189 Composite Trapezoidal Rule » I=trap( 'example1' ,a,b,64) I = -4.9308 » I=trap( 'example1' ,a,b,128) I = -4.9338 » I=trap( 'example1' ,a,b,256) I = -4.9346 » I=trap( 'example1' ,a,b,512) I = -4.9347 » I=trap( 'example1' ,a,b,1024) I = -4.9348 » Q=quad8( 'example1' ,a,b) Q = -4.9348 MATLAB function
Background image of page 2
n = 2 I = -1.4239 e-15 Exact = -4. 9348 dx x 2 sin x 0 2 ) ( π
Background image of page 3

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

View Full DocumentRight Arrow Icon
n = 4 I = -3.8758 Exact = -4. 9348 dx x 2 sin x 0 2 ) ( π
Background image of page 4
n = 8 I = -4.6785 Exact = -4. 9348 dx x 2 sin x 0 2 ) ( π
Background image of page 5

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

View Full DocumentRight Arrow Icon
n = 16 I = -4.8712 Exact = -4. 9348 dx x 2 sin x 0 2 ) ( π
Background image of page 6
Simpson’s 1/3-Rule Approximate the function by a parabola [ ] ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( 2 1 0 2 2 1 1 0 0 i 2 0 i i b a x f x f 4 x f 3 h x f c x f c x f c x f c dx x f + + = + + = = x 0 x 1 x f ( x ) x 2 h h L ( x )
Background image of page 7

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

View Full DocumentRight Arrow Icon
Simpson’s 1/3-Rule 0 2 1 1 0 1 2 a b , , 2 d , , d 2 h 1 0 1 let x a x b x x x b a x h h x x x x x x ξ + = = = - - = = = = = - = = = = 2 0 1 2 ( 1) ( 1) ( ) ( ) (1 ) ( ) ( ) 2 2 L f x f x f x ξ ξ - + = + - + 2nd order Lagrangian polynomial interpolation for y = f ( x ): 0 2 0 1 1 2 2 0 1 2 0 1 0 2 1 0 1 2 2 0 2 1 ( )( ) ( )( ) ( )( ) ( ) ( ) ( ) ( ) ( )( ) ( )( ) ( )( ) x x x x x x x x x x x x P x f x f x f x x x x x x x x x x x x x - - - - - - = + + - - - - - - -1 1 0 x x 0 =a x 1 =(a+b)/2 x 2 =b h
Background image of page 8
Simpson’s 1/3-Rule 2 0 1 2 ( 1) ( 1) ( ) ( ) (1 ) ( ) ( ) 2 2 L f x f x f x ξ ξ ξ - + = + - + 1 1 2 3 2 1 1 3 1 1 1 2 3 0 1 1 2 1 0 2 1 1 1 0 1 1 b a 2 ξ 3 ξ 2 h x f 3 ξ ξ h x f 2 ξ 3 ξ 2 h x f 1 ξ ξ 2 h x f ξ 1 ( h x f 1 ξ ξ 2 h x f L h dx x f - - - - - - + + - + - = + + - + - = ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ) ( ) ( ) ( ) ( ) ( [ ] ) ( ) ( ) ( ) ( 2 1 0 b a x f x f 4 x f 3 h dx x f + + = 2nd order polynomial for y = f ( x ) E T = - h 5 f (4) ( ξ ) 1 90
Background image of page 9

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

View Full DocumentRight Arrow Icon
Simpson’s 3/8-Rule Approximate by a cubic polynomial [ ] ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( 3 2 1 0 3 3 2 2 1 1 0 0 i 3 0 i i b a x f x f 3 x f 3 x f 8 h 3 x f c x f c x f c x f c x f c dx x f + + + = + + + =
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

Lecture 35 - Composite Trapezoidal Rule 0 2 x sin( 2 x )dx...

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

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