Numerical integration
Basic integration rules
Dr LD Moleleki
Mathematics and Applied Mathematics
A4-2106
September 13, 2021
Lesson outcomes
At the end of lesson students should be able to:
Use interpolating polynomials to derive some basic integration rules
Determine nodes and weights in the general integration rule on
[−1, 1] and use the rule to estimate integrals on [a, b]
Apply the error formula for the trapezoidal rule and simpson’s rule
Trapezoidal rule I
Formula
b
b−a
Z
f (x)dx ≈ (f (a) + f (b)) (1)
a 2
Derivation
Let p(x) be the 1st Lagrange polynomial that interpolates f at
a = x0 < x1 = b. Set f (x) ≈ p(x) and integrate over [a, b]
Z b Z b Z b
f (x)dx ≈f (a) L0 (x)dx +f (b) L1 (x)dx
a
|a {z } | a {z }
(1)(b−a)/2 (1)(b−a)/2
b−a
= (f (a) + f (b))
2
Trapezoidal rule II
Error term
for Trapezoidal rule is
f 00 (ξ)
− (b − a)3
12
Simpson’s rule I
Formula
b
b−a
Z
a+b
f (x)dx ≈ f (a) + 4f + f (b) (2)
a 6 2
Derivation
Simpson’s rule II
Let 2nd Lagrange polynomial q(x) interpolate f at
Rb
a = x0 < x1 = a+b
2 < x2 = b. Set f (x) ≈ q(x) and take a
Z b Z b Z b
a+b
f (x)dx ≈f (a) L0 (x)dx + f L1 (x)dx
a a 2 a
Z b
+ f (b) L2 (x)dx
a
Z b
(x − x1 )(x − b)
=f (a) dx
a (a − x1 )(a − b)
Z b
a+b (x − a)(x − b)
+f dx
2 a (x1 − a)(x1 − b)
Z b
(x − a)(x − x1 )
+ f (b) dx
a (b − a)(b − x1 )
Simpson’s rule III
1−η 1+η a+b b−a
Let x(η) = 2 a + 2 b ≡ 2 + 2 η then
b 1
b−a
Z Z
f (x)dx ≈f (a) η(η − 1)dη
4
a
| −1 {z }
2
3
1
b−a
Z
a+b
+f (η + 1)(η − 1)dη
2 2 −1
| {z }
4
3
1
b−a
Z
+ f (b) (η(η + 1)dη
4 −1
| {z }
2
3
b−a a+b
= f (a) + 4f + f (b)
6 2
Simpson’s rule IV
Error term
for Simpson’s rule is
f (4) (ξ)
− (b − a)5
90
Mapping to [−1, 1]
General integration rule on [−1, 1]
Integration rules (1) and (2) on [a, b] = [−1, 1] take general form:
Z 1 n
X
f (t)dt ≈ wi f (ti ) (3)
−1 i=1
where the numbers t1 , t2 , · · · , tn ∈ [−1, 1] are called nodes, and
the numbers w1 , w2 , · · · , wn are called weights.
Example
The Trapezoidal rule is (3) with
n = 2, w1 = w2 = (b − a)/2, t1 = a and t2 = b.
Class problem
Determine the nodes and weights for the Simpson rule.
Mapping to [−1, 1]
General rule on arbitrary intervals
Rb
Use formula (3) to estimate a f (x)dx. Let −1 = t0 < t1 = 1, and
let
t −1 t +1 a+b b−a
x(t) = a+ b= + t
|−1{z− 1} |1 {z
+ 1} 2 2
L0 (t) L0 (t)
then
b 1
b−a a+b b−a
Z Z
f (x)dx = f + t dt
a 2 −1 2 2
| {z }
g (t)
n
b−aX
≈ wi g (ti )
2
i=1
Basic integration rules
Example
R2
1. 1.1 Use the Trapezoidal rule (TR) to estimate 1
ln x dx correct to
3 decimal places.
1.2 Compare your answer with the exact value.
1.3 Compute an error bound for the TR and compare it with the
actual error.
2. Repeat the previous problem for Simpson’s rule.