Generally, integration is the process of summing up slices or parts in order to find the whole. If *dx* represents a small displacement or change along the direction *x*, the process of integration will give a function g(x), the derivative of which △g(x) is equal to the function f(x). This is indicated by the integral sign ∫. Thus, ∫*f*(*x*)*dx* is the summation of the product of *f*(*x*) and *dx*. Numerical integration is a computational (approximate) approach of evaluating definite integrals.

A definite integral is defined by limits (say *a* and *b*) and it is given by;

\int_{a}^{b} f(x) \,dx

Numerical integration has a lot of applications in engineering such as in the computation of areas, volumes, and surfaces. It also has the advantage of being easily programmable in computer software. In civil engineering, it can be applied in the computation of earthwork volumes such as cut and fill in road construction.

*Read Also…*

Linear Interpolation for Engineers

For the approximation of definite integrals of the form ∫*f*(*x*)*dx*, the numerical quadrature is normally used. In this method, the function *f(x)* is normally replaced with an interpolating polynomial *p(x)* which on integration, obtains an approximate value of the definite integral.

To obtain the numerical solution of functions using the numerical quadrature, the first step is usually to select a distinct set of equally spaced nodes {x_{0}, x_{1}, …., x_{n}} from the interval [a,b]. The smaller the spacing of the nodes or intervals, the more accurate the solution.

Let us assume that P_{n} is the lagrange interpolating polynomial then we can write;

\\P_n(x) = \sum_{i=0}^{n} f(x_i)L_i(x)

If we integrate *P _{n}* excluding its truncation error term over [a ,b], we obtain;

\int_{a}^{b} f(x) \,dx\ =\int_{a}^{b} \sum_{i=0}^{n} f(x_i)L_i(x),dx\\= \sum_{i=0}^{n} a_if(x)

Where a_{i }= ∫*L _{i}*(

*x*)

*dx*for i = 0, 1, 2, 3, … n

There are many methods of approximating the numerical quadrature for numerical integration but we are going to consider the most popular ones which are;

- Trapezoidal Rule, and
- Simpson’s rule

**The Trapezoidal Rule** **for Numerical Integration**

The Trapezoidal rule for numerical integration is obtained from considering the integration formula produced by using first Lagrange polynomials with equally spaced intervals. To evaluate ∫*f*(*x*)*dx* within the limits [a, b], let x_{0} = a and x_{1} = b. Then h = b – a = x_{1} – x_{0}

Using the linear Lagrange polynomial;

P_{1}(x)= [(x – x_{1})/(x_{0} – x_{1})]f(x_{0}) + [(x – x_{0})/(x_{1} – x_{0})]f(x_{1})

Therefore;

\int_{a}^{b} f(x) \,dx\ =\int_{a}^{b}[((x - x_1)/(x_0-x_1))f(x_0) + ((x - x_0)/(x_1-x_0))f(x_1)]dx

The equation above eventually yields;

∫*f*(*x*)*dx* = (x_{1} – x_{0})/2[f(x_{1}) + f(x_{0})}

But (x_{1} – x_{0})/2 = h

Hence,

\int_{a}^{b} f(x) \,dx\ = h/2[f(x_1) + f(x_0)] ---- (2.3)

Equation (2.3) is known as the Trapezoidal rule.

It gives good approximation to the value of ∫*f*(*x*)*dx* when the curve of y = f(x) when the interval [a, b] is small, and deviates slightly from the trapezium aABb. However, in a situation when the deviation is violent, i.e. the interval [a, b] is very large, the accuracy in the approximation to the value of ∫*f*(*x*)*dx* can be improved by dividing the interval [a, b] into a larger (even) number of trapezoid of smaller width. This is referred to as the Composite Trapezoidal Rule.

**Composite Trapezoidal Rule**

Under the condition that warrants the use of composite trapezoidal rule, we can establish the general formula using the figure below;

The area;

A_{1} = h/2(y_{0} + y_{1})

A_{2} = h/2(y_{1} + y_{2})

A_{3 }= h/2(y_{2} + y_{4})

.

.

.

