# Trapezoidal Rule

We know from a previous lesson that we can use Riemann Sums to evaluate a definite integral $$\int\limits_a^b {f\left( x \right)dx}.$$

Riemann Sums use rectangles to approximate the area under a curve.

Another useful integration rule is the Trapezoidal Rule. Under this rule, the area under a curve is evaluated by dividing the total area into little trapezoids rather than rectangles.

Let $$f\left( x \right)$$ be continuous on $$\left[ {a,b} \right].$$ We partition the interval $$\left[ {a,b} \right]$$ into $$n$$ equal subintervals, each of width

$\Delta x = \frac{{b - a}}{n},$

such that

$a = {x_0} \lt {x_1} \lt {x_2} \lt \cdots \lt {x_n} = b.$

The Trapezoidal Rule for approximating $$\int\limits_a^b {f\left( x \right)dx}$$ is given by

$\int\limits_a^b {f\left( x \right)dx} \approx {T_n} = {\frac{{\Delta x}}{2}}\left[ {{f\left( {{x_0}} \right)} + {2f\left( {{x_1}} \right)} + {2f\left( {{x_2}} \right)} + \cdots + {2f\left( {{x_{n - 1}}} \right)} + {f\left( {{x_n}} \right)}} \right],$

where $$\Delta x = \frac{{b - a}}{n}$$ and $${x_i} = a + i\Delta x.$$

As $$n \to \infty,$$ the right-hand side of the expression approaches the definite integral $$\int\limits_a^b {f\left( x \right)dx}.$$

## Solved Problems

Click or tap a problem to see the solution.

### Example 1

Use the Trapezoidal Rule with $$n = 6$$ to approximate $\int\limits_0^\pi {{{\sin }^2}xdx}.$

### Example 2

A function $$f\left( x \right)$$ is given by the table of values. Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = 0$$ and $$x = 8$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

### Example 3

A function $$f\left( x \right)$$ is given by the table of values. Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = -4$$ and $$x = 2$$ using the Trapezoidal Rule with $$n = 6$$ subintervals.

### Example 4

Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = 0$$ and $$x = 10$$ using the Trapezoidal Rule with $$n = 5$$ subintervals.

### Example 5

Approximate the area under the curve $y = {2^x}$ between $$x = -1$$ and $$x = 3$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

### Example 6

Approximate the area under the curve $y = \frac{1}{x}$ between $$x = 1$$ and $$x = 5$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

### Example 1.

Use the Trapezoidal Rule with $$n = 6$$ to approximate $\int\limits_0^\pi {{{\sin }^2}xdx}.$

Solution.

Here

$f\left( x \right) = {\sin ^2}x,\;\; a = 0,\;\; b = \pi .$

The width of each subinterval is

$\Delta x = \frac{{b - a}}{n} = \frac{\pi }{6},$

so the grid points have the coordinates $${x_i} = \frac{{i\pi }}{6}.$$

Calculate the values of the function $$f\left( x \right)$$ at the points $${x_i}:$$

$f\left( {{x_0}} \right) = f\left( 0 \right) = {\sin ^2}0 = {0^2} = 0;$
$f\left( {{x_1}} \right) = f\left( {\frac{\pi }{6}} \right) = {\sin ^2}\frac{\pi }{6} = {\left( {\frac{1}{2}} \right)^2} = \frac{1}{4};$
$f\left( {{x_2}} \right) = f\left( {\frac{{2\pi }}{6}} \right) = {\sin ^2}\frac{\pi }{3} = {\left( {\frac{{\sqrt 3 }}{2}} \right)^2} = \frac{3}{4};$
$f\left( {{x_3}} \right) = f\left( {\frac{{3\pi }}{6}} \right) = {\sin ^2}\frac{\pi }{2} = {1^2} = 1;$
$f\left( {{x_4}} \right) = f\left( {\frac{{4\pi }}{6}} \right) = {\sin ^2}\frac{{2\pi }}{3} = {\left( {\frac{{\sqrt 3 }}{2}} \right)^2} = \frac{3}{4};$
$f\left( {{x_5}} \right) = f\left( {\frac{{5\pi }}{6}} \right) = {\sin ^2}\frac{{5\pi }}{6} = {\left( {\frac{1}{2}} \right)^2} = \frac{1}{4};$
$f\left( {{x_6}} \right) = f\left( \pi \right) = {\sin ^2}\pi = {0^2} = 0.$

The Trapezoidal Rule formula is written in the form

$\int\limits_0^\pi {{{\sin }^2}xdx} \approx {T_6} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + \cdots + 2f\left( {{x_5}} \right) + f\left( {{x_6}} \right)} \right] = \frac{\pi }{{12}}\left[ {0 + 2 \cdot \frac{1}{4} + 2 \cdot \frac{3}{4} + 2 \cdot 1 + 2 \cdot \frac{3}{4} + 2 \cdot \frac{1}{4} + 0} \right] = \frac{\pi }{{12}}\left[ {\frac{1}{2} + \frac{3}{2} + 2 + \frac{3}{2} + \frac{1}{2}} \right] = \frac{\pi }{{12}} \cdot \frac{{12}}{2} = \frac{\pi }{2}.$

We can also determine the exact value of the integral:

$\int\limits_0^\pi {{{\sin }^2}xdx} = \frac{1}{2}\int\limits_0^\pi {\left( {1 - \cos 2x} \right)dx} = \frac{1}{2}\left[ {x - \frac{{\sin 2x}}{2}} \right]_0^\pi = \frac{1}{2}\left[ {\left( {\pi - 0} \right) - 0} \right] = \frac{\pi }{2}.$

So, in this particular example, the trapezoidal approximation $${T_6}$$ coincides with the exact value of the integral.

