Numerical Calculus III
Numerical Calculus III
Simpson’s rule
For appropriate functions f and intervals [a, b], we can approximate the
integral
b
∫ f (x) dx
a
using Simpson’s rule
b b−a a+b
∫ f (x) dx ≈ (f (a) + 4f ( ) + f (b)) .
a 6 2
Numerical Calculus III 5/28
Problem 1
Let f be given by f (x) = 1 − x − x2 .
1
Compute an approximation to ∫ f (x) dx using the midpoint rule.
0
1
Compute an approximation to ∫ f (x) dx using the trapezoidal rule.
0
1
Compute an approximation to ∫ f (x) dx using Simpson’s rule.
0
Compute the absolute error in each of the obtained approximations
1
to ∫ f (x) dx.
0
Numerical Calculus III 6/28
Problem 2
For appropriate functions f and intervals [a, b], derive the trapezoidal rule
b
for approximating ∫ f (x) dx by integrating an appropriate polynomial.
a
Moreover,
b b
1 1 1 1
∫ p1 (x) dx = [f (a) ( x2 − bx) + f (b) ( x2 − ax)]
a a−b 2 b−a 2 a
1 1 2 2 1 1 2
= f (a) ( b − b ) + f (b) ( b − ab)
a−b 2 b−a 2
1 1 1 1
−f (a) ( a2 − ab) − f (b) ( a2 − a2 )
a−b 2 b−a 2
1 1 2 1 2
= f (a) (− b − a + ab)
a−b 2 2
1 1 2 1
+f (b) ( b − ab + a2 )
b−a 2 2
1 1 2 2 1 1 2
= f (a) (b + a − 2ab) + f (b) (b − 2ab + a2 )
b−a2 b−a2
1 1 1 1
= f (a) (b − a)2 + f (b) (b − a)2
b−a2 b−a2
b−a
= (f (a) + f (b)).
2
Numerical Calculus III 12/28
Degree of accuracy
The degree of accuracy (also called degree of precision) of a numerical
integration rule is the largest nonnegative integer n for which the rule is
exact for all polynomials of degree at most n.
The degree of accuracy of the trapezoidal rule is 1.
The degree of accuracy of Simpson’s rule is 3.
Numerical Calculus III 14/28
Problem 3
Determine the degree of accuracy of the midpoint rule.
and
a+b b
(b − a)f0 ( ) = b − a = ∫ f0 (x) dx.
2 a
With f1 (x) = x we have that
b b
1 1
∫ f1 (x) dx = [ x2 ] = (b2 − a2 )
a 2 a 2
and
a+b a+b 1 2 b
(b − a)f1 ( ) = (b − a) = (b − a2 ) = ∫ f1 (x) dx.
2 2 2 a
Numerical Calculus III 15/28
So, with f (x) = c0 f0 (x) + c1 f1 (x) where c0 and c1 are constants we have
that
a+b a+b a+b
(b − a)f ( ) = (b − a) (c0 f0 ( ) + c1 f1 ( ))
2 2 2
a+b a+b
= c0 (b − a)f0 ( ) + c1 (b − a)f1 ( )
2 2
b b
= c0 ∫ f0 (x) dx + c1 ∫ f1 (x) dx
a a
b
= ∫ (c0 f0 (x) + c1 f1 (x)) dx
a
b
= ∫ f (x) dx.
a
Hence, the midpoint rule is exact for all polynomials of degree at most 1.
Numerical Calculus III 16/28
or
g(x) ≤ 0 for all x ∈ [a, b].
Then there exists ξ ∈ (a, b) for which
b b
∫ f (x)g(x) dx = f (ξ) ∫ g(x) dx.
a a
Numerical Calculus III 18/28
Moreover,
1 h 2 h2 1 h 2 h2 1 h 2 h2 h2 h2
p(b) = (b − a − ) − = (h − ) − = ( ) − = − = 0,
2 2 8 2 2 8 2 2 8 8 8
1 h 2 h2 1 h 2 h2 h2 h2
p(a) = (a − a − ) − = (− ) − = − = 0,
2 2 8 2 2 8 8 8
p′ (b) = b − a − = h − =
h h h
2 2 2
and
p′ (a) = a − a −
h h
=− .
2 2
Numerical Calculus III 20/28
Moreover,
b b
f ′ (x)p′ (x) dx = − [f ′ (x)p(x)]a + ∫ f ′′ (x)p(x) dx
b
−∫
a a
b
′ ′
= −f (b)p(b) + f (a)p(a) + ∫ f ′′ (x)p(x) dx
a
b
= ∫ f ′′ (x)p(x) dx.
a
Now, since p(x) ≤ 0 for all x ∈ [a, b], by the Weighted Mean Value
Theorem for Integrals, there exists ξ ∈ (a, b) for which
b b
∫ f ′′ (x)p(x) dx = f ′′ (ξ) ∫ p(x) dx.
a a
Numerical Calculus III 22/28
Furthermore,
b
b 1 h 3 h2
∫ p(x) dx = [ (x − a − ) − x]
a 6 2 8 a
1 h 3 h2 1 h 3 h2
= (b − a − ) − b − (a − a − ) + a
6 2 8 6 2 8
3 2 3
1 h h 1 h
= (h − ) − (b − a) − (− )
6 2 8 6 2
1 h 3 h3 1 h3
= ( ) − +
6 2 8 6 8
1 h3 5 h3
= −
6 8 6 8
2 h3
= −
3 8
h3
= − .
12
Numerical Calculus III 23/28
Problem 4
Suppose that a ∈ R, that b ∈ R, that a < b and that f ∈ C 2 [a, b]. Let
h = b − a. Determine an upper bound on
b h
∣∫ f (x) dx − (f (a) + f (b))∣ .
a 2
Numerical Calculus III 25/28
By the error identity for the trapezoidal rule, there exists ξ ∈ (a, b) for
which
b h h3 ′′
∫ f (x) dx − (f (a) + f (b)) = − f (ξ)
a 2 12
and hence
b h3 h3 ′′
f (x) dx − (f (a) + f (b))∣ = ∣− f ′′ (ξ)∣ =
h
∣∫ ∣f (ξ)∣ .
a 2 12 12
Consequently,
b h3
max ∣f ′′ (c)∣ .
h
∣∫ f (x) dx − (f (a) + f (b))∣ ≤
a 2 12 c∈[a,b]
Numerical Calculus III 26/28
References
Burden, Faires & Burden, Numerical Analysis, 10E
Section 4.3