You are on page 1of 43

Numerical Integration

Dr. Meead Saberi


Research Centre for Integrated Transport
Innovation (rCITI)
School of Civil and Environmental Engineering
Integration
Mathematically, integration is represented by

! = # & ' ('


$

& ' is known as integrand.


Non-computer methods for integration

Graphical approach: using a grid, rectangles or strips.


Example: Strip
method
(a) A complicated, continuous
function.

(b) Table of discrete values of


f(x) generated from the
function.

(c) Use of a numerical method


(stripe method) to estimate
the integral.
Engineering applications

(a) Estimating the area of a field bounded by a stream and two


roads; (b) Estimating the cross-sectional area of a river; (c)
Determining the net force due to a non-uniform wind force.
Newton-Cotes Method
Newton-Cotes method Straight line Parabola
is the most common
numerical integration
method. It’s based on
the strategy of replacing
a complicated function
or tabulated data with
an approximating % %
function that is easy to ! = # & ' (' ≅ # &* ' ('
integrate.
$ $

&* ' = +, + +. ' + +/ ' / + ⋯


Newton-Cotes Method
We can also approximate
the integral using a series of
polynomials applied piece-
wise to the function.
So, what is the “strip method”?
“Strip method” employs a
series of zero-order
polynomials to approximate
the integral.

% %

! = # & ' (' ≅ # &* ' ('


$ $

&* ' = +,
Closed vs. Open formulas
Closed forms are those where data points at the beginning and
end of the limits of integration are known.

Open forms have integration limits that extend beyond the range
of the data.

In this class, we focus more on closed forms.


Closed vs. Open formulas
Trapezoidal rule
The trapezoidal rule is the first of the Newton-Cotes closed
integration formulas which uses a first order polynomial
approximation.

% %

! = # & ' (' ≅ # &* ' ('


$ $

& / −& ,
&* ' = &(,) + (' − ,)
/−,
Trapezoidal rule
The area under this straight
line is an estimate of the
+
integral of !(#) between ! & −! %
' ≅ )! % + # − % .#
limits of % and &. &−%
*

! % +! &
' ≅ (& − %)
2
Area of the trapezoid?
The trapezoidal rule is equivalent
to approximating the area of the
trapezoid under the straight line.

! ≅ #$%&ℎ × )*+,-)+ ℎ+$-ℎ&

2 ) +2 /
! ≅ (/ − )) ×
2
Newton-Cotes closed formulas
In fact, all Newton-Cotes closed formulas can be expressed in a
general format of the ”area of trapezoid”. They differ only with
respect to how we calculate the average height.

! ≅ #$%&ℎ × )*+,-)+ ℎ+$-ℎ&


Error of the Trapezoidal rule
Of course, there is error in
this approximation, right?

An estimate for the local


truncating error of a single
application of the
trapezoidal rule is

1 ))
!" = − ( ̅ (+)(- − .)/
12
Example
Use the trapezoidal rule to numerically integrate

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

from a = 0 and b = 0.8. Also estimate the truncating error.


Example: Approximate Integral
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! 6 +! 5
2 ≅ (5 − 6) ×
2
! 0 + ! 0.8
2 ≅ (0.8 − 0) ×
2
0.2 + 0.232
2 ≅ 0.8× = 0.1728
2
Example: Truncating error
We need the function’s second derivative over the interval.

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! 22 " = −400 + 4050" − 10,800" * + 8,000" -

We then need to find the average value of the second derivative


8.9
∫8 −400 + 4050" − 10,800" * + 8,000" - :"
! ̅22 " = = −60
0.8 − 0
Example: Truncating error
1 ))
!" = − ( ̅ (+)(- − .)/
12

1 /
!0 = − −60 0.8 = 2.56
12

That’s quite a large error!


Multiple-application trapezoidal rule

One way to reduce the error is to


divide the integration interval into a
number of smaller segments and
apply the trapezoidal rule to each
segment separately.

We have n+1 equally spaced points


!" , !$ , !% , …

)−+
ℎ=
,
Multiple-application trapezoidal rule
#−%
ℎ=
&
)+ )0

' = ( , - .- + ( , - .- + ⋯
)* )+

, -2 + , -3 , -3 + , -5
'=ℎ +ℎ +⋯
2 2

, -2 + 2 ∑;<3
9:3 , -9 + , -;
' = (# − %)
2&
Multiple-application trapezoidal rule

( )* + 2 ∑120
./0 ( ). + ( )1
! = ($ − &)
23
What about the error?
An estimate for the local
truncating error of a
multiple-application of the
trapezoidal rule is

1 (( − ))+ 00
!" = − -

12 ,
Example
Use the two-segment trapezoidal rule to numerically integrate

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

from a = 0 and b = 0.8. Also estimate the truncating error.


Example: Approximate Integral
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

