Top

# Trapezoidal Rule

In this page, we are going to learn about trapezoidal rule concept. Below you can see the explanation about trapezoidal rule. The evaluation of a definite integral from a set of numerical values is the process of numerical integration. If the function is of a single variable, the process is called as quadrature.

The numerical integration is calculated by first approximating the integral by a polynomial through an interpolation formula and then integrate it between the given limits.

Thus, to evaluate $\int_{a}^{b} f(x) dx$ ,express the function f(x) by an interpolation formula, say p(x) and then, integrate the function f(x) by an interpolation formula, say p(x) and then, integrate p(x) between the limits a and b.

Therefore, $\int_{a}^{b} f(x) dx$ ∼ $\int_{a}^{b} p(x) dx$

There are times when it is not possible to evaluate a definite integral directly, using the standard method.

$\int_ a^b f(x) dx = [F(x)]_a^b = F(b) – F(a)$, where I(x) is the simplest function for which $\frac{d}{dx}$$F(x) = f(x). Two examples which you cannot integrate with your knowledge so far are \int_ 0^1$$\frac{1}{1 + x^2}$$dx and \int_ 0^1 \sqrt{1 + x^2} dx. You need to use another method for approximating to the integrals. Divide the interval from a to b into n equal intervals, each of width h, so that h = \frac{b - a}{n} Call the x-coordinate of the left side of the first Interval x0, so x0 = a, and then successively let x_1 = x_0 + h, x_2 = x_0 + 2h and so on until x_{n - 1} = x_0 + (n - 1)h and x_n - x_0 + nh = b. To shorten the amount of writing, use the shorthand y_0 = f(x_0), y_1 = f(x_1) and so on. Then, using the simple form of the each interval of width h in turn, you find that \int_ a^b f(x) dx = \frac{1}{2}$$ h (y_0 + y_1) + $$\frac{1}{2}$$ h (y_1 + y_2) + $$\frac{1}{2}$$ h (y_2 + y_3) + ...... + $$\frac{1}{2}$$ h (y_{n - 1} + y_n)$

= $\frac{1}{2}$$h [(y_0 + y_n) + 2(y_1 + y_2 + .... + y_n-1)] The sum estimates total area under the curve y = f(x) on the interval a and b and hence also estimates the integral \int_{a}^{b} f(x) dx. This approximation formula is known as the trapezoid rule and applies as a mean of approximating the integral even if the function is not positive. Therefore, the trapezoidal rule with n intervals states that \int_ a^b y dx =$$\frac{1}{2}$$h [(y_0 + y_n) + 2(y_1 + y_2 +.... +y_{n - 1})] where h = \frac{b - a}{n} Now, let us try some problems to apply the trapezoidal rule.  Related Calculators Perimeter of a Trapezoid Trapezoid Calculator Isosceles Trapezoid Calculator Cramer's Rule Calculator ## Trapezoidal Rule Formula Back to Top The approximation of \int_{a}^{b} f(x) dx is done by partitioning the interval [a, b] into sub intervals of equal width. The sum of the areas of resulting trapezoids gives the required estimation of the definite integral. In the above diagram, the graph of f(x) is divided into six equal partitions. \int_{a}^{b} f(x) dx = sum of the areas of the six trapezoids formed by the partition. = \frac{h}{2}$$ [(f(x_{0}) + f(x_{1}) + f(x_{1}) + f(x_{2}) + f(x_{2}) + f(x_{3}) + f(x_{3}) + f(x_{4}) + f(x_{4}) + f(x_{5}) + f(x_{5}) + f(x_{6})$

= $\frac{h}{2}$$[f(x_0)] + 2f(x_{1}) + 2f(x_{2}) + 2f(x_{3}) + f(x_{4}) + 2f(x_{5}) + f(x_{6}) Let y be a continuous function on [a,b]. Then, the Trapezoid rule is \int_{a}^{b} y dx = \int_{a}^{b} f(x) dx = \frac{h}{2}$$[(y_{0} + y_{n}) + 2(y_{1} + y_{2} + ... + y _{n - 1})]$
Where h =$\frac{b - a}{ n}$ and a = x0 and b = x0+nh

## Trapezoidal Rule Examples

Given below are some of the examples on trapezoidal rule.

### Solved Examples

Question 1: Use the trapezoidal rule with 5 intervals to estimate $\int_0^1 [\frac{1}{1 + x^2}] dx$, giving your answer correct to 3 decimal places.
Solution:

The factor $\frac{1}{2}$$h is \frac{1}{2}$$ \times 0.2 = 0.1$

Therefore, the approximation to the integral is $0.1 \times 7.83732 = 0.783 732$

Thus, the 5-interval approximation correct to 3 decimal places is 0.784.

The accurate value of $\int_0^1 $$\frac{1}{1 + x^2}$$ dx$ is $\frac{1}{4}$ and the value correct to 3 decimal places is 0.785

