Numerical Quadrature and Error Bounds

Compute trapezoidal and Simpson approximations and interpret their smoothness-dependent error bounds.

Builds on Improper Integrals and Convergence

The bigger question: When is an integral meaningful, and when is an estimate reliable?

On this page

Approximate a function locally

With nn equal subintervals, h=(b−a)/nh=(b-a)/n and xi=a+ihx_i=a+ih, the composite trapezoidal rule joins neighboring samples by straight lines:

Tn=h[f(x0)+f(xn)2+∑i=1n−1f(xi)].T_n=h\left[\frac{f(x_0)+f(x_n)}2+\sum_{i=1}^{n-1}f(x_i)\right].

Composite Simpson's rule fits quadratics across pairs of subintervals. It requires even nn:

Sn=h3[f(x0)+f(xn)+4∑i oddf(xi)+2∑i even0<i<nf(xi)].S_n=\frac h3\left[f(x_0)+f(x_n)+4\sum_{i\text{ odd}}f(x_i)+2\sum_{\substack{i\text{ even}\\0<i<n}}f(x_i)\right].

Samples must correspond to the same equally spaced grid. An odd interval count or inconsistent spacing invalidates these composite Simpson weights.

Visual guide

VISUAL GUIDETrapezoids overestimate this convex curve
For x² on [0, 2], straight chords lie above the curve. Two trapezoids of width 1 give area 3; the exact integral is 8/3. Convexity explains the error direction for this example.000.5751.131.152.251.723.382.34.5xy
  • x²
  • Trapezoid tops
For x² on [0, 2], straight chords lie above the curve. Two trapezoids of width 1 give area 3; the exact integral is 8/3. Convexity explains the error direction for this example.

Worked example: a known integral

For f(x)=x2f(x)=x^2 on [0,2][0,2] and n=2n=2, samples are 0,1,40,1,4 and h=1h=1. Thus T2=(0+4)/2+1=3T_2=(0+4)/2+1=3, while S2=(0+4⋅1+4)/3=8/3S_2=(0+4\cdot1+4)/3=8/3. The exact integral is 8/38/3. Simpson is exact here because it integrates polynomials of degree at most three exactly; trapezoids overestimate this convex function.

PAUSE & THINKA quick check, not a grade

Try it yourself.

Choose an answer and explain your reasoning to yourself. Use a hint if you get stuck.

On [0,2], one trapezoid uses endpoint heights f(0)=1 and f(2)=5. What is its estimate?

Hint 1 · Find a starting point

A trapezoid has width times average endpoint height.

Hint 2 · Take the next step

The width is 2 and average height is (1+5)/2.

Show the reasoning

Answer: 6

2×3=6. Its accuracy still depends on the curve between the endpoints.

Before moving on: what would make one of the other answers wrong? Saying why is part of understanding.

Worked example: choosing resolution

If ∣f′′∣≤M2|f''|\le M_2 on [a,b][a,b], then ∣I−Tn∣≤M2(b−a)3/(12n2)|I-T_n|\le M_2(b-a)^3/(12n^2). For f=exf=e^x on [0,1][0,1], use M2=eM_2=e. To guarantee error below 0.0010.001, require e/(12n2)<0.001e/(12n^2)<0.001, so n=16n=16 suffices. This is a sufficient bound, not a claim that 1515 necessarily fails in practice.

If ff has a continuous fourth derivative bounded by M4M_4, Simpson's error satisfies ∣I−Sn∣≤M4(b−a)5/(180n4)|I-S_n|\le M_4(b-a)^5/(180n^4). These guarantees depend on derivatives being bounded over the entire interval. They do not apply unchanged to a singular integrand such as 1/x1/\sqrt x on [0,1][0,1].

Practice

  1. Compute T2T_2 for f(x)=xf(x)=x on [0,2][0,2].
  2. Compute S2S_2 for x3x^3 on [0,2][0,2].
  3. What happens to the stated trapezoidal error bound when nn doubles?
Show worked solutions
  1. Samples 0,1,20,1,2 give T2=2T_2=2, exactly the integral.
  2. Samples 0,1,80,1,8 give S2=(0+4+8)/3=4S_2=(0+4+8)/3=4, exactly the integral.
  3. It becomes one quarter as large. The actual error may behave better, including being zero for a linear function.
MAKE IT YOURS

Pause before the next idea.

Can you explain how the visualization connects to this lesson’s goal? If a step still feels uncertain, put this lesson on your review list and try the check again another day.

Optional marks, not a grade. Saved in this browser only. Open notebook →