MTH 343 · 4.4 Composite quadrature rules

Composite Quadrature Rules Lab

Split [a, b] into n subintervals of width h = (b − a)/n. The composite trapezoidal rule puts a line segment on each subinterval; the composite Simpson's rule puts a parabola on each pair of subintervals. Compare the errors of both rules, and find the n that guarantees a target error.

f(x) =

Use x as the variable. You can write + − * / ^, sin, cos, tan, exp, ln (or log), sqrt, abs, pi, e.

eˣ on [0, 4] and sin x on [0, π] are the exercises on slides 4 and 9. Simpson's rule is exact for x³. For the periodic e^sin x the trapezoidal rule beats its error bound by far. For √x, f′ (and so f″) is unbounded: no error bound.

Interval [a, b]

Numbers or expressions such as pi/2 or sqrt(2), or drag the a and b handles on the plot.

Composite rule

The plot and the formula follow this choice.

Exact value —
Composite trapezoidal — Absolute error —
Composite Simpson's — Absolute error —

Area under f on [a, b]

  • f(x)
  • Parabolas
  • Area under the parabolas
  • Nodes
Shade

Choose n for a target error

|error| <

Type 0.00002, 2e-5 or 10^-6.

As in the exercise on slide 9: make the error bound of each rule smaller than the target and solve for n. The lab also finds the n the actual error needs, which is usually smaller: the error bound uses the largest value of |f″| or |f⁽⁴⁾| on all of [a, b]. This part uses the function and the interval chosen above, for both rules; the n and the rule chosen above do not matter here.

Error as n grows

  • Trapezoidal error
  • Simpson's error
  • Trapezoidal error bound
  • Simpson's error bound
  • Target

Doubling n

Both rules for n = 1, 2, 4, …, 1024 (each doubling halves h), and for your n. The ratio is the error for n/2 divided by the error for n. Click an n to select it.