A simple derivation of the trapezoidal rule for numerical integration

A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
A simple derivation of the trapezoidal rule for
numerical integration
Erik Talvila and Matthew Wiersma
Composite
rule
Trapezoidal
theorem
Proof
University of the Fraser Valley
Chilliwack, British Columbia
and
University of Waterloo
Waterloo, Ontario
Composite
rule
Corrected
trapezoidal
rule
January 6, 2012
Topics and Techniques for Teaching Real Analysis
References
Power corrupts. Powerpoint corrupts absolutely.
Outline
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
1.
2.
3.
4.
5.
6.
7.
The trapezoidal rule
The composite rule
Trapezoidal approximation theorem
Proof of trapezoidal approximation
Composite rule
Corrected trapezoidal rule
References
The trapezoidal rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
!b
f : [a, b] → R estimate
a
f (x) dx
Trapezoidal approximation
"
#
!b
f (a)+f (b)
f
(x)
dx
"
(b
−
a)
2
a
y=f(x)
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
f(a)
f(b)
References
a
b
The composite rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
Uniform partition of interval [a, b]
a = x0 < x 1 < · · · < x n = b
xi = a + i∆x
0≤i ≤n
∆x =
b−a
n
nth trapezoidal
$ approximation
&
n−1
%
b−a
f (a) + 2
f (xi ) + f (b)
Tn =
2n
i=1
Composite trapezoidal rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
f(x i-1 )
Trapezoidal
rule
f(x i )
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
x 0= a
x i-1
xi
x n= b
Figure: Composite trapezoidal approximation
Trapezoidal approximation theorem
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Theorem (Trapezoidal rule)
Let f ∈ C 2 ([a, b]). Write
'
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
b
f (x) dx =
a
Then |E T (f )| ≤
rule is
'
b
a
b−a
[f (a) + f (b)] + E T (f ).
2
(b − a)3 max|f "" |
. The composite trapezoidal
12
$
&
n−1
%
b−a
f (x) dx =
f (a) + 2
f (xi ) + f (b) + EnT (f ), and
2n
|EnT (f )| ≤
i=1
(b −
a)3 max|f "" |
12n2
.
Proof of trapezoidal approximation
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Write p(x) = (x − α)2 + β
Integrate by parts to get
'
b
Trapezoidal
rule
Composite
rule
"
f (x)p(x) dx = f (b)p(b) − f (a)p(a) −
Composite
rule
Corrected
trapezoidal
rule
References
b
a
a
Trapezoidal
theorem
Proof
"
'
f " (x)p " (x) dx
' b
= f " (b)p(b) − f " (a)p(a) − f (b)p " (b) +f (a)p " (a) +
f (x)p "" (x) dx
a
""
(α, β ∈ R to be determined).
Since p "" = 2 we can solve for
'
b
a
f (x) dx,
)
1(
−f (a)p " (a) + f (b)p " (b) + f " (a)p(a) − f " (b)p(b)
2
'
1 b ""
f (x)p(x) dx
+ E (f ), where E (f ) =
2 a
f (x) dx =
a
!b
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Trapezoidal rule requires for p(x) = (x − α)2 + β
p(a) = p(b) = 0
The unique solution of this overdetermined system is
α=
Proof
Composite
rule
Corrected
trapezoidal
rule
References
− p " (a) = p " (b) = b − a
and
Hence, p(x) =
*
a+b
2
a+b
x−
2
and
+2
−
β=−
(b − a)2
4
(b − a)2
4
Error estimate
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
1
2
'
b
|f "" (x)p(x)| dx
a
,
+
' ,*
max|f "" | b ,,
a + b 2 (b − a)2 ,,
≤
−
, x−
, dx
,
2
2
4
a ,
'
max|f "" | h 2
|x − h2 | dx
h = (b − a)/2
=
2
−h
' h
""
(h2 − x 2 ) dx
= max|f |
|E (f )| ≤
0
Corrected
trapezoidal
rule
=
References
=
max|f "" |2h3
3
(b − a)3 max|f "" |
12
Composite rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
'
b
f (x) dx
=
a
i=1
"
Proof
Composite
rule
Corrected
trapezoidal
rule
References
n '
%
=
xi
f (x) dx
xi−1
n
(b − a) %
[f (xi−1 ) + f (xi )]
2n
i=1
$
&
n−1
%
b−a
f (a) + 2
f (xi ) + f (b)
2n
i=1
Composite rule error
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Let yi be the midpoint of [xi−1 , xi ]. Define
P(x) = (x − yi )2 −
(b − a)2
4n2
if x ∈ [xi−1 , xi ].
Then P is continuous on [a, b].
Trapezoidal
rule
P(xi−1 ) = P(xi ) = 0
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
|EnT (f )|
P " (xi −) =
b−a
n
P " (xi +) = −
b−a
n
, n '
,
n ' xi
, max|f "" | %
1 ,,% xi ""
,
= ,
f (x)P(x) dx , ≤
|P(x)| dx
,
2,
2
xi−1
xi−1
i=1
=
max|f "" |
2
i=1
n
%
(xi − xi−1 )3
6
i=1
(b − a)3 max|f "" |
=
12n2
Corrected trapezoidal rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Choose p(x) = (x − α)2 + β to minimise the error.
|E (f )| ≤
≤
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
Minimised for
α=
'
1 b ""
|f (x)p(x)| dx
2 a
'
,
max|f "" | b ,,
,
2
,(x − α) + β , dx
2
a
a+b
2
β=−
(b − a)2
16
Corrected trapezoidal rule
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Let f ∈ C 2 ([a, b]). Then
'
a
b
f (x) dx "
)
3(b − a)2 ( "
b−a
[f (a) + f (b)] +
f (a) − f " (b)
2
32
Then |E CT (f )| ≤
trapezoidal rule is
'
a
b
$
&
n−1
%
b−a
f (a) + 2
f (x) dx =
f (xi ) + f (b)
2n
i=1
+
Corrected
trapezoidal
rule
References
(b − a)3 max|f "" |
. The composite corrected
32
with |EnCT (f )| ≤
a)2
3(b −
32n2
( "
)
f (a) − f " (b) + EnCT (f ),
(b − a)3 max|f "" |
.
32n2
References
A simple
derivation of
the
trapezoidal
rule for
numerical
integration
Trapezoidal
rule
Composite
rule
Trapezoidal
theorem
Proof
Composite
rule
Corrected
trapezoidal
rule
References
E.T. and M.W., Simple derivation of basic quadrature formulas,
Atlantic Electronic Journal of Mathematics (in press)
E.T. and M.W., Optimal error estimates for corrected
trapezoidal rules (preprint)