Learn Without Walls
← Module 8 Home Lesson 4 of 4 Practice Problems →

Lesson 4: Numerical Integration

Estimated time: 35 to 45 minutes

Learning Objectives

By the end of this lesson, you will be able to:

Why Numerical Integration?

Many important integrals cannot be expressed in terms of elementary functions. Examples include ∫ e−x² dx (the Gaussian integral), ∫ sin(x²) dx, and ∫ √(1 + x4) dx. For these, we need numerical methods to approximate the value.

Even when an antiderivative exists, numerical methods can be faster for one time computations or when the integrand is given as a table of data points.

The Trapezoidal Rule

Instead of approximating the area with rectangles (Riemann sums), the Trapezoidal Rule uses trapezoids, which fit the curve more closely.

Trapezoidal Rule

With n subintervals and Δx = (b − a)/n:

Tn = (Δx/2)[f(x0) + 2f(x1) + 2f(x2) + ... + 2f(xn−1) + f(xn)]

Note the pattern: first and last values get weight 1; all interior values get weight 2.

Example 1: Trapezoidal Rule

Approximate ∫02 e−x² dx with n = 4.

Step 1: Δx = 2/4 = 0.5. Points: x0=0, x1=0.5, x2=1, x3=1.5, x4=2.

Step 2: Evaluate: f(0) = 1, f(0.5) = 0.7788, f(1) = 0.3679, f(1.5) = 0.1054, f(2) = 0.0183.

Step 3: T4 = (0.5/2)[1 + 2(0.7788) + 2(0.3679) + 2(0.1054) + 0.0183]

= 0.25[1 + 1.5576 + 0.7358 + 0.2108 + 0.0183] = 0.25(3.5225) ≈ 0.8806.

Simpson's Rule

Simpson's Rule approximates the integrand with parabolas instead of straight lines, yielding much better accuracy. It requires n to be even.

Simpson's Rule

With n subintervals (n even) and Δx = (b − a)/n:

Sn = (Δx/3)[f(x0) + 4f(x1) + 2f(x2) + 4f(x3) + 2f(x4) + ... + 4f(xn−1) + f(xn)]

Pattern: 1, 4, 2, 4, 2, ..., 4, 1.

Example 2: Simpson's Rule

Approximate ∫02 e−x² dx with n = 4 (same as Example 1).

S4 = (0.5/3)[1 + 4(0.7788) + 2(0.3679) + 4(0.1054) + 0.0183]

= (1/6)[1 + 3.1152 + 0.7358 + 0.4216 + 0.0183] = (1/6)(5.2909) ≈ 0.8818.

(The true value is approximately 0.8821. Simpson's is already very close with just n = 4!)

Error Bounds

Error Bound for Trapezoidal Rule

|ET| ≤ M(b − a)³ / (12n²), where M = max |f''(x)| on [a, b].

Error decreases as O(1/n²): doubling n cuts the error by 4.

Error Bound for Simpson's Rule

|ES| ≤ K(b − a)5 / (180n4), where K = max |f(4)(x)| on [a, b].

Error decreases as O(1/n4): doubling n cuts the error by 16!

Example 3: Comparing Accuracy

For ∫01 x³ dx (exact answer = 1/4), compare T4 and S4.

Δx = 0.25. Points: 0, 0.25, 0.5, 0.75, 1. Values: 0, 0.0156, 0.125, 0.4219, 1.

T4 = (0.25/2)[0 + 2(0.0156) + 2(0.125) + 2(0.4219) + 1] = 0.125(2.1250) = 0.2656. Error: 0.0156.

S4 = (0.25/3)[0 + 4(0.0156) + 2(0.125) + 4(0.4219) + 1] = (1/12)(3.0000) = 0.2500. Error: 0!

Simpson's Rule gives the exact answer for cubics (because f(4) = 0 for polynomials of degree 3 or less).

Working with Data Tables

Numerical methods are essential when you only have data points (no formula).

Example 4: From a Data Table

Estimate ∫06 f(x) dx using Simpson's Rule given:

x0123456
f(x)3546752

n = 6 (even), Δx = 1.

S6 = (1/3)[3 + 4(5) + 2(4) + 4(6) + 2(7) + 4(5) + 2] = (1/3)[3 + 20 + 8 + 24 + 14 + 20 + 2] = 91/3 ≈ 30.33.

Comparison and Guidelines

MethodAccuracyRequirementBest For
TrapezoidalO(1/n²)Any nQuick estimates, odd n
Simpson'sO(1/n4)n must be evenBest accuracy per function evaluation

Rule of thumb: Simpson's Rule with n = 10 often matches the Trapezoidal Rule with n = 100 in terms of accuracy.

Key Takeaways

Check Your Understanding

1. Use the Trapezoidal Rule with n = 4 to approximate ∫13 (1/x) dx.

Answer: Δx = 0.5. Points: 1, 1.5, 2, 2.5, 3. Values: 1, 0.667, 0.5, 0.4, 0.333. T4 = 0.25[1 + 2(0.667) + 2(0.5) + 2(0.4) + 0.333] = 0.25(4.467) ≈ 1.117. (Exact: ln 3 ≈ 1.099.)

2. Use Simpson's Rule with n = 4 for the same integral.

Answer: S4 = (0.5/3)[1 + 4(0.667) + 2(0.5) + 4(0.4) + 0.333] = (1/6)[1 + 2.667 + 1 + 1.6 + 0.333] = (1/6)(6.600) = 1.100. Much closer to ln 3!

3. If you need the Trapezoidal Rule error to be less than 0.001 for ∫01 ex dx, how many subintervals do you need?

Answer: f''(x) = ex, max on [0,1] is e. Error ≤ e(1)³/(12n²) < 0.001. n² > e/0.012 ≈ 226.5. n > 15.05, so n = 16.

Ready for More?

Practice Problems

Test all your integration techniques with 10 problems.

Practice Problems

Module Home

You have completed all 4 lessons in Module 8!

Back to Module Home