A_{n} = h/2 (y_{n-1} +y_{n})

Hence

∑*A*_{i} = (A_{1} + A_{2} + A_{3} + ⋯ + A_{n})

= h/2 [y_{0} + y_{n}+ 2(y_{1} + y_{2} + y_{3} + ⋯ + y_{n-1}]

The generalised Trapezoidal Rule can therefore be expressed as;

\int_{a}^{b} f(x) \,dx\ = h/2[f(x_0) + f(x_n) + 2\sum_{i=1}^{n-1}f(x_i)] ---- (2.4)

**The Simpson’s Rule for Numerical Integration**

If we consider the integration formula derived by using the second Lagrange polynomials with equally spaced intervals. If the function f(x) is replaced by an arc of a parabola, and the origin temporarily shifted to a point x = x_{0} by putting x = X + x_{0} . We may therefore write the equation of the parabola A_{0}A_{1}A_{2} as y = y_{0} + bX + cX^{2}.

The area of the two adjacent strips under A_{0}A_{1}A_{2} is approximately;

\int_{0}^{2h} (y_o + bX + cX^2)dx\ = 2h(y_o + bh + 4/3ch^2)

Ultimately;

\int_{0}^{2h} (y_o + bX + cX^2)dx\ = h/3(y_o + 4y_1 + y_2)

**Composite Simpson’s Rule**

Similar to Trapezoidal rule, the accuracy of Simpson’s rule can be improved by dividing the interval [a, b] into a larger (even) number of strips of smaller width. Let us evoke fig 6.2, and by considering two successive strips at a time, we can write the expression of Simpson’s formula as thus:

∫*f*(*x*)*dx* = h/3[y_{0 }+ 4y_{1} + y_{2}) + (y_{2} + 4y_{3} + y_{4}) + … + (y_{n-2} + 4y_{n-1} + y_{n})

In a more compact form;

∫*f*(*x*)*dx* = h/3[y_{0} + y_{n} + 2∑even ordinates + 4∑odd ordinates]

**Worked Example**

Evaluate the integral below using 10 intervals;

\int_{0}^{1} (sinx)dx\

**Solution**

At 10 intervals, h = 0.1

y_{0} = f(x_{0}) = sin(0) = 0

y_{1} = f(x_{1}) = sin(0.1) = 0.0998 (radians)

y_{2 }= f(x_{2}) = sin(0.2) = 0.1986

y_{3} = f(x_{3}) = sin(0.3) = 0.2955

y_{4} = f(x_{4}) = sin(0.4) = 0.3894

y_{5} = f(x_{5}) = sin(0.5) = 0.4794

y_{6} = f(x_{6}) = sin(0.6) = 0.5646

y_{7} = f(x_{7}) = sin(0.7) = 0.6442

y_{8} = f(x_{8}) = sin(0.8) = 0.7173

y_{9} = f(x_{9}) = sin(0.9) = 0.7833

y_{n} = f(x_{10}) = sin(1.0) = 0.8414

Using the composite Trapezoidal rule;

∫*f*(*x*)*dx* = h/2[y_{0} + y_{n}+ 2(y_{1} + y_{2} + y_{3} + ⋯ + y_{n-1}]

∫*sin*(*x*)*dx* = 0.1/2[0 + 0.8414 + 2(0.0998 + 0.1986 + 0.2955 + 0.3894 + 0.4794 + 0.5646 + 0.6442 + 0.7173 + 0.7833] = 0.4593

Using the composite Simpson’s rule;

∫*f*(*x*)*dx* = h/3[y_{0} + y_{n} + 2∑even ordinates + 4∑odd ordinates]

∫*sin*(*x*)*dx* = 0.1/3[0 + 0.84814 + 2∑(0.1986 + 0.3894 + 0.5646 + 0.7173) + 4∑(0.0998 + 0.2955 + 0.4794 + 0.6442 + 0.7833)] = 0.4596

**The exact solution**

\int_{0}^{1} (sinx)dx\ = 0.459697

Therefore, it can be seen that the composite Simpson’s rule approximates better than the composite Trapezoidal rule.