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.

01

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.
0 or 1 weak itemsContinue with this module.
2 weak itemsRefresh integrals in Mathematics, Module 5.
3 or more weak itemsReview interpolation, the basis of these rules, in Module 7.
02

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 skill works when: you pick a rule, apply it across the strips, and know its error order.
The skill breaks down when: Simpson's 1/3 is used with an odd number of strips, or the error order is forgotten.
The concept. Numerical integration slices the area into strips and approximates each with a simple shape. Straight tops give the trapezoidal rule; fitting parabolas across strip pairs gives Simpson's far more accurate rule.
03

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.

RuleFitsExact forError
Trapezoidala straight linelinearO(h2)
Simpson's 1/3a parabolaup to cubicO(h4)
Simpson's 3/8a cubicup to cubicO(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.

04

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.

Figure 1. Four trapezoids over the cubic overestimate the area slightly, since straight tops cut across the concave-up curve. The result is 4.25 against the true 4.
  1. ProblemEstimate the integral of x3 on [0, 2] by four trapezoids, as in Figure 1.
  2. Given / findf(x) = x3, a = 0, b = 2, n = 4, h = 0.5. Find I and the error.
  3. AssumptionsEvenly spaced points; the function is smooth over the interval.
  4. ModelI = (h/2)[f0 + 2(f1 + f2 + f3) + f4].
  5. Equationsx = 0, 0.5, 1, 1.5, 2f = 0, 0.125, 1, 3.375, 8
  6. 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%.
  7. 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.
  8. ConclusionFour trapezoids give 4.25, a 6 percent overestimate. The trapezoidal rule is simple but only second-order accurate.
Result. I = 4.25 (true 4, error 6.25%).
05

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.

Figure 2. A single parabola over the two strips reproduces the cubic's area exactly. Simpson's 1/3 rule gives 4.000 against the trapezoidal 4.25, with no error.
  1. ProblemEstimate the integral of x3 on [0, 2] by Simpson's 1/3 rule, as in Figure 2.
  2. Given / findf(x) = x3, a = 0, b = 2, n = 2, h = 1. Find I and the error.
  3. AssumptionsTwo equal strips, so the three points are evenly spaced for the 1/3 rule.
  4. ModelI = (h/3)[f0 + 4f1 + f2].
  5. Equationsx = 0, 1, 2; f = 0, 1, 8I = (h/3)(f0 + 4f1 + f2)
  6. SolveI = (1/3)[0 + 4(1) + 8] = (1/3)(12) = 4.000. Error = 0%.
  7. 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.
  8. ConclusionSimpson's rule reaches the exact answer with fewer points than the trapezoidal rule needed for a poor one. Fitting curvature pays off steeply.
Result. I = 4.000, exact, versus the trapezoidal 4.25.
06

Misconceptions and diagnostics

MistakeSymptomDiagnostic questionCorrection
Odd strips with Simpson's 1/3Rule cannot be applied cleanly"Is the number of strips even?"Simpson's 1/3 needs an even number of strips.
Wrong composite weightsInterior points weighted as endpoints"Did I weight interior ordinates correctly?"Trapezoid weights interior 2; Simpson alternates 4 and 2.
Ignoring the error orderTrapezoid used where accuracy matters"Is O(h2) enough here?"Use Simpson for O(h4) on smooth functions.
Integrating non-smooth data crudelyLarge error at a kink"Is the function smooth?"Split the interval at discontinuities or kinks.
07

Practice ladder

Level 1 · Direct skill

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.

Level 2 · Mixed concept

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.

Level 3 · Independent problem

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.

Transfer task | Real engineering

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.

08

Working with AI, and proving it yourself

Use AI as an examiner, not a solver

"Check that my Simpson weights alternate 4 and 2 correctly."
"Give me three integrals; I will pick a rule and strip count for each."
"Integrate this for me." Applying the rule yourself is the skill.
"Which rule is best?" Reasoning from the error order is the point.

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.

Must include: both estimates, an error comparison, and a refinement showing convergence.
09

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.

TodayFinish this quiz and Levels 1 and 2 of the ladder.
+1 dayRe-derive both estimates of the cubic integral.
+3 daysIntegrate three new functions by both rules.
+7 daysTurn from integrals to derivatives, Module 9.
+30 daysReuse Simpson's rule to integrate measured test data.
10

Textbook mapping

This module follows Chapra and Canale, Numerical Methods for Engineers, 7th edition. Use these references to read further.

Topic in this moduleWhere to read more
Newton-Cotes and the trapezoidal ruleChapra & Canale, Chapter 21
Simpson's rulesChapra & Canale, Chapter 21
Composite rules and integration errorChapra & Canale, Chapter 21

Chapter numbers refer to the 7th edition. The Newton-Cotes rules are standard, so any recent edition will align closely.