CGN 3421  Computer Methods
Gurley
Numerical Methods Lecture 4  Numerical Integration / Differentiation
page 83 of 88
Numerical Methods Lecture 4

Numerical Integration / Differentiation
Numerical Integration 
approximating the area under a function
We will consider 3 methods:
Trapezoidal rule,
Simpson’s rule,
Gauss Quadrature
The basic concept is to break the area up into smaller pieces with simple shapes fitted to approximate the func
tion over short lengths. The area under these simple shapes are then added up to approximate the total.
Trapezoidal rule 
piecewise linear approximation to curve f(x)
• chop area into N smaller pieces (sample of two pieces on the right)
• connect areas with straight lines, creating trapezoids
• find the area under each trapezoid
A=1/2*dx*(f(x)+f(x+dx))
• add up the trapezoids
Example, the figure at the bottom of the page chops a function into 4 trapezoids
over the range [a, b]. The trapeziodal rule adds up the area of each of the 4 trape
zoids to represent the area under the fucntion f(x).
dx = (ba)/N
(a, b are limits, N is number of pieces we divide the area into)
A1= 1/2 * dx * (f(x1) + f(x2))
A2 = 1/2* dx * (
f(x2) + f(x3))
A3 = 1/2* dx * (
f(x3) + f(x4))
A4 = 1/2* dx * (
f(x4) + f(x5))
_____________________________________________
Area =
1/2 * dx * (f(x1)+
2
*f(x2)+
2
*f(x3)+
2
*f(x4)+f(x5))
The generalized equation expressing trapezoidal rule is then ==>
Error:
The error (in blue) between the area of the trapezoid and the curve it represents builds up
Error reduction:
We can reduce error if we can
shorten the straight lines
used to estimate curves. Increasing
the number (increase N) of trapezoids used over the same range [a,b] will reduce error in the area estimate.
A1
A2
x1
x2
x3
dx
f(x)
A1=1/2*dx*(f(x1)+f(x2))
!"#$
!
"

%& ’ &
!
(
)
"
’ &
(
(
)
(
"
#
)
∑
’ &
)
!
$
(
)
$
$
≅
fx
x
a
b
Numerically estimate area
under fx within [a, b]
A1
A2
A3
A4
dx
x1
x2
x3
x4
x5
Error
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document