5.1 Newton-Cotes Quadrature 111
PN(x) =
N
∑
i= 0
∏
k 6 =i
x−xk
xi−xk
yi,
we could attempt to approximate the functionf(x)with a first-order polynomial inxin the
two sub-intervalsx∈[x 0 −h,x 0 ]andx∈[x 0 ,x 0 +h]. A first order polynomial means simply that
we have for say the intervalx∈[x 0 ,x 0 +h]
f(x)≈P 1 (x) = x−x^0
(x 0 +h)−x 0
f(x 0 +h)+x−(x^0 +h)
x 0 −(x 0 +h)
f(x 0 ),
and for the intervalx∈[x 0 −h,x 0 ]
f(x)≈P 1 (x) =
x−(x 0 −h)
x 0 −(x 0 −h)
f(x 0 )+
x−x 0
(x 0 −h)−x 0
f(x 0 −h).
Having performed this subdivision and polynomial approximation, one fromx 0 −htox 0 and
the other fromx 0 tox 0 +h,
∫a+ 2 h
a
f(x)dx=
∫x 0
x 0 −h
f(x)dx+
∫x 0 +h
x 0
f(x)dx,
we can easily calculate for example the second integral as
∫x 0 +h
x 0
f(x)dx≈
∫x 0 +h
x 0
(
x−x 0
(x 0 +h)−x 0 f(x^0 +h)+
x−(x 0 +h)
x 0 −(x 0 +h)f(x^0 )
)
dx,
which can be simplified to
∫x 0 +h
x 0
f(x)dx≈
∫x 0 +h
x 0
(
x−x 0
h
f(x 0 +h)−
x−(x 0 +h)
h
f(x 0 )
)
dx,
resulting in ∫
x 0 +h
x 0
f(x)dx=
h
2
(f(x 0 +h)+f(x 0 ))+O(h^3 ).
Here we added the error made in approximating our integral with a polynomial of degree 1.
The other integral gives
∫x 0
x 0 −h
f(x)dx=
h
2
(f(x 0 )+f(x 0 −h))+O(h^3 ),
and adding up we obtain
∫x 0 +h
x 0 −h
f(x)dx=
h
2
(f(x 0 +h)+ 2 f(x 0 )+f(x 0 −h))+O(h^3 ), (5.3)
which is the well-known trapezoidal rule. Concerning the error in the approximation made,
O(h^3 ) =O((b−a)^3 /N^3 ), you should note the following.This is the local error!Since we are
splitting the integral fromatobinNpieces, we will have to perform approximatelyNsuch
operations. This means that theglobal errorgoes like≈O(h^2 ). To see that, we use the trape-
zoidal rule to compute the integral of Eq. (5.1),
I=
∫b
a
f(x)dx=h(f(a)/ 2 +f(a+h)+f(a+ 2 h)+···+f(b−h)+fb/ 2 ), (5.4)
with a global error which goes likeO(h^2 ).