0.8 − 0
ℎ= = 0.4
2
! "9 + 2 ∑>?=
;<= ! "; + ! ">
4 = (6 − 7)
2@
! 0 + 2! 0.4 + ! 0.8
4 = 0.8 = 1.0688
4
Example: Truncating error
We need the function’s second derivative over the interval.

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! 22 " = −400 + 4050" − 10,800" * + 8,000" -

We then need to find the average value of the second derivative


8.9
∫8 −400 + 4050" − 10,800" * + 8,000" - :"
! ̅22 " = = −60
0.8 − 0
Example: Truncating error
1 (( − ))+ 00
!" = − -

12 ,

1 0.8 − 0 +
!" = − −60 = 0.64
12 2-

Remember the error from the previous example with only a


single application of trapezoidal rule? The error is reduced
significantly.

!" (6789:;<= 8>)?6@8) = 2.56


Simpson’s rules
Another way to obtain a more accurate estimate of an integral is
to use higher-order polynomials to connect the points.

3 points 4 points
Simpson’s 1/3 rules
Simpson’s 1/3 rule results when 3 points

a second-order interpolating
polynomial is used with
!" , !$ , and !( .
. .

* = , / ! 0! ≅ , /( ! 0!
- -
24
! − !$ ! − !( ! − !" ! − !(
*= , / !" + / !$ 0!
!" − !$ !" − !( !$ − !" !$ − !(
23
Simpson’s 1/3 rules
% %

! = # & ' (' ≅ # &* ' ('


$ $

!
+-
' − '1 ' − '* ' − '2 ' − '*
= #. & '2 + & '1
'2 − '1 '2 − '* '1 − '2 '1 − '*
+,
' − '2 ' − '1
+ & '* / ('
'* − '2 '* − '1
Simpson’s 1/3 rules
( )* + 4( )- + ((). )
! = ($ − &)
6

Accordingly, the error can be estimated as follows

($ − &)2 (7)
01 = − (̅
2880
Example
Use the Simpson’s 1/3 rule to numerically integrate

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

from a = 0 and b = 0.8 with a midpoint in middle (0.4). Also


estimate the truncating error.
Example
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! "7 + 4! "8 + !("* )


2 = (4 − 5)
6
! 0 + 4! 0.4 + ! 0.8
2 = 0.8 = 1.367467
6
The error is estimated as Much smaller error
compared to trapezoidal rule
4−5 1 0.8 1
<= = − !̅ /
=− −2400 = ?. @AB?CCA
2880 2880
Multi-Application Simpson’s 1/3 rules
Just like before, Simpson’s rule
can be improved by dividing
the integral interval into a
number of smaller segments.
Number of segments must be
even.

( )* + 4 ∑450
./0,2,3 ( ). + 2 ∑ 458
7/8,9,: ( )7 + (()4 )
! = ($ − &)
3<
Multi-Application Simpson’s 1/3 rules
The error can also be estimated as

(& − ')) (.)


!" = − 0 ̅
180-.
Example
Use multiple-application (n=4) Simpson’s 1/3 rule to
numerically integrate

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

from a = 0 and b = 0.8 with a midpoint in middle (0.4). Also


estimate the truncating error.
Example
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

2 = 4 (ℎ = 0.2)

! 0 = 0.2
! 0.2 = 1.288
! 0.4 = 2.456
! 0.6 = 3.464
! 0.8 = 0.232
Example
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! "7 + 4 ∑=>;
9:;,-,1 ! "9 + 2 ∑ =>*
?:*,/,@ ! "? + !("= )
2 = (4 − 5)
3B

0.2 + 4 1.288 + 3.464 + 2 2.456 + 0.232


2 = 0.8 = 1.623467
12

4−5 1 0.81
EF = − /
!̅ /
=− /
−2400 = 0.017067
180B 180 4
Simpson’s 3/8 rules
Similarly, if we fit a third-order
polynomial to four points, it’s
called Simpson’s 3/8 rule.

Interestingly, we can apply both


the 1/3 and 3/8 rule combined to
handle multiple applications with
odd number of segments.
Simpson’s 3/8 rules
Similarly, if we fit a third-order polynomial to four points, it’s
called Simpson’s 3/8 rule.

( )* + 3( )- + 3( ). + ( )/
! = ($ − &)
8

Accordingly, the error can be estimated as follows

($ − &)3 (8)
12 = − (̅
6480
Example
Use Simpson’s 3/8 rule to numerically integrate

! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

from a = 0 and b = 0.8 with a midpoint in middle (0.4). Also


estimate the truncating error.
Example
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

A single application of Simpson’s 3/8 rule requires four equally


spaced points:

! 0 = 0.2
! 0.2667 = 1.432724
! 0.5333 = 3.487177
! 0.8 = 0.232
Example
! " = 0.2 + 25" − 200" * + 675" - − 900" / + 400" 1

! "7 + 3! "9 + 3! "* + ! "-


2 = (4 − 5)
8
0.2 + 3 1.432724 + 3.487177 + 0.232
2 = 0.8 = 1.519170
8
0.8 1
<= = − −2400 = 0.1213630
6480

You might also like