Académique Documents
Professionnel Documents
Culture Documents
}
, on each sub-interval we can approximate the exact integral of f by that of a
polynomial f approximating f on
k
I . The simplest solution consists in choosing f as the constant
polynomial interpolating f at the middle point of
k
I , that is, at
1
2
k k
k
x x
x
+
= . In such a way we obtain the
composite midpoint quadrature formula:
1
( ) ( )
M
midpt k
k
I f h f x
=
=
(1)
b. Trapezoidal formula
Another formula can be obtained by replacing f on
k
I by the linear polynomial interpolating f at the nodes
x
k-1
and x
k
. This yields the so-called composite trapezoidal formula given by,
| | | |
1
1
1 1
( ) ( ) ( ) ( ) ( ) ( )
2 2
M M
trap k k k
k k
h h
I f f x f x f a f b h f x
= =
= + = + +
(2)
Using Matlab
Look up the following Matlab commands - quad, quadl and trapz.
The function you want to integrate needs to be defined as an anonymous function which is then passed
as an argument to one of the three integration functions.
Illustrative example problems
1. (Simple functions) Consider ( ) 2 sin(2 ) f x x = + . Calculate the approximate integral of f(x) over the
interval [1, 6]. Use the two numerical integration methods given below with 11 sample points to compute the
approximate integral. How do they compare?
2. (Demography) Consider the population of a very large number M of individuals. The distribution of their
height can be represented by a bell function characterized by the mean value h0 of the height and standard
deviation ,
2 2
0
( ) /(2 )
( )
2
h h
M
N h e
o
o t
=
Calculate the number of individuals whose height is between 1.8m and 1.9m for a group of 200 people with a
mean height of 1.7m and a standard deviation of 0.1m.