← All Tools

∫ Numerical Integration Playground

Approximate ∫ₐᵇ f(x) dx with six classic quadrature rules — Left / Right Riemann, Midpoint, Trapezoid, Simpson's 1/3, and Simpson's 3/8 — then watch each rule's error shrink as you double the panel count. The plot shows the actual rectangles, trapezoids, or parabolic strips being summed.

Function & interval

sin, 0→π, exact=2 x², 0→1, 1/3 e^(-x²), −2→2 1/(1+x²), 0→1, π/4 √(1−x²), −1→1, π/2 ln x, 1→e, 1 cos²x, 0→π, π/2 1/x, 1→2, ln 2

All six methods

Approximation (selected method)
Signed error vs exact
MethodResult|Error|Order

Simpson's 1/3 needs even n; Simpson's 3/8 needs n divisible by 3. The row for the currently selected method is highlighted.

Error convergence — |error| vs n

Left Right Midpoint Trapezoid Simpson 1/3 Simpson 3/8

Log-log axes. The slope of each line is the empirical order of convergence — −1 for Left/Right, −2 for Midpoint and Trapezoid, −4 for both Simpson rules on smooth integrands. Requires an exact reference value.

The rules

Left / Right Riemann. Sample f at the left (or right) endpoint of each of n equal-width panels, sum the rectangle areas. Error O(h) where h = (b−a)/n.

Midpoint. Sample at each panel's midpoint. Second-order accurate — error O(h²) — and often the best of the low-order rules for smooth f.

Trapezoid. Replace each panel by the trapezoid joining the two endpoints. Also O(h²), but the midpoint rule beats it by a factor of two on convex or concave f.

Simpson's 1/3. Fit a parabola through every triple of consecutive samples (needs even n). Exact for cubics, O(h⁴) on smooth f. Coefficients 1 4 2 4 2 … 4 1.

Simpson's 3/8. Fit a cubic through every quadruple of consecutive samples (needs n divisible by 3). Also O(h⁴). Coefficients 1 3 3 2 3 3 2 … 3 3 1.

Supported operators: + − * / ^ and functions sin cos tan asin acos atan sinh cosh tanh exp log log2 log10 sqrt cbrt abs sign floor ceil round. Constants pi and e. Use x as the variable.