Numerical Methods · Module 8 of 10
Numerical Integration
An integral is an area, and when the function has no antiderivative, you approximate that area with simple shapes. Trapezoids are the first cut; Simpson's parabolas are far more accurate for the same number of points.
Readiness check
This module approximates integrals. Tick only what you can do closed-notes.
- Recall a definite integral as an area under a curve.
- Find the area of a trapezoid.
- Evaluate a function at evenly spaced points.
- Recall the order O(hn) of an error.
- Recall that a parabola fits three points.
The core idea
Numerical integration approximates the area under a curve by fitting simple polynomials over strips and summing them. The trapezoidal rule uses straight tops; Simpson's rule uses parabolas and is exact for cubics.
trapezoidal: I = h(f0 + 2Σf + fn)/2Simpson 1/3: I = h(f0 + 4f1 + f2)/3error: trapezoid O(h2), Simpson O(h4)The definite integral is the area under f(x) between two limits. When f has no closed-form antiderivative, or is known only as data, numerical integration estimates that area. The Newton-Cotes formulas do it by replacing f over each strip with an interpolating polynomial whose area is easy. The trapezoidal rule uses a straight line across each strip, summing trapezoids; its error falls as h2, so halving the strip width quarters the error. Simpson's 1/3 rule fits a parabola over each pair of strips, and because a parabola captures curvature, it is dramatically more accurate, exact for any cubic, with error falling as h4. Applying either rule across many strips, the composite form, drives the error down as the spacing shrinks. The same number of function evaluations buys far more accuracy with Simpson than with trapezoids.
The skills, taught in order
Five skills build the Newton-Cotes rules, their composite forms, and their error orders.
8.1 Newton-Cotes formulas
The Newton-Cotes family integrates by replacing f with an interpolating polynomial over evenly spaced points and integrating that exactly. A first-order fit gives the trapezoidal rule, a second-order fit gives Simpson's 1/3 rule, and so on up the orders.
8.2 The trapezoidal rule
The single-application trapezoidal rule approximates the area as a trapezoid: I = (b − a)(f(a) + f(b))/2. It is exact only for straight lines, so a curved function leaves an error that depends on the second derivative.
| Rule | Fits | Exact for | Error |
|---|---|---|---|
| Trapezoidal | a straight line | linear | O(h2) |
| Simpson's 1/3 | a parabola | up to cubic | O(h4) |
| Simpson's 3/8 | a cubic | up to cubic | O(h4) |
Higher-order rules fit higher-order polynomials and are exact for more curved functions, with steeply smaller error.
8.3 Simpson's 1/3 rule
Simpson's 1/3 rule fits a parabola through three equally spaced points: I = h(f0 + 4f1 + f2)/3, with h the strip width. The middle point is weighted four times. Remarkably, it integrates cubics exactly, despite using only a parabola.
8.4 Composite rules
Applying a rule over many strips and summing gives the composite form: the composite trapezoidal rule sums interior ordinates with weight two, and composite Simpson alternates weights four and two. More strips, smaller h, mean less error. Simpson's 1/3 needs an even number of strips.
8.5 Integration error
The trapezoidal error scales as h2 and Simpson's as h4, so halving h cuts the trapezoidal error to a quarter but Simpson's to a sixteenth. This steep gain is why Simpson is the default for smooth functions.
Engineering connection: integrating a measured pressure, a velocity profile, or a load distribution to get force or flow rate is exactly this area calculation.
Worked example 1: the composite trapezoidal rule
Estimate the integral of f(x) = x3 from 0 to 2 with the composite trapezoidal rule using four strips (h = 0.5). The exact value is 4.
- ProblemEstimate the integral of x3 on [0, 2] by four trapezoids, as in Figure 1.
- Given / findf(x) = x3, a = 0, b = 2, n = 4, h = 0.5. Find I and the error.
- AssumptionsEvenly spaced points; the function is smooth over the interval.
- ModelI = (h/2)[f0 + 2(f1 + f2 + f3) + f4].
- Equationsx = 0, 0.5, 1, 1.5, 2f = 0, 0.125, 1, 3.375, 8
- SolveI = (0.5/2)[0 + 2(0.125 + 1 + 3.375) + 8] = 0.25[2(4.5) + 8] = 0.25[9 + 8] = 0.25 × 17 = 4.25. Error = |4 − 4.25|/4 = 6.25%.
- CheckThe estimate exceeds the true value because x3 is concave up, so the straight trapezoid tops lie above the curve. Doubling the strips would cut the error to about a quarter.
- ConclusionFour trapezoids give 4.25, a 6 percent overestimate. The trapezoidal rule is simple but only second-order accurate.
Worked example 2: Simpson's 1/3 rule
Estimate the same integral of f(x) = x3 from 0 to 2 with Simpson's 1/3 rule using two strips (h = 1), and compare with the trapezoidal result.
- ProblemEstimate the integral of x3 on [0, 2] by Simpson's 1/3 rule, as in Figure 2.
- Given / findf(x) = x3, a = 0, b = 2, n = 2, h = 1. Find I and the error.
- AssumptionsTwo equal strips, so the three points are evenly spaced for the 1/3 rule.
- ModelI = (h/3)[f0 + 4f1 + f2].
- Equationsx = 0, 1, 2; f = 0, 1, 8I = (h/3)(f0 + 4f1 + f2)
- SolveI = (1/3)[0 + 4(1) + 8] = (1/3)(12) = 4.000. Error = 0%.
- CheckSimpson's 1/3 rule is exact for any cubic, so x3 integrates with zero error, while the trapezoidal rule, with twice as many strips, was 6 percent high.
- ConclusionSimpson's rule reaches the exact answer with fewer points than the trapezoidal rule needed for a poor one. Fitting curvature pays off steeply.
Misconceptions and diagnostics
| Mistake | Symptom | Diagnostic question | Correction |
|---|---|---|---|
| Odd strips with Simpson's 1/3 | Rule cannot be applied cleanly | "Is the number of strips even?" | Simpson's 1/3 needs an even number of strips. |
| Wrong composite weights | Interior points weighted as endpoints | "Did I weight interior ordinates correctly?" | Trapezoid weights interior 2; Simpson alternates 4 and 2. |
| Ignoring the error order | Trapezoid used where accuracy matters | "Is O(h2) enough here?" | Use Simpson for O(h4) on smooth functions. |
| Integrating non-smooth data crudely | Large error at a kink | "Is the function smooth?" | Split the interval at discontinuities or kinks. |
Practice ladder
Use one trapezoid to estimate the integral of f(x) = x2 from 0 to 2.
Show answer
I = (2)(f(0) + f(2))/2 = (2)(0 + 4)/2 = 4. The true value is 8/3 = 2.667, so this is a large overestimate.
Now use Simpson's 1/3 rule with two strips (h = 1) on that integral.
Show answer
I = (1/3)[f(0) + 4f(1) + f(2)] = (1/3)[0 + 4 + 4] = 8/3 = 2.667, exact, since Simpson integrates quadratics exactly.
Apply the composite trapezoidal rule with two strips (h = 1) to the integral of x2 from 0 to 2.
Show answer
I = (1/2)[f(0) + 2f(1) + f(2)] = 0.5[0 + 2(1) + 4] = 0.5(6) = 3. Closer to 2.667 than the single trapezoid, but still high.
You must integrate a smooth measured pressure profile to get a force. Argue which rule to use and how to check the result has converged.
What good work looks like
Use composite Simpson's 1/3 for its O(h4) accuracy on a smooth profile; confirm convergence by halving the spacing and checking the result changes negligibly, the integration analogue of a mesh-refinement check.
Working with AI, and proving it yourself
Use AI as an examiner, not a solver
Portfolio task
Integrate a real function or data set by both the trapezoidal and Simpson rules, compare to a known value, and show the error shrinking as you halve the spacing.
Retrieval and spaced review
Closed notes. Answer out loud, then reveal.
1. What shape does the trapezoidal rule fit?
A straight line across each strip, exact only for linear functions.
2. Write Simpson's 1/3 rule.
I = (h/3)(f0 + 4f1 + f2) over two strips.
3. What is Simpson's 1/3 exact for?
Polynomials up to and including cubics.
4. Give the error orders.
Trapezoidal O(h2), Simpson O(h4).
5. What does Simpson's 1/3 require of the strips?
An even number of strips.
Textbook mapping
This module follows Chapra and Canale, Numerical Methods for Engineers, 7th edition. Use these references to read further.
| Topic in this module | Where to read more |
|---|---|
| Newton-Cotes and the trapezoidal rule | Chapra & Canale, Chapter 21 |
| Simpson's rules | Chapra & Canale, Chapter 21 |
| Composite rules and integration error | Chapra & Canale, Chapter 21 |
Chapter numbers refer to the 7th edition. The Newton-Cotes rules are standard, so any recent edition will align closely.