On this page
Some integrals have no antiderivative you can write down, and some functions arrive only as a table of readings. The trapezoidal rule and Simpson's rule turn both into a short weighted sum. Below: the formulas, a worked example checked against π/4, and what halving the step h does to the error.
How do you use the trapezoidal rule?
Split [a, b] into n strips of equal width h = (b − a)/n and call the function values at the strip edges y0, y1, ..., yn. Join neighbouring points on the curve with straight lines, so each strip becomes a trapezium of area h × (left side + right side)/2. Add the strips and you get the composite trapezoidal rule, as stated in OpenStax Calculus Volume 2, section 3.6:
T = (h/2)[y0 + 2y1 + 2y2 + ... + 2y(n−1) + yn]
The two end values count once; every inside value counts twice, because two trapezia share it. The same OpenStax section shows that the trapezoidal rule is the average of the left-endpoint and right-endpoint Riemann sums.
What is Simpson's rule, and why must n be even?
Simpson's rule swaps straight chords for curves: it passes a parabola through three neighbouring points and integrates the parabola instead of the function. Over one pair of strips that gives (h/3)(y0 + 4y1 + y2). Chain the pairs together and the composite rule is:
S = (h/3)[y0 + 4y1 + 2y2 + 4y3 + ... + 2y(n−2) + 4y(n−1) + yn]
OpenStax states it for n a positive even integer, because each parabola needs two strips. Wikipedia's article on Simpson's rule notes that it gives exact results for any polynomial of degree three or less. The rule is named after Thomas Simpson (1710–1761), though Johannes Kepler derived it in 1615, according to the same article.
Worked example: ∫ from 0 to 1 of 1/(1 + x²)
This integral is a good test because you know the answer. The antiderivative is tan⁻¹ x, so the exact value is tan⁻¹ 1 − tan⁻¹ 0 = π/4 ≈ 0.785398, and four times any estimate is an estimate of π. Using the OpenStax formulas with h = 0.25 needs five values:
y(0) = 1
y(0.25) = 16/17 ≈ 0.941176
y(0.5) = 0.8
y(0.75) = 0.64
y(1) = 0.5
Here are the four estimates (error = estimate − π/4):
Trapezoidal, h = 0.5: 0.25 × (1 + 2 × 0.8 + 0.5) = 0.775, error −0.010398.
Trapezoidal, h = 0.25: 0.125 × (1 + 2 × (0.941176 + 0.8 + 0.64) + 0.5) ≈ 0.782794, error −0.002604.
Simpson, h = 0.5: (0.5/3) × (1 + 4 × 0.8 + 0.5) = 4.7/6 ≈ 0.783333, error −0.002065.
Simpson, h = 0.25: (0.25/3) × (1 + 4 × 0.941176 + 2 × 0.8 + 4 × 0.64 + 0.5) ≈ 0.785392, error −0.000006.
A shortcut: OpenStax writes Simpson's rule as S(2n) = (2/3)M(n) + (1/3)T(n), with M the midpoint rule. Since T(2n) averages T(n) and M(n), S(2n) = (4T(2n) − T(n))/3. Check: (4 × 0.782794 − 0.775)/3 ≈ 0.785392, line 4 again.
How does the error shrink when you halve h?
The error bounds in OpenStax section 3.6 are:
Trapezoidal: error ≤ M(b − a)³/(12n²), where M is the largest value of |f″| on [a, b].
Simpson: error ≤ M(b − a)⁵/(180n⁴), where M is the largest value of |f⁗| on [a, b].
Because n = (b − a)/h, the first bound is proportional to h² and the second to h⁴. Halve h and the trapezoidal bound falls by a factor of 4, Simpson's by a factor of 16.
Our example follows this. Adding h = 0.125, the trapezoidal error runs −0.010398, −0.002604, −0.000651: a factor of 4 each time. Simpson's runs −0.002065, −0.000006, about −0.00000004, even faster than 16; a bound is a ceiling, not a forecast. Four times the Simpson estimate at h = 0.125 is 3.1415925, against π ≈ 3.1415927.
A checklist before you write the final answer
Count values: n strips need n + 1 function values. For Simpson, n must be even, so the number of values is odd.
Keep six decimals in every y value and round only at the end.
Check the weights: with f = 1 every rule must return b − a. Trapezoidal weights 1, 2, ..., 2, 1 add to 2n; Simpson's 1, 4, 2, ..., 4, 1 add to 3n.
When a step like this goes wrong, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer. If Riemann sums or the definite integral itself feel shaky, the Fermi Concept Library gives each mathematics concept its own lesson and its place in the map.
Your next step: estimate ∫ from 0 to 1 of e^(−x²) with h = 0.25 both ways, then halve h and watch how much each answer still moves.



