We compare all four methods on the same problem: integrating f ( x ) = e x f(x) = e^x f ( x ) = e x over [ 0 , 2 ] [0, 2] [ 0 , 2 ] . The exact value is known analytically, so we can compute a precise relative error for each approximation and observe how accuracy improves as we use more nodes or a higher-degree rule.
Setup
Problem: Approximate ∫ 0 2 e x d x \displaystyle\int_0^2 e^x\,dx ∫ 0 2 e x d x using (i) the basic Trapezoidal Rule, (ii) the Composite Trapezoidal Rule with m = 2 m = 2 m = 2 , (iii) the Composite Trapezoidal Rule with m = 3 m = 3 m = 3 , and (iv) Simpson’s Rule. Compute the relative error for each.
The exact value is:
∫ 0 2 e x d x = [ e x ] 0 2 = e 2 − e 0 = e 2 − 1 ≈ 6.389 \int_0^2 e^x\,dx = \left[e^x\right]_0^2 = e^2 - e^0 = e^2 - 1 \approx 6.389 ∫ 0 2 e x d x = [ e x ] 0 2 = e 2 − e 0 = e 2 − 1 ≈ 6.389
The relative error is defined as:
Relative Error = ∣ Exact − Approximate Exact ∣ × 100 % \text{Relative Error} = \left|\frac{\text{Exact} - \text{Approximate}}{\text{Exact}}\right| \times 100\% Relative Error = Exact Exact − Approximate × 100%
(i) Basic Trapezoidal Rule
Step 1 — Identify parameters
a = 0 , b = 2 , f ( x ) = e x a = 0, \quad b = 2, \quad f(x) = e^x a = 0 , b = 2 , f ( x ) = e x
Step 2 — Evaluate f f f at both endpoints
f ( 0 ) = e 0 = 1 , f ( 2 ) = e 2 ≈ 7.389 f(0) = e^0 = 1, \qquad f(2) = e^2 \approx 7.389 f ( 0 ) = e 0 = 1 , f ( 2 ) = e 2 ≈ 7.389
Step 3 — Apply the Trapezoidal Rule
I 1 = b − a 2 [ f ( a ) + f ( b ) ] = 2 − 0 2 [ f ( 0 ) + f ( 2 ) ] = 1 ⋅ [ 1 + 7.389 ] = 8.389 I_1 = \frac{b - a}{2}\left[f(a) + f(b)\right] = \frac{2 - 0}{2}\left[f(0) + f(2)\right] = 1 \cdot \left[1 + 7.389\right] = \boxed{8.389} I 1 = 2 b − a [ f ( a ) + f ( b ) ] = 2 2 − 0 [ f ( 0 ) + f ( 2 ) ] = 1 ⋅ [ 1 + 7.389 ] = 8.389
Step 4 — Compute the relative error
Relative Error = ∣ 6.389 − 8.389 6.389 ∣ × 100 % ≈ 31.30 % \text{Relative Error} = \left|\frac{6.389 - 8.389}{6.389}\right| \times 100\% \approx 31.30\% Relative Error = 6.389 6.389 − 8.389 × 100% ≈ 31.30%
(ii) Composite Trapezoidal Rule (m = 2 m = 2 m = 2 )
Step 1 — Compute the step size and nodes
h = b − a m = 2 − 0 2 = 1 h = \frac{b - a}{m} = \frac{2 - 0}{2} = 1 h = m b − a = 2 2 − 0 = 1
x 0 = 0 , x 1 = 0 + 1 = 1 , x 2 = 1 + 1 = 2 x_0 = 0, \qquad x_1 = 0 + 1 = 1, \qquad x_2 = 1 + 1 = 2 x 0 = 0 , x 1 = 0 + 1 = 1 , x 2 = 1 + 1 = 2
Step 2 — Evaluate f f f at all nodes
f ( x 0 ) = f ( 0 ) = 1 , f ( x 1 ) = f ( 1 ) = e ≈ 2.718 , f ( x 2 ) = f ( 2 ) = e 2 ≈ 7.389 f(x_0) = f(0) = 1, \qquad f(x_1) = f(1) = e \approx 2.718, \qquad f(x_2) = f(2) = e^2 \approx 7.389 f ( x 0 ) = f ( 0 ) = 1 , f ( x 1 ) = f ( 1 ) = e ≈ 2.718 , f ( x 2 ) = f ( 2 ) = e 2 ≈ 7.389
C 1 , 2 = h 2 [ f ( x 0 ) + 2 f ( x 1 ) + f ( x 2 ) ] = 1 2 [ 1 + 2 ( 2.718 ) + 7.389 ] C_{1,2} = \frac{h}{2}\left[f(x_0) + 2f(x_1) + f(x_2)\right] = \frac{1}{2}\left[1 + 2(2.718) + 7.389\right] C 1 , 2 = 2 h [ f ( x 0 ) + 2 f ( x 1 ) + f ( x 2 ) ] = 2 1 [ 1 + 2 ( 2.718 ) + 7.389 ]
= 1 2 [ 1 + 5.436 + 7.389 ] = 1 2 ( 13.825 ) = 6.913 = \frac{1}{2}\left[1 + 5.436 + 7.389\right] = \frac{1}{2}(13.825) = \boxed{6.913} = 2 1 [ 1 + 5.436 + 7.389 ] = 2 1 ( 13.825 ) = 6.913
Step 4 — Compute the relative error
Relative Error = ∣ 6.389 − 6.913 6.389 ∣ × 100 % ≈ 8.20 % \text{Relative Error} = \left|\frac{6.389 - 6.913}{6.389}\right| \times 100\% \approx 8.20\% Relative Error = 6.389 6.389 − 6.913 × 100% ≈ 8.20%
(iii) Composite Trapezoidal Rule (m = 3 m = 3 m = 3 )
Step 1 — Compute the step size and nodes
h = 2 − 0 3 = 2 3 h = \frac{2 - 0}{3} = \frac{2}{3} h = 3 2 − 0 = 3 2
x 0 = 0 , x 1 = 2 3 , x 2 = 4 3 , x 3 = 2 x_0 = 0, \qquad x_1 = \frac{2}{3}, \qquad x_2 = \frac{4}{3}, \qquad x_3 = 2 x 0 = 0 , x 1 = 3 2 , x 2 = 3 4 , x 3 = 2
Step 2 — Evaluate f f f at all nodes
f ( x 0 ) = e 0 = 1 , f ( x 1 ) = e 2 / 3 ≈ 1.948 f(x_0) = e^0 = 1, \qquad f(x_1) = e^{2/3} \approx 1.948 f ( x 0 ) = e 0 = 1 , f ( x 1 ) = e 2/3 ≈ 1.948
f ( x 2 ) = e 4 / 3 ≈ 3.794 , f ( x 3 ) = e 2 ≈ 7.389 f(x_2) = e^{4/3} \approx 3.794, \qquad f(x_3) = e^2 \approx 7.389 f ( x 2 ) = e 4/3 ≈ 3.794 , f ( x 3 ) = e 2 ≈ 7.389
C 1 , 3 = h 2 [ f ( x 0 ) + 2 f ( x 1 ) + 2 f ( x 2 ) + f ( x 3 ) ] C_{1,3} = \frac{h}{2}\left[f(x_0) + 2f(x_1) + 2f(x_2) + f(x_3)\right] C 1 , 3 = 2 h [ f ( x 0 ) + 2 f ( x 1 ) + 2 f ( x 2 ) + f ( x 3 ) ]
= 2 / 3 2 [ 1 + 2 ( 1.948 ) + 2 ( 3.794 ) + 7.389 ] = \frac{2/3}{2}\left[1 + 2(1.948) + 2(3.794) + 7.389\right] = 2 2/3 [ 1 + 2 ( 1.948 ) + 2 ( 3.794 ) + 7.389 ]
= 1 3 [ 1 + 3.896 + 7.588 + 7.389 ] = 1 3 ( 19.873 ) = 6.624 = \frac{1}{3}\left[1 + 3.896 + 7.588 + 7.389\right] = \frac{1}{3}(19.873) = \boxed{6.624} = 3 1 [ 1 + 3.896 + 7.588 + 7.389 ] = 3 1 ( 19.873 ) = 6.624
Step 4 — Compute the relative error
Relative Error = ∣ 6.389 − 6.624 6.389 ∣ × 100 % ≈ 3.68 % \text{Relative Error} = \left|\frac{6.389 - 6.624}{6.389}\right| \times 100\% \approx 3.68\% Relative Error = 6.389 6.389 − 6.624 × 100% ≈ 3.68%
(iv) Simpson’s Rule
Step 1 — Identify parameters
a = 0 , b = 2 , a + b 2 = 1 a = 0, \qquad b = 2, \qquad \frac{a+b}{2} = 1 a = 0 , b = 2 , 2 a + b = 1
Step 2 — Evaluate f f f at all three nodes
f ( 0 ) = 1 , f ( 1 ) = e ≈ 2.718 , f ( 2 ) = e 2 ≈ 7.389 f(0) = 1, \qquad f(1) = e \approx 2.718, \qquad f(2) = e^2 \approx 7.389 f ( 0 ) = 1 , f ( 1 ) = e ≈ 2.718 , f ( 2 ) = e 2 ≈ 7.389
Step 3 — Apply Simpson’s Rule
I 2 = b − a 6 [ f ( a ) + 4 f ( a + b 2 ) + f ( b ) ] I_2 = \frac{b - a}{6}\left[f(a) + 4f\!\left(\frac{a+b}{2}\right) + f(b)\right] I 2 = 6 b − a [ f ( a ) + 4 f ( 2 a + b ) + f ( b ) ]
= 2 − 0 6 [ f ( 0 ) + 4 f ( 1 ) + f ( 2 ) ] = 1 3 [ 1 + 4 ( 2.718 ) + 7.389 ] = \frac{2 - 0}{6}\left[f(0) + 4f(1) + f(2)\right] = \frac{1}{3}\left[1 + 4(2.718) + 7.389\right] = 6 2 − 0 [ f ( 0 ) + 4 f ( 1 ) + f ( 2 ) ] = 3 1 [ 1 + 4 ( 2.718 ) + 7.389 ]
= 1 3 [ 1 + 10.873 + 7.389 ] = 1 3 ( 19.262 ) = 6.421 = \frac{1}{3}\left[1 + 10.873 + 7.389\right] = \frac{1}{3}(19.262) = \boxed{6.421} = 3 1 [ 1 + 10.873 + 7.389 ] = 3 1 ( 19.262 ) = 6.421
Step 4 — Compute the relative error
Relative Error = ∣ 6.389 − 6.421 6.389 ∣ × 100 % ≈ 0.50 % \text{Relative Error} = \left|\frac{6.389 - 6.421}{6.389}\right| \times 100\% \approx 0.50\% Relative Error = 6.389 6.389 − 6.421 × 100% ≈ 0.50%
Comparison
Method Nodes Approximate Value Relative Error Exact — 6.389 6.389 6.389 0.00 % 0.00\% 0.00% Trapezoidal I 1 I_1 I 1 2 8.389 8.389 8.389 31.30 % 31.30\% 31.30% Composite C 1 , 2 C_{1,2} C 1 , 2 (m = 2 m=2 m = 2 ) 3 6.913 6.913 6.913 8.20 % 8.20\% 8.20% Composite C 1 , 3 C_{1,3} C 1 , 3 (m = 3 m=3 m = 3 ) 4 6.624 6.624 6.624 3.68 % 3.68\% 3.68% Simpson’s I 2 I_2 I 2 3 6.421 6.421 6.421 0.50 % 0.50\% 0.50%
Note
Three observations stand out from this table. First, increasing m m m in the Composite Trapezoidal Rule steadily reduces the error: going from m = 2 m=2 m = 2 to m = 3 m=3 m = 3 roughly halves the error from 8.20% to 3.68%, consistent with the O ( h 2 ) O(h^2) O ( h 2 ) convergence rate. Second, Simpson’s Rule uses the same three nodes as the Composite Trapezoidal Rule with m = 2 m=2 m = 2 , yet its relative error is 0.50% versus 8.20%, a more than 16-fold improvement from using a parabola instead of a line. Third, even the single-trapezoid rule (I 1 I_1 I 1 ) provides a rough estimate quickly, which is useful for sanity-checking or as a starting point before applying more refined methods.