You are on page 1of 49

Simpson’s one third and

three-eight rules
Simpson’s 1/3 Rule
• If we use a 2nd order polynomial (need 3
points or 2 intervals):
– Lagrange form.
 x + x2 
 x1 = 0 
 2 

 ( x − x1 )( x − x2 )
x2 ( x − x0 )( x − x2 )
I =∫  f ( x0 ) + f ( x1 )
x0 ( x − x )( x − x ) (x1 − x0 )(x1 − x2 )
 0 1 0 2

+
( x − x0 )( x − x1 ) 
f ( x2 ) dx
(x2 − x0 )(x2 − x1 ) 

Engineering Mathematics III 2


Simpson’s 1/3 Rule
• Requiring equally-spaced intervals:

x2  ( x − x0 − h )( x − x0 − 2h ) ( x − x0 )( x − x0 − 2h )
I =∫  f ( x0 ) + f ( x1 )
x0
 −h ( −2h ) ( h )( −h )
( x − x0 )( x − x0 − h ) 
+ f ( x2 )  dx
( 2h )( h ) 

Engineering Mathematics III 3


Simpson’s 1/3 Rule
• Integrate and simplify:

h b−a
I ≈ [ f ( x0 ) + 4 f ( x1 ) + f ( x2 )] h=
12
3 2
10

Quadratic
8 Polynomial

0
3 5 7 9 11 13 15

Engineering Mathematics III 4


Simpson’s 1/3 Rule
• If we use a = x0 and b = x2, and
x1 = (b+a)/2

f ( x0 ) + 4 f ( x1 ) + f ( x2 )
I ≈ (b − a )
6
width
average height

Engineering Mathematics III 5


Simpson’s 1/3 Rule
• Error for Simpson’s 1/3 rule

Et = −
h 5 (4 )
f (ξ ) = −
(b − a ) (4 )
5
f (ξ ) 5
90 2880
O(h )

b−a
h=
2
(4 )
⇒Integrates a cubic exactly: f (ξ ) = 0

Engineering Mathematics III 6


Composite Simpson’s 1/3 Rule
• As with Trapezoidal rule, can use multiple
applications of Simpson’s 1/3 rule.
• Need even number of intervals
– An odd number of points are required.

Engineering Mathematics III 7


Composite Simpson’s 1/3 Rule
• Example: 9 points, 4 intervals
25

20

15

10

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5

-5

Engineering Mathematics III 8


Composite Simpson’s 1/3 Rule
• As in composite trapezoid, break integral up
into n/2 sub-integrals:
x2 x4 xn
I = ∫ f ( x )dx + ∫ f ( x )dx + ... + ∫ f ( x )dx
• Substitute
x 0 Simpson’sx 2 1/3 rule x for each integral
n −2

and collect terms.

n −1 n−2
f ( x0 ) + 4 ∑ f ( xi ) + 2 ∑ f (x )+ f (x )
j n
i =1,3,5 j = 2,4,6
I = (b − a )
3n
n+1 data points, an odd number
Engineering Mathematics III 9
Composite Simpson’s 1/3 Rule
• Odd coefficients receive a weight of 4, even
receive a weight of 2.
• Doesn’t seem very fair, does it?

4 1 coefficients on
1
4 1 i=n numerator
1 1
1 4
i=0

Engineering Mathematics III 10


Error Estimate
• The error can be estimated by:

nh 5 ( 4 ) (b − a )h 4 ( 4 ) 4
Ea = f = f O(h )
180
• If n is doubled, 180and Ea → Ea/16
h → h/2

f ( 4 ) is the average 4th derivative

Engineering Mathematics III 11


