Maria Cameron
1. Numerical integration: some basic rules
The problem of numerical integration, or numerical quadrature, is to estimate
Z b
f (x)dx.
I(f ) =
a
This problem arises when the integration cannot be carried out exactly or when f (x) is
known only at a finite number of points.
Numerical integration is basically a stable process, and many adequate formulas or rules
exist for it. Some of them we are going to derive here.
We assume that the integrand f (x) is sufficiently smooth on some interval [c, d] containing [a, b] so that we ca write
f (x) = pk (x) + f [x0 , . . . , xk , x]πk+1 (x)
where πk+1 (x) = (x − x0 ) . . . (x − xk ) is the nodal polynomial. We estimate I(f ) by I(pk ).
Then the error of this estimate is
Z b
(1)
E(f ) = I(f ) − I(pk ) =
f [x0 , . . . , fk , x]πk (x)dx.
a
Note that f [x0 , . . . , fk , x] is continuous and hence integrable function of x as
πk+1 (k+1)
f (x) − pk (x) ≡ f [x0 , . . . , fk , x]πk+1 (x) =
f
(ζ), ζ ∈ (a, b),
(k + 1)!
i.e.,
f (k+1) (ζ)
, ζ ∈ (a, b).
(k + 1)!
The error term in Eq. (1) can be simplified in some cases. The first such case is where
the nodal polynomial πk+1 (x) is of one sign. Then by the mean value theorem
Z b
Z b
(2)
f [x0 , . . . , fk , x]πk (x)dx = f [x0 , . . . , fk , ξ]
πk+1 (x)dx.
f [x0 , . . . , fk , x] =
a
a
If f (x) is k + 1 times continuously differentiable then
Z
f (k+1) (η) b
πk+1 (x)dx.
(3)
E(f ) =
(k + 1)! a
Another case where the error term can be simplified is where
Z b
(4)
πk+1 (x)dx.
a
In such a case we can make use of the identity
(5)
f [x0 , . . . , xk , x] = f [x0 , . . . , xk , xk+1 ] + f [x0 , . . . , xk+1 , x](x − xk+1 )
1
2
which is valid for an arbitrary xk+1 . Then we get
Z b
f [x0 , . . . , xk , x]πk+1 (x)dx
E(f ) =
a
Z
b
Z
a
a
Z
b
f [x0 , . . . , xk+1 , x](x − xk+1 )πk+1 (x)dx
f [x0 , . . . , xk , xk+1 ]πk+1 (x)dx +
=
b
f [x0 , . . . , xk+1 , x]πk+2 (x)dx.
=
a
Here we used
Z b
Z b
πk+1 (x)dx = 0.
f [x0 , . . . , xk , xk+1 ]πk+1 (x)dx = f [x0 , . . . , xk , xk+1 ]
a
a
Now, if we choose xk+1 in such a way that
πk+2 (x) ≡ (x − xk+1 )πk+1 (x)
is of one sign on (a, b), and if f (x) is k + 2 times continuously differentiable, then it follows
that
Z
f (k+2) (η) b
πk+2 (x)dx.
(6)
E(f ) =
(k + 2)! a
Now we consider specific examples.
k = 0: Then
f (x) = f (x0 ) + f [x0 , x](x − x0 ).
Hence
I(p0 ) = (b − a)f (x0 ).
(1) If x0 = a, we have the rectangle rule. Noting that the nodal polynomial is
of one sign we have
Z b
1
R
0
(7)
I(f ) ≈ R = (b − a)f (a), E = f (η)
(x − a)dx = f 0 (η)(b − a)2 .
2
a
Rb
R
b
π
(x)dx
=
(2) If x0 = a+b
,
then
φ
(x)
is
not
of
one
sign
but
1
1
a (x − x0 )dx = 0,
a
Rb 2
2
while a (x − x0 ) dx is of one sign. Hence in this case, the error in I(p0 ) can
be computed by Eq. (6) with x1 = x0 . One gets the midpoint rule
a+b
1
(8)
I(f ) ≈ M = (b − a)f
, E M = f 00 (η)(b − a)3 .
2
24
k = 1:
f (x) = f (x0 ) + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x]π2 (x).
Set x0 = a and x1 = b. Then π2 (x) = (x − a)(x − b) is of one sign on (a, b). Hence
Z b
Z b
I(f ) =
{f (a) + f [a, b](x − a)}dx + 21 f 00 (η)
(x − a)(x − b)dx.
a
a
3
Then we get the trapezoid rule
I(f ) ≈ T =
(9)
f (a) + f (b)
(b − a),
2
ET = −
1 00
f (η)(b − a)3 .
12
k = 2: Then
f (x) = p2 (x) + f [x0 , x1 , x2 , x]π3 (x).
Set x0 = a, x1 =
1
2 (a
+ b), x2 = b. Then
Z b
π3 (x)dx = 0.
a
(10)
Therefore the error can be found from Eq. (6). In this case we obtain Simpson’s
rule
b−a
a+b
I(f ) ≈ S =
f (a) + 4f
+ f (b) ,
6
2
1
E = − f (iv) (η)
90
S
(11)
b−a
2
5
.
k = 3: In this case we have
f (x) = p3 (x) + f [x0 , x1 , x2 , x3 ]π4 (x).
In order to have π4 (x) of one sign on [a, b] we set x0 = x1 = a and x2 = x3 = b.
Then we get
Z b
1 (iv)
1 (iv)
E(f ) = f (η)
(x − a)2 (x − b)2 dx =
f (η)(b − a)5 .
4!
720
a
(iv)
Since p3 (x) = 0, we can use the Simpson rule to evaluate I(p3 ) exactly. One can
find p3 (a) = f (a), p3 (b) = b, and
b−a 0
a+b
p3
= 12 [f (a) + f (b)] +
[f (a) − f 0 (b)].
2
8
Hence
(12)
(13)
I(f ) ≈ CT =
b−a
(b − a)2 0
[f (a) + f (b)] +
[f (a) − f 0 (b)],
2
12
E CT =
1 (iv)
f (η)(b − a)5 .
720
This rule is called the corrected trapezoidal rule.
Exercise Work out the details of the derivation of the basic integration rules, Eqs. (7),
(8), (9), (10) and (11), and (12) and (13).
4
2. Newton-Cotes quadrature
A quadrature rule for evaluating an integral is a formula of the type
Z b
n
X
f (x)dx ≈ Q(f ) =
(14)
wi f (xi ).
a
i=0
The numbers wi are called the weights and the values xi are called the nodes.
If f (x) is approximated by an n-th degree interpolating polynomial we have
Z b
Z b
Z bX
n
n
X
f (x)dx ≈
pn (x)dx =
f (xi )Li (x)dx =
wi f (xi ),
a
a
a i=0
where
Z
b
Z
Li (x)dx ≡
wi =
a
b
i=0
n
Y
a k=0,k6=i
x − xk
dx.
xi − xk
Definition 1. The Newton-Cotes quadrature rules are the interpolatory quadrature rules
on equally spaced abscissas.
Example For n = 1 the Newton-Cotes rule is the trapezoidal rule. For n = 2 the NewtonCotes rule is the Simpson rule.
For several reasons considering Newton-Cotes rules for a high number of nodes is not
very practical. If the goal is to design a quadrature rule for fixed n that is exact for
the highest degree polynomials, the Gaussian quadrature is the best choice. If one wants
to reduce the error of integration, the better options are composite rules and Romberg
integration.
Definition 2. A quadrature rule has degree of exactness m if it renders exact restlts when
f (x) is any polynomial of degree not larger than m but it is not exact for at least one
polynomial of degree m + 1.
The degree of exactness of an n + 1-point Newton-Cotes rule is at least n. For the
trapezoidal rule and the Simpson rule, the degrees of exactness are 1 and 3 respectively.
As we will see later, the degree of exactness of an n+1-point Gaussian quadrature is 2n+1.
3. Composite rules
3.1. Composite trapezoidal rule. Let us consider an equally spaced partition of the
interval [a, b]:
a = x0 < x1 < . . . < xn = b,
, xk = a + kh,
h=
b−a
.
n
If we apply the trapezoidal rule to each subinterval, we obtain
Z b
n−1
n−1
X Z xi+1
X
h
f (x)dx =
f (xi ).
f (x)dx ≈ Tn (x) = (f0 + fn ) + h
2
a
xi
i=0
i=1
5
Theorem 1. Let f (x) ∈ C 2 [a, b] and let a = x0 < x1 < . . . < xn = b, xk = a + kh,
h = b−a
n , be an equally spaced partition of [a, b]. Then
Z b
n−1
X
h
f (x)dx = (f0 + fn ) + h
(15)
f (xi ) + EnT ,
2
a
i=1
where fi = f (xi ) and there is τ ∈ [a, b] such that
(b − a)h2 00
f (τ ).
12
Proof. It immediately follows from the trapezoidal rule that
n
n
h2 X 00
(b − a)h2 1 X 00
EnT = −
f (ηi ) = −
f (ηi ),
12
12
n
EnT = −
(16)
i=1
i=1
where ηi ∈ [xi−1 , xi ], i = 1, 2, . . . , n. Observing that
n
1 X 00
f (ηi ) ≤ max f 00 (x)
min f 00 (x) ≤
n
[a,b]
[a,b]
i=1
and applying
P the intermediate value theorem, we obtain that there is τ ∈ [a, b] such that
f 00 (τ ) = n1 ni=1 f 00 (ηi ). Then the result follows.
One can check that the composite corrected trapezoidal rule is given by
(17)
Z b
n−1
X
h
b − a 4 (iv)
h2
f (x)dx = CTn (f )+EnCT (f ) = (f0 +fn )+h
h f (η).
f (xi )+ [f 0 (a)−f 0 (b)]+
2
12
720
a
i=1
Comparing Eqs. (15), (16) and CTn we conclude that the major contribution to the error
of the composite trapezoidal rule is
h2 0
[f (a) − f 0 (b)].
12
Therefore, if the first derivatives of a function coincide at the ends of the interval then we
can expect the error of integration by the composite trapezoid rule decay as O(h4 ) rather
than O(h2 ). Now let us consider the following example.
Example The Bessel function J0 (x) is given by
Z π
n−1
X
(18)
πJ0 (x) =
cos(x sin(t))dx = h + h
cos(x sin(hj)) + Rn h = π/n.
EnT (f ) ≈
0
j=1
The relative errors of integration by the composite trapezoid al rule are given in Table 1.
We observe that the error is much smaller than we have expected taking into account the
fact that f 0 (0) = f 0 (π).
This example suggests that the composite trapezoidal rule can be much better than
expected for certain types of integrals. The crucial result to understand this behavior is
the Euler-Maclarin formula.
6
Table 1. The relative errors using the composite trapezoidal rule for Eq.
(18) for x = 5.
n
Rn
4
-0.12e-0
8
-0.48e-6
16 -0.11e-21
32 -0.13e-62
64 -0.13e-163
128 -0.53e-404
Theorem 2. Let f (x) ∈ C 2m+2 [x0 , xn ]. Then
Z xn
f (x)dx = Tn (f ) + Rn (f )
x0
where the truncation error Rn admits the expansion
m
X
B2l 2l (2l−1)
(19)
(x0 ) − f (2l−1) (xn )
h f
Rn (f ) =
(2l)!
l=1
−
(20)
B2m+2
(xn − x0 )h2m+2 f (2m+2) (ζ)
(2m + 1)!
where ζ ∈ [x0 , xn ] and Bk are the Bernoulli numbers.
The Bernoulli numbers are defined as follows. The Bernoulli polynomials are defines by
the generating function
∞
X Bn (x)
zexz
=
zn,
ez − 1
n!
(21)
|z| < 2π.
n=0
The Bernoulli numbers are the values of the Bernoulli polynomials at x = 0. Since
z
− 1 + 12 z
z
e −1
is even, we have
B2n+1 = 0, n = 1, 2, 3, . . . .
The first non vanishing numbers are
1
1
, B6 = 42
,....
30
By differentiating and integrating Eq. (21) with respect to x, it follows that
Z 1
1 0
(22)
Bn−1 (x) = Bn (x),
Bn (x)dx = 0, n = 1, 2, 3, . . . .
n
0
B0 = 1,
B1 = − 21 ,
Now we have the following theorem
B2 = 16 ,
B4 = −
7
Theorem 3. Let the function f : [0, 1] → C have k continuous derivatives (k = 0, 1, 2, . . .).
Then for k ≥ 1
Z 1
k
X
(−1)m Bm (m−1)
f (x)dx +
f
(1) − f (m−1) (0) + Rk ,
f (1) =
m!
0
m=1
where
Z
(−1)k+1 1 (k)
f (x)Bk (x)dx.
k!
0
Proof. The proof runs by induction w.r.t. k. For k = 1 the claim is true which follows
by integrating by parts. Then the property Bn−1 (x) = n1 Bn0 (x) is used to go from k to
k + 1.
Rk =
Extending the Bernoulli functions periodically and resealing we obtain the Euler-Maclarin
summation formula.
Theorem 4. If f ∈ C k (R) is periodic and the integral is taken over the full period, then
|Rn | = O(n−k ),
k → ∞.
3.2. Composite Simpson rule.
Theorem 5. Let f (x) ∈ C 4 [a, b] and let a = x0 < x1 < . . . < xn = b, xi = xx + jh,
i = 0, 1, 2, . . . , n = 2m, h = (b − a)/n. Then
Z b
f (x)dx = Sn (f ) + EnS (f ),
(23)
a
where
(24)
m−1
m−1
j=1
j=1
2 X
4 X
1
f2j + h
f2j−1 ,
Sn (f ) = h(f0 + fn ) + h
3
3
3
where fj = f (xj ) and there is τ ∈ [a, b] such that
(b − a)h4 (iv)
f (τ ).
180
Remark The error can be estimated for large n as
(25)
EnS (f ) = −
EnS (f ) ≈ ÊnS (f ) =
h4
f 000 (a) − f 000 (b)
180
in the sense that if f 000 (a) 6= f 000 (b) then
ÊnS (f )
= 1.
S (f )
n→∞ En
lim
References
[1] A. Gil, J. Segura, N. Temme, Numerical Methods for Special Functions, SIAM, 2007
[2] S. D. Conte, Carl de Boor, Elementary Numerical Analysis: an algorithmic approach, Second Edition,
McGraw-Hill Book Company, 1972
© Copyright 2026 Paperzz