Numerical Integration
Introduction To integrate a given function f(x) between limits [a,b], the general method
is to identify f(x) as the derivative of another function g(x) and then applying the
fundamental theorem of calculus; ie,
I = a∫b f(x) dx = a∫b [ dg(x)/dx] dx =g(b)-g(a)
Handbooks of tables of integrals are available for this purpose. Commercial softwares are
also available for performing symbolic computations that include evaluation of common
derivatives and integrals. However, in many cases, close-form expression for integration
does not exist, particularly when f(x) is generated from experimental measurements.
Even when an analytical expression for f(x) is available, there is no guarantee that a
closed form expression for the integral exists. In such cases, numerical methods are
employed to find the integral.
To find an estimate for the integral I = a∫b f(x) dx the interval [a,b] is sampled at m+1
equally spaced points, xo, x1, x2, ..,xm with xo = a and xm+1 = b. The step size is h= (b-a)/m
and the following data table of x vs f(x) may be generated:
x= xo x1 x2 … Xm
f(x)= fo f1 f2 … fm
Where, xk = xo + k.h and fk= f(xk)
The basic approach to find the integral is to approximate f(x) by an interpolating
polynomial pn(x) of degree n and integrate it between the specified limits. The resulting
expression for the integral would be a weighted sum of values of f(x).
Newton-Cote’s Integration Formulae
In Newton-Cote’s Integration Formulae, the interpolating polynomials are obtained
through Newton’s forward interpolation formula which expresses f(x) as a polynomial in
p, where, x= (xo+ ph), in terms of fo and forward differences of higher orders at fo as :
f(x) = f(xo+ ph) = fo + p.∆fo + p.(p-1). ∆2fo / 2! +p.(p-1)(p-2). ∆3fo/ 3! + …..
+ p.(p-1).(p-2)….(p-n+1) ∆nfo / n! + En+1(p)
Where, En+1(p) ≈ p.(p-1).(p-2)….(p-n).∆n+1 f0/(n+1)!
it may be shown that, ∆n+1 f0 ≈ f(n+1)(ξ).hn+1/(n+1)!
is the remainder after nth order difference term in f(xo+ ph). Thus, if the above series is
terminated after nth order term, the error shall be of the order of h n+1, written as O(hn+1), ξ
being a point in [a,b]
Thus, f(x) ≈ pn(x)= fo + p.∆fo + p.(p-1). ∆2fo / 2! +p.(p-1)(p-2). ∆3fo/ 3! + …
+ p.(p-1).(p-2)….(p-n+1) ∆nfo / n!
The Trapezoidal Rule:
The simplest of the Newton-Cote’s integration formula, the ‘Trapezoidal Rule’ may be
derived by truncating the above infinite series after the first-order difference term. Thus,
f(x) = f(xo+p.h) ≈ f(xo) + p.∆fo
where, x = xo+ p.h, dx = h.dp and when x = xo, p=0 and when x=x1, p=1
Therefore, the integral xo ∫x1 f(x) dx = o ∫1{fo + p.∆fo}h.dp
= h( fo + ∆fo/2) = h/2(fo +f1)
The error in the approximation is E = o ∫1E2(p).h.dp = o ∫1p(p-1).f(2)( ξ) dp.h3/2!
= (1/3 –1/2) f(2)( ξ).h3 /2! = - 1/12h3. f(2)( ξ)
Thus the error in a single step of trapezoidal formula is O(h3), of the order of h3 and may
be significant, if h is large. h may be made smaller by splitting the interval [a,b] into m
equally spaced panels, each of width h=(b-a)/m. With this modification,
a ∫b f(x) dx = xo ∫x1 f(x) dx+ x1 ∫x2 f(x) dx+….+ x m-1 ∫xm f(x) dx
= h/2{ fo +2( f1 + f2 +…+fm-1) +fm }
There shall be some error in integration of each panel and the overall error for m such
panels becomes - m/12h3. f(2)( ξ), where, f(2)( ξ) represents average of f(2)( ξ) over m
intervals. Since m = (b-a)/h, the overall error in the result shall be
E2= - h2(b-a). f(2)( ξ)/12, which is of the order of h2.
Simpson’s Rules
Simpson’s rules are based on approximating f(x) by higher degree interpolating
polynomials. This improves accuracy of the formula. Thus, Simpson’s 1/3rd rule is
derived by retaining up to third order differences of the interpolation formula, and
integrating over 2 panels
f(x) = f(xo+ ph) ≈ fo + p.∆fo + p.(p-1). ∆2fo / 2! +p.(p-1)(p-2). ∆3fo/ 3!
The error involved in the process is E4(p) = p.(p-1).(p-2)(p-3). f(4)(ξ).h4/4!
Now integrating above approximate expression of f(x) over 2-panels, we have,
xo ∫x2 f(x) dx = 0 ∫2 f(xo+ ph) h.dp
= h. 0 ∫2 { fo + p.∆fo + p.(p-1). ∆2fo / 2! +p.(p-1)(p-2). ∆3fo/ 3!}.dp
= h.{2.f0 + 4/2.∆fo + ( 8/3 - 4/2).∆2fo / 2 + (16/4 – 3.8/3 + 2.4/2) . ∆3fo/ 6}
= h{ 2fo + 2.∆fo + 1/3.∆2fo}
= h{ 2fo +2(f1 –f0) +1/3(f2- 2f1 +fo)}
= h/3(fo + 4f1 +f2)
The error involved in the process may be estimated as
E= o ∫2 E4(p) h.dp = o ∫2 {p.(p-1).(p-2)(p-3). f(4)(ξ).h4/4!}h.dp
= h5/24. o ∫2{p4 – 6p3 +11p2 –6p} f(4)(ξ)
= h5/24{ 32/5 – 6. 16/4 +11.8/3 –6.4/2}
= -1/90 f(4)(ξ).h5
The formula truncation error in 2-panels is of the order of h5. Dividing the interval [a,b]
of integration into even no of panels, ‘m’, the composite formula for the integral and the
error shall be respectively,
xo ∫xm f(x) dx = h/3 { (fo+fn) + 4(f1+f3+…+fm-1) + 2(f2 +f4 + …fm-2)}
and E4 = -1/180.(b-a) f(4)(ξ).h4 , which is of the order of h4.
Simpson’s 3/8th rule may be derived by using a cubic polynomial, once again, but
integrating over 3 panels instead of 2.
xo ∫x3 f(x) dx = 0 ∫3 f(xo+ ph) h.dp
= h. 0 ∫3 { fo + p.∆fo + p.(p-1). ∆2fo / 2! +p.(p-1)(p-2). ∆3fo/ 3!}.dp
= h{3fo + 9/2.∆fo + (27/3-9/2) ∆2fo/2+(81/4-3.27/3+2.9/2) ∆3fo/ 6}
= h{ 3fo+9/2(f1-fo) +9/4.(f2-2f1+fo) +3/8.(f3-3f2+3f1-f0)}
= 3/8.h{fo+ 3f1+3f2 +f3}
The formula truncation error involved in the process may be estimated as
E= o ∫3 E4(p) h.dp = o ∫3 {p.(p-1).(p-2)(p-3). f(4)(ξ).h4/4!}h.dp
= h5/24. o ∫3{p4 – 6p3 +11p2 –6p} f(4)(ξ)
= h5/24{ 243/5 – 6.81/4 +11.27/3 –6.9/2}
= -1/90 f(4)(ξ).h5
= -3/80 f(4)(ξ).h5
Here again, the local error in integrating over 3-panels is of the order of h5 as in 1/3rd rule.
More generally, if there are multiple of 3 no. of panels, the above formulae may be
modified to
xo ∫xm f(x) dx = 3/8.h{(fo + fm) +3.(f1+f2+f4+f5+…fm-2+fm-1) + 2(f3+f6+f9 +…+fm-3)}
and the composite truncation error shall be E4’ = -3/80.(b-a) f(4)(ξ).h4
Example:
To illustrate the relative accuracies Newton-Cote’s integration formula of the different
order, consider integration
I= a ∫b ex .dx /(eb – ea)
The exact value of the above integral is 1.
The results obtained by the above methods for a= 0 and b=1, using different values of m
are given in following table:
For m=2:
x= 0 3/6 1
f(x)= 0.581976 0.959517 1.5819767
7 3
No. of Trapezoidal Simpson’s
panels rule 1/3 rd. rule
2 1.0207470 1.0003371
For m=6
x= 0 1/6 2/6 3/6 4/6 5/6 1
f(x)= 0.581976 0.687524 0.812213 0.959517 1.33535 1.339114 1.5819767
7 2 9 3 9 4
No. of Trapezoida Simpson’s Simpson’s
panels l 1/3 rd. rule 3/8 rd. rule
6 1.0023137 1.000004 1.0000122
3