Example
• Integrate from a = 0 to b = 2.
2
−x
) = erule:
f ( x1/3
• Use Simpson’s

b−a a+b
h= =1 x0 = a = 0 x1 = =1 x2 = b = 2
2 2
2 1
I =∫ e − x2
dx ≈ h  f ( x0 ) + 4 f ( x1 ) + f ( x2 ) 
0 3
1
=  f ( 0 ) + 4 f (1) + f ( 2 ) 
3
1 0
= (e + 4e −1 + e −4 ) = 0.82994
3
Engineering Mathematics III 12
Example
• Error estimate:
h 5 (4 )
Et = − f (ξ )
90
• Where h = b - a and a < ξ < b
• Don’t know ξ
– use average value

5
1 ( 4) 1 5f ( 4)
( x0 ) + f ( 4)
( x1 ) + f ( 4)
( x2 ) 
Et ≈ Ea = − f =−
90 90 3

Engineering Mathematics III 13


Another Example
• Let’s look at the polynomial again:

2 3 4 5
f ( x ) = 0.2 + 25
– From a = 0 to b = 0.8x − 200 x + 675 x − 900 x + 400 x

b−a a+b
h= = 0. 4 x0 = a = 0 x1 = = 0.4 x2 = b = 0.8
2 2
2 1
I = ∫ f ( x )dx ≈ h[ f ( x0 ) + 4 f ( x1 ) + f ( x2 )]
0 3
(0.4)
= [ f (0) + 4 f (0.4) + f (0.8)]
3
= 1.36746667
Exact integral is 1.64053334
Engineering Mathematics III 14
Error

• Actual Error: (using the known exact value)


E = 1.64053334 - 1.36746667 = 0.27306666 16%

• Estimate error: (if the exact value is not


available)
h 5 (4 )
Et = − f (ξ )
90
• Where a < ξ < b.

Engineering Mathematics III 15


Error
• Compute the fourth-derivative

(4 )
f ( x ) = − 21600 + 48000 x

5 5
0 .4
E t ≈ E a = − f (4 )
(x 1 ) = − 0 . 4 f (4 )
(0 . 4 ) = 0 . 27306667
90 90

middle point
• Matches actual error pretty well.

Engineering Mathematics III 16


Example Continued
• If we use 4 segments instead of 1:
– x = [0.0 0.2 0.4 0.6 0.8] b−a
h= = 0.2
n
f ( 0 ) = 0 .2 f (0.2) = 1.288 f (0.4) = 2.456
f (0.6) = 3.464 f (0.8) = 0.232
n −1 n −2
f ( x0 ) + 4 ∑ f (x ) + 2 ∑ f (x ) + f (x )
i j n

I = (b − a ) i =1, 3,5 j =2 , 4, 6

3n
f (0) + 4 f (0.2) + 2 f (0.4) + 4 f (0.6) + f (0.8)
= (0.8 − 0)
(3)( 4)
0.2 + 4(1.288 + 3.464) + 2( 2.456) + 0.232
= 0.8
12
= 1.6234667 Exact integral is 1.64053334
Engineering Mathematics III 17
Error
• Actual Error: (using the known exact value)

E = 1.64053334 - 1.6234667 = 0.01706667 1%


• Estimate error: (if the exact value is not
available)

0.25 (4 ) 0.25 (4 )
Et ≈ Ea = − f ( x2 ) = − f (0.4) = −0.0085
90 90
middle point

Engineering Mathematics III 18


Error
• Actual is twice the estimated, why?
• Recall:

(4 )
f ( x ) = − 21600 + 48000 x

m ax
x ∈ [0 , 0 . 8 ]
{ f (4)
(x) }= f (4)
(0 ) = − 2 1 6 0 0
(4)
f ( 0 .4 ) = 2 4 0 0

Engineering Mathematics III 19


Error
• Rather than estimate, we can bound the
absolute value of the error:

0.25 ( 4) 0.25 ( 4)
Ea = − f (ξ ) ≤ f ( 0 ) = 0.0768
90 90
• Five times the actual, but provides a safer
error metric.

Engineering Mathematics III 20


Simpon’s 1/3 Rule
• Simpson’s 1/3 rule uses a 2nd order polynomial
– need 3 points or 2 intervals
– This implies we need an even number of intervals.
• What if you don’t have an even number of
intervals? Two choices:
1. Use Simpson’s 1/3 on all the segments except the last (or
first) one, and use trapezoidal rule on the one left.
– Pitfall - larger error on the segment using trapezoid
2. Use Simpson’s 3/8 rule.

Engineering Mathematics III 21


Simpson’s 3/8 Rule
• Simpson’s 3/8 rule uses a third order polynomial
– need 3 intervals (4 data points)

f ( x ) ≈ p3 ( x) = a0 + a1 x + a2 x 2 + a3 x 3

x3 x3
I = ∫ f ( x )dx ≈ ∫ p3 ( x )dx
x0 x0

Engineering Mathematics III 22


Simpson’s 3/8 Rule
• Determine a’s with Lagrange polynomial
• For evenly spaced points

3
I = h[ f ( x0 ) + 3( x1 ) + 3 f ( x2 ) + f ( x3 )]
8

b−a
h=
3

Engineering Mathematics III 23


Error
• Same order as 1/3 Rule.
– More function evaluations.
– Interval width, h, is smaller.

3 5 ( 4)
Et = − h f (ξ ) O(h 4 )
80
• Integrates a cubic exactly:

⇒ f (4 ) (ξ ) = 0

Engineering Mathematics III 24


Comparison
• Simpson’s 1/3 rule and Simpson’s 3/8 rule have the
same order of error
– O(h4)
– trapezoidal rule has an error of O(h2)
• Simpson’s 1/3 rule requires even number of
segments.
• Simpson’s 3/8 rule requires multiples of three
segments.
• Both Simpson’s methods require evenly spaced data
points

Engineering Mathematics III 25


Mixing Techniques
• n = 10 points ⇒ 9 intervals
– First 6 intervals - Simpson’s 1/3
– Last 3 intervals - Simpson’s 3/8

Simpson’s 1/3

Simpson’s 3/8

Engineering Mathematics III 26


Newton-Cotes Formulas
• We can examine even higher-order
polynomials.
– Simpson’s 1/3 - 2nd order Lagrange (3 pts)
– Simpson’s 3/8 - 3rd order Lagrange (4 pts)
• Usually do not go higher.
• Use multiple segments.
– But only where needed.

Engineering Mathematics III 27


Adaptive Simpson’s Scheme
• Recall Simpson’s 1/3 Rule:

h
I≈ [ f (x0 ) + 4 f (x1 ) + f (x2 )]
3
• Where initially, we have a=x0 and b=x2.
• Subdividing the integral into two:

h
I ≈  f ( a ) + 4 f ( x1 ) + 2 f ( x2 ) + 4 f ( x3 ) + f ( b ) 
6

Engineering Mathematics III 28


Adaptive Simpson’s Scheme
• We want to keep subdividing, until we reach a
desired error tolerance, ε.
• Mathematically:

b
h 

a
f ( x ) dx −   f ( a ) + 4 f ( x1 ) + f ( b )   ≤ ε
3 
b
h 

a
f ( x ) dx −   f ( a ) + 4 f ( x1 ) + 2 f ( x2 ) + 4 f ( x3 ) + f ( b )   ≤ ε
6 

Engineering Mathematics III 29


Adaptive Simpson’s Scheme
• This will be satisfied if:

c
h  ε

a
f ( x ) dx −   f ( a ) + 4 f ( x1 ) + f ( x2 )   ≤ , and
6  2
b
h  ε

c
f ( x ) dx −   f ( x2 ) + 4 f ( x3 ) + f ( b )   ≤ , where
6  2
a+b
c =left
• The x2 =and the right are within one-half of the error.
2

Engineering Mathematics III 30


Adaptive Simpson’s Scheme
• Okay, now we have two separate intervals to
integrate.
• What if one can be solved accurately with an
h=10-3, but the other requires many, many
more intervals, h=10-6?

Engineering Mathematics III 31


Adaptive Simpson’s Scheme
• Adaptive Simpson’s method provides a divide
and conquer scheme until the appropriate
error is satisfied everywhere.
• Very popular method in practice.
• Problem:
– We do not know the exact value, and hence do
not know the error.

Engineering Mathematics III 32


Adaptive Simpson’s Scheme
• How do we know whether to continue to
subdivide or terminate?

b
I ≡ ∫ f ( x ) dx = S ( a, b ) + E ( a, b ) , where
a

b−a   a+b 
S ( a, b ) =  f (a) + 4 f   + f ( b )  , and
6   2  
5
1  b − a  ( 4)
E ( a, b ) = −   f
90  2 

Engineering Mathematics III 33


Adaptive Simpson’s Scheme
• The first iteration can then be defined as:

I = S ( ) + E ( ) , where
1 1

() ()
S =
1
S ( )
a , b ,
• Subsequent subdivision E ( a, bbe
= Ecan
1
) defined as:

( 2)
S = S ( a, c ) + S ( c, b )

Engineering Mathematics III 34


Adaptive Simpson’s Scheme
• Now, since

( 2)
E ( a, c ) + E(2)( c, b )
• We Ecan =solve for E in terms of E(1).

5 5
1  h / 2  ( 4) 1  h / 2  ( 4)
E(
2)
=−   f −   f
90  2  90  2 
5
 1  1  h  ( 4) 1 (1)
= 4 −   f = E
 2  90  2  16

Engineering Mathematics III 35


Adaptive Simpson’s Scheme
• Finally, using the identity:

(1) (1) ( 2) ( 2)
=S
• We Ihave: +E =S +E

( 2) (1) (1) ( 2) ( 2)
S −into
• Plugging = Edefinition:
S our − E = 15 E

1 ( 2)
I =S ( 2)
+E ( 2)
=S ( 2)
+
15
S −S (
(1)
)
Engineering Mathematics III 36
Adaptive Simpson’s Scheme
• Our error criteria is thus:

1 ( 2)
I −S =( 2)
15
S −S ( (1)
≤ε )
• Simplifying leads to the termination formula:

(S ( 2)
−S (1)
) ≤ 15ε
Engineering Mathematics III 37
Adaptive Simpson’s Scheme
• What happens graphically:

Engineering Mathematics III 38


S 2 − S1 ≥ 15ε → subdivide

Engineering Mathematics III 39


Engineering Mathematics III 40
ε
S 2 − S1 ≥ 15 → subdivide
2

Engineering Mathematics III 41


ε
S2 − S1 ≤ 15 → done
4
1
I = S2 + ( S2 − S1 )
15

Engineering Mathematics III 42


ε
S2 − S1 ≥ 15 → subdivide
4

Engineering Mathematics III 43


1
I = S2 + ( S2 − S1 )
15

Engineering Mathematics III 44


1
I = S2 + ( S2 − S1 )
15

Engineering Mathematics III 45


Iright =Ileft + Iright

I=Ileft + Iright

Engineering Mathematics III 46


Engineering Mathematics III 47
Engineering Mathematics III 48
Adaptive Simpson’s Scheme
• We gradually capture the difficult spots.

Engineering Mathematics III 49

You might also like