Numerical Integration
•In general, a numerical integration is the approximation
of a definite integration by a “weighted” sum of function
values at discretized points within the interval of
integration.
0
( ) ( )
where is the weighted factor depending on the integration
schemes used, and ( ) is the function value evaluated at the
given point
N
b
i i
a
i
i
i
i
f x dx w f x
w
f x
x
=
»åò
Rectangular Rule
x=a x=b
Approximate the integration,
, that is the area under
the curve by a series of
rectangles as shown.
The base of each of these
rectangles is Dx=(b-a)/n and
its height can be expressed as
f(x
i
*) where x
i
* is the midpoint
of each rectangle
( )
b
a
f x dxò
x=x
1
* x=x
n
*
height=f(x
1
*)height=f(x
n
*)
1 2
1 2
( ) ( *) ( *) .. ( *)
[ ( *) ( *) .. ( *)]
b
n
a
n
f x dx f x x f x x f x x
x f x f x f x
= D + D + D
=D + +
ò
f(x)
x
Trapezoidal Rule
x=a x=b
x=x
1x=x
n-1
f(x)
x
The rectangular rule can be made
more accurate by using
trapezoids to replace the
rectangles as shown. A linear
approximation of the function
locally sometimes work much
better than using the averaged
value like the rectangular rule
does.
1 1 2 1
1 1
( ) [ ( ) ( )] [ ( ) ( )] .. [ ( ) ( )]
2 2 2
1 1
[ ( ) ( ) .. ( ) ( )]
2 2
b
n
a
n
x x x
f x dx f a f x f x f x f x f b
x f a f x f x f b
-
-
D D D
= + + + + + +
=D + + +
ò
Simpson’s Rule
Still, the more accurate integration formula can be achieved by
approximating the local curve by a higher order function, such as
a quadratic polynomial. This leads to the Simpson’s rule and the
formula is given as:
1 2 3
2 2 2 1
( ) [ ( ) 4 ( ) 2 ( ) 4 ( ) ..
3
..2 ( ) 4 ( ) ( )]
b
a
m m
x
f x dx f a f x f x f x
f x f x f b
- -
D
= + + + +
+ +
ò
It is to be noted that the total number of subdivisions has to be an
even number in order for the Simpson’s formula to work
properly.
Examples
3
2
3 4 2 4 4
1
1
Integrate ( ) between 1 and 2.
1 1
x dx= | (2 1 ) 3.75
4 4
2-1
Using 4 subdivisions for the numerical integration: x= 0.25
4
Rectangular rule:
f x x x x
x
= = =
= - =
D =
ò
i x
i
* f(x
i
*)
1 1.1251.42
2 1.3752.60
3 1.6254.29
4 1.8756.59
2
3
1
[ (1.125) (1.375) (1.625) (1.875)]
0.25(14.9) 3.725
x dx
x f f f f=D + + +
= =
ò
Trapezoidal Rule
ix
i
f(x
i
)
1 1
11.251.95
21.53.38
31.755.36
2 8
2
3
1
1 1
[ (1) (1.25) (1.5) (1.75) (2)]
2 2
0.25(15.19) 3.80
x dx
x f f f f f=D + + + +
= =
ò
Simpson’s Rule
2
3
1
[ (1) 4 (1.25) 2 (1.5) 4 (1.75) (2)]
3
0.25
(45) 3.75 perfect estimation
3
x
x dx f f f f f
D
= + + + +
= = Þ
ò
Trapezoidal Rule
ix
i
f(x
i
)
1 1
11.251.95
21.53.38
31.755.36
2 8
2
3
1
1 1
[ (1) (1.25) (1.5) (1.75) (2)]
2 2
0.25(15.19) 3.80
x dx
x f f f f f=D + + + +
= =
ò
Simpson’s Rule
2
3
1
[ (1) 4 (1.25) 2 (1.5) 4 (1.75) (2)]
3
0.25
(45) 3.75 perfect estimation
3
x
x dx f f f f f
D
= + + + +
= = Þ
ò