Trapezoidal Rule
Solved Problems
Example 7.
Approximate the integral \[\int\limits_0^1 {{x^3}dx}\] using the Trapezoidal Rule with \(n = 2\) subintervals.
Solution.
The Trapezoidal Rule formula with \(n = 2\) subintervals is written as
\[{T_2} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + f\left( {{x_2}} \right)} \right],\]
where
\[\Delta x = \frac{{b - a}}{n} = \frac{{1 - 0}}{2} = \frac{1}{2},\]
and the function has the following values:
\[f\left( {{x_0}} \right) = f\left( 0 \right) = {0^3} = 0;\]
\[f\left( {{x_1}} \right) = f\left( {\frac{1}{2}} \right) = {\left( {\frac{1}{2}} \right)^3} = \frac{1}{8};\]
\[f\left( {{x_2}} \right) = f\left( 1 \right) = {1^3} = 1.\]
Hence
\[\int\limits_0^1 {{x^3}dx} \approx {T_2} = \frac{1}{4}\left[ {0 + 2 \cdot \frac{1}{8} + 1} \right] = \frac{1}{4} \cdot \frac{5}{4} = \frac{5}{{16}}\]
Example 8.
Approximate the integral \[\int\limits_0^2 {{x^2}dx}\] using the Trapezoidal Rule with \(n = 3\) subintervals.
Solution.
We write the Trapezoidal Rule formula with \(n = 3\) subintervals:
\[{T_3} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + f\left( {{x_3}} \right)} \right],\]
where
\[\Delta x = \frac{{b - a}}{n} = \frac{{2 - 0}}{3} = \frac{2}{3},\]
and the function has the following values at \({x_i}:\)
\[f\left( {{x_0}} \right) = f\left( 0 \right) = {0^2} = 0;\]
\[f\left( {{x_1}} \right) = f\left( {\frac{2}{3}} \right) = {\left( {\frac{2}{3}} \right)^2} = \frac{4}{9};\]
\[f\left( {{x_2}} \right) = f\left( {\frac{4}{3}} \right) = {\left( {\frac{4}{3}} \right)^2} = \frac{{16}}{9};\]
\[f\left( {{x_3}} \right) = f\left( 2 \right) = {2^2} = 4.\]
Then
\[\int\limits_0^2 {{x^2}dx} \approx {T_3} = \frac{1}{3}\left[ {0 + 2 \cdot \frac{4}{9} + 2 \cdot \frac{{16}}{9} + 4} \right] = \frac{1}{3}\left[ {\frac{8}{9} + \frac{{32}}{9} + 4} \right] = \frac{1}{3} \cdot \frac{{8 + 32 + 36}}{9} = \frac{1}{3} \cdot \frac{{76}}{9} = \frac{{76}}{{27}}\]
Example 9.
Using the Trapezoidal Rule with \(n = 10\) subintervals, evaluate the integral \[\int\limits_0^1 {\frac{{dx}}{{1 + {x^2}}}} \] and calculate the approximate value of \(\pi.\) Round the answer to \(2\) decimal places.
Solution.
We evaluate the given integral by the formula
\[{T_{10}} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + \cdots + 2f\left( {{x_9}} \right) + f\left( {{x_{10}}} \right)} \right].\]
The width of each subinterval is
\[\Delta x = \frac{{b - a}}{n} = \frac{{1 - 0}}{{10}} = 0.1\]
The function values at the points \({x_i}\) are given below:
Figure 5.
Plugging in the values from the table into our equation, we obtain:
\[\int\limits_0^1 {\frac{{dx}}{{1 + {x^2}}}} \approx {T_{10}} = 0.05 \times 15.6996 = 0.7850\]
Let's also evaluate this integral by the Fundamental Theorem of Calculus :
\[\int\limits_0^1 {\frac{{dx}}{{1 + {x^2}}}} = \left[ {\arctan x} \right]_0^1 = \arctan 1 - \arctan 0 = \frac{\pi }{4} - 0 = \frac{\pi }{4}.\]
Hence, the approximate value of \(\pi\) with an accuracy of two decimal places is
\[\pi \approx 4\int\limits_0^1 {\frac{{dx}}{{1 + {x^2}}}} = 4 \times 0.7850 = 3.14\]
Example 10.
Using the Trapezoidal Rule with \(n = 3\) subintervals approximate the area under the curve \[f\left( x \right) = 3x - {x^2}\] between \(x = 0\) and \(x = 3.\) Estimate the relative percent error of the approximation.
Solution.
The Trapezoidal Rule with \(n = 3\) segments is written in the form
\[{T_3} = \frac{{\Delta x}}{2}\left[ {f\left( {{x_0}} \right) + 2f\left( {{x_1}} \right) + 2f\left( {{x_2}} \right) + f\left( {{x_3}} \right)} \right].\]
The width of the subinterval is equal to
\[\Delta x = \frac{{b - a}}{n} = \frac{{3 - 0}}{3} = 1.\]
We calculate the values of the function at the points \({x_i}:\)
\[f\left( {{x_0}} \right) = f\left( 0 \right) = 3 \cdot 0 - {0^2} = 0;\]
\[f\left( {{x_1}} \right) = f\left( 1 \right) = 3 \cdot 1 - {1^2} = 2;\]
\[f\left( {{x_2}} \right) = f\left( 2 \right) = 3 \cdot 2 - {2^2} = 2;\]
\[f\left( {{x_3}} \right) = f\left( 3 \right) = 3 \cdot 3 - {3^2} = 0.\]
Hence, the approximate value of the area under the curve is given by
\[A \approx {T_3} = \frac{1}{2}\left[ {0 + 2 \cdot 2 + 2 \cdot 2 + 0} \right] = 4.\]
The true solution is found by integration:
\[\int\limits_0^3 {f\left( x \right)dx} = \int\limits_0^3 {\left( {3x - {x^2}} \right)dx} = \left[ {\frac{{3{x^2}}}{2} - \frac{{{x^3}}}{3}} \right]_0^3 = \frac{{27}}{2} - \frac{{27}}{3} - 0 = \frac{9}{2} = 4.5\]
So the relative error is
\[\left| \varepsilon \right| = \frac{{4.5 - 4}}{{4.5}} = \frac{{0.5}}{{4.5}} = \frac{1}{9} \approx 11.1\% \]
The final answer is
\[A \approx 4,\;\left| \varepsilon \right| = 11.1\%\]
Example 11.
Using the Trapezoidal Rule with \(n = 4\) subintervals approximate the area under the sine curve \[f\left( x \right) = \sin x\] between \(x = 0\) and \(x = \pi\) to \(3\) decimal places. Estimate the relative percent error of the approximation.
Solution.
The Trapezoidal Rule formula with \(n = 4\) segments is given by
\[{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].\]
Determine the width of each subinterval:
\[\Delta x = \frac{{b - a}}{n} = \frac{{\pi - 0}}{4} = \frac{\pi }{4}.\]
Calculate the values of the sine function:
\[f\left( {{x_0}} \right) = f\left( 0 \right) = \sin 0 = 0;\]
\[f\left( {{x_1}} \right) = f\left( {\frac{\pi }{4}} \right) = \sin \frac{\pi }{4} = \frac{{\sqrt 2 }}{2};\]
\[f\left( {{x_2}} \right) = f\left( {\frac{\pi }{2}} \right) = \sin \frac{\pi }{2} = 1;\]
\[f\left( {{x_3}} \right) = f\left( {\frac{{3\pi }}{4}} \right) = \sin \frac{{3\pi }}{4} = \frac{{\sqrt 2 }}{2};\]
\[f\left( {{x_4}} \right) = f\left( \pi \right) = \sin \pi = 0.\]
Substituting these values, we find the approximate value of the area:
\[A \approx {T_4} = \frac{\pi }{8}\left[ {0 + 2 \cdot \frac{{\sqrt 2 }}{2} + 2 \cdot 1 + 2 \cdot \frac{{\sqrt 2 }}{2} + 0} \right] = \frac{\pi }{8}\left( {2\sqrt 2 + 2} \right) = \frac{\pi }{4}\left( {\sqrt 2 + 1} \right) \approx 1.896\]
Integrating the sine function we get the true solution:
\[\int\limits_0^\pi {f\left( x \right)dx} = \int\limits_0^\pi {\sin xdx} = \left[ { - \cos x} \right]_0^\pi = - \cos \pi + \cos 0 = - \left( { - 1} \right) + 1 = 2.\]
Thus, the relative error is
\[\left| \varepsilon \right| = \frac{{2 - 1.896}}{2} = 0.052 = 5.2\% \]
The answer is
\[A \approx 1.896,\;\left| \varepsilon \right| = 5.2\%\]