Question 2: Approximating the definite integral using trapezoidal rule with uniform partition.
Solution:
Approximate $\int_{1}^{2} $$\frac{1}{x}$$ dx$ using 5 uniform trapezoidal partitions.

When the interval (1, 2) is partitioned into 5 intervals the width of each interval, $h = 0.2$

The heights to be used in trapezoidal approximation are as follows:

$x_{0} = 1, x_{1} = 1.2, x_{2} = 1.4, x_{3} = 1.6, x_{4} = 1.8\ and\ x_{5} = 2$

$\int_{1}^{2} $$\frac{1}{x}$$ dx$ = $0.1(1 + 2($$\frac{1}{1.2}$$) + 2($$\frac{1}{1.4}$$) + 2($$\frac{1}{1.6}$$) + 2($$\frac{1}{1.8}$$) + $$\frac{1}{2}$$)$

$=0.695635$

Hence, the general formula for 'n' partitions can be stated as
$\int_{a}^{b} f(x) dx$ = $\frac{h}{2}$$[f(x_{0}) + 2f(x_{1}) +... ... + 2f(x_{n - 1}) + f(x_{n})]This is called the Composite Trapezoid Rule. This can also be written using sigma notation as follows: \int_{a}^{b} f(x) dx = \frac{h}{2}$$ [f(x_{0}) + \sum_{k = 1}^{n - 1} f(x_{k}) + f(n_{n})]$

Question 3: Estimate $\int_{1}^{2} x^{2} dx$ using Trapezoidal rule with $n = 4$. Compare the estimate with the actual value.
Solution:
Partition [1.2] into four sub-intervals. Evaluate each of the trapezoidal areas and sum them up.

$a = 1, b = 2, n = 4$ Hence, the width of each interval $h$ = $\frac{b - a}{n}$ = $\frac{2 - 1}{4}$ = $0.25$

$x_{0} = 1, x_{1} = 1.25, x_{2} = 1.5, x_{3} = 1.75, x_{4} = 2$

The actual value of the integral = $\int_{1}^{2} x^{2} dx$ = $\frac{x^{3}}{3}$ = $\frac{8 - 1}{3}$ = $\frac{7}{3}$

The error in approximation is 0.0104167

Percentage error occurred in the estimate = 0.004464 or 0.4464 %

## Composite Trapezoidal Rule

The definite integral $\int_{a}^{b} f(x) dx$ can be evaluated using the rule provided by the fundamental theorem calculus as $\int_{a}^{b} f(x) dx= F(b) - F(a)$, where $f(x)$ is the anti derivative of $f(x)$. But, there are functions like $\tan (x^{4})$ which do not have direct anti derivative. We may also come across situations where the function is represented in table with experimental entries. Even though a formula for the function does not exist, we nevertheless would be required to evaluate the definite integral. Numerical methods like Trapezoidal Rule and Simpson's rule are specially handy for situations when the definite integral cannot be evaluated using the anti derivative.

### Trapezoidal Rule - Straight Line Approximation

The straight line approximation for the trapezoidal rule considers the whole trapezoid formed by the ordinates of the two points as the parallel sides and the whole width of the interval as the height. To find the area between the curve $f(x)$ and the x axis between the two points $x_{0}$ and $x_{1}$ the trapezoidal rule used in straight line approximation is

$\int_{a}^{b} f(x) = \frac {h}{2}[f(x_{0})] + f(x_{1})$ where h is the width = $x_{1} - x_{0}$

Using the graph given above for the function f, the area under the curve can be evaluated using straight line approximation and the formula for the area of a trapezoid.

Area of a trapezoid = $\frac{1}{2}$$\times height \times sum of the lengths of the parallel sides . x_{0} = 1, x_{1} = 12, f(x_{0}) = 3 and f(x_{1}) = 5, h = x_{1} - x_{0} = 12 - 1 = 11 The lengths of the parallel sides are f(x_{0}) = 3 and f(x_{1}) = 5 \int_{1}^{12} f(x) dx = \frac{11}{2}$$ [3 + 5]$ = 44 sq units

Even though the straight line method is not a good approximation to the definite integral, the principle is extended by partitioning the entire width into sub intervals.

## Trapezoidal Rule Integration

It is the process of finding or evaluating a definite integral. I = $\int_{a}^{b}f(x)dx$ from a set of numerical values of the integral f(x). The problem of numerical integration is solved by first approximating the integrand by a polynomial with the help of an interpolation formula and then integrating this expression between the desired limits. Trapezoidal rule is a way to find an approximate value for an given numerical integration, which based on calculating the sum of the area of the curve. This is known as method of approximate integration. We can find the total area under the given curve f(x) with the help of Trapezoidal rule and also estimate the integral $\int_{a}^{b}f(x)dx$.