### Example 2.

A function $$f\left( x \right)$$ is given by the table of values. Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = 0$$ and $$x = 8$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

Solution.

The Trapezoidal Rule formula for $$n= 4$$ subintervals has the form

${T_4} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + 2f\left( {{x_3}} \right) + f\left( {{x_4}} \right)} \right].$

The width of the subinterval is $$\Delta x = 2.$$

Substituting the values of the function from the table, we find the approximate area under the curve:

$A \approx {T_4} = \frac{2}{2}\left[ {3 + 2 \cdot 7 + 2 \cdot 11 + 2 \cdot 9 + 3} \right] = 3 + 14 + 22 + 18 + 3 = 60.$

### Example 3.

A function $$f\left( x \right)$$ is given by the table of values. Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = -4$$ and $$x = 2$$ using the Trapezoidal Rule with $$n = 6$$ subintervals.

Solution.

We apply the Trapezoidal Rule formula with $$n = 6$$ subintervals which is given by

${T_6} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + 2f\left( {{x_3}} \right) + 2f\left( {{x_4}} \right) + 2f\left( {{x_5}} \right) + f\left( {{x_6}} \right)} \right].$

The width of each interval is $$\Delta x = 1.$$

The function values are known from the table, so we can easily calculate the approximate value of the area:

$A \approx {T_6} = \frac{1}{2}\left[ {0 + 2 \cdot 4 + 2 \cdot 5 + 2 \cdot 3 + 2 \cdot 10 + 2 \cdot 11 + 2} \right] = \frac{1}{2}\left[ {8 + 10 + 6 + 20 + 22 + 2} \right] = \frac{{68}}{2} = 34.$

### Example 4.

Approximate the area under the curve $$y = f\left( x \right)$$ between $$x = 0$$ and $$x = 10$$ using the Trapezoidal Rule with $$n = 5$$ subintervals.

Solution.

The Trapezoidal Rule formula for $$n = 5$$ intervals is given by

${T_5} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + 2f\left( {{x_3}} \right) + 2f\left( {{x_4}} \right) + f\left( {{x_5}} \right)} \right].$

It follows from the figure that $$\Delta x = 2.$$ The function values at the endpoints of the intervals are

$f\left( {{x_0}} \right) = f\left( 0 \right) = 4;$
$f\left( {{x_1}} \right) = f\left( 2 \right) = 6;$
$f\left( {{x_2}} \right) = f\left( 4 \right) = 6;$
$f\left( {{x_3}} \right) = f\left( 6 \right) = 4;$
$f\left( {{x_4}} \right) = f\left( 8 \right) = 4;$
$f\left( {{x_5}} \right) = f\left( {10} \right) = 5.$

Hence, the approximate value of the area is equal to

$A \approx {T_5} = \frac{2}{2}\left[ {4 + 2 \cdot 6 + 2 \cdot 6 + 2 \cdot 4 + 2 \cdot 4 + 5} \right] = 49.$

### Example 5.

Approximate the area under the curve $y = {2^x}$ between $$x = -1$$ and $$x = 3$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

Solution.

The Trapezoidal Rule formula for $$n = 4$$ has the form

${T_4} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + 2f\left( {{x_3}} \right) + f\left( {{x_4}} \right)} \right].$

Compute the function values $$f\left( {{x_i}} \right):$$

$f\left( {{x_0}} \right) = f\left( { - 1} \right) = {2^{ - 1}} = \frac{1}{2};$
$f\left( {{x_1}} \right) = f\left( 0 \right) = {2^0} = 1;$
$f\left( {{x_2}} \right) = f\left( 1 \right) = {2^1} = 2;$
$f\left( {{x_3}} \right) = f\left( 2 \right) = {2^2} = 4;$
$f\left( {{x_4}} \right) = f\left( 3 \right) = {2^3} = 8.$

As $$\Delta x = 1,$$ we get

$A \approx {T_4} = \frac{1}{2}\left[ {\frac{1}{2} + 2 \cdot 1 + 2 \cdot 2 + 2 \cdot 4 + 8} \right] = \frac{1}{2} \cdot 22\frac{1}{2} = 11\frac{1}{4}.$

### Example 6.

Approximate the area under the curve $y = \frac{1}{x}$ between $$x = 1$$ and $$x = 5$$ using the Trapezoidal Rule with $$n = 4$$ subintervals.

Solution.

We write the Trapezoidal Rule formula for $$n = 4$$ subintervals:

${T_4} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + 2f\left( {{x_3}} \right) + f\left( {{x_4}} \right)} \right].$

The function has the following values at the points $${x_i}:$$

$f\left( {{x_0}} \right) = f\left( 1 \right) = \frac{1}{1} = 1;$
$f\left( {{x_1}} \right) = f\left( 2 \right) = \frac{1}{2};$
$f\left( {{x_2}} \right) = f\left( 3 \right) = \frac{1}{3};$
$f\left( {{x_3}} \right) = f\left( 4 \right) = \frac{1}{4};$
$f\left( {{x_4}} \right) = f\left( 5 \right) = \frac{1}{5}.$

Since $$\Delta x = 1,$$ we obtain

$A \approx {T_4} = \frac{1}{2}\left[ {1 + 2 \cdot \frac{1}{2} + 2 \cdot \frac{1}{3} + 2 \cdot \frac{1}{4} + \frac{1}{5}} \right] = \frac{1}{2}\left[ {1 + 1 + \frac{2}{3} + \frac{1}{2} + \frac{1}{5}} \right] = \frac{1}{2} \cdot \frac{{30 + 30 + 20 + 15 + 8}}{{30}} = \frac{1}{2} \cdot \frac{{101}}{{30}} = \frac{{101}}{{60}}$