Function & Bounds
Use x as variable. Supports: sin, cos, tan, exp, ln, log, sqrt, abs, pi, e
100
Methods
Method Comparison
Function Plot
Step-by-Step (Trapezoidal Rule)
Trapezoidal Formula
Formula∫ ≈ (h/2)[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]

Trapezoidal Rule Explained

The Trapezoidal Rule approximates the area under a curve by dividing the interval [a, b] into n equal sub-intervals and connecting adjacent points on the curve with straight lines, forming trapezoids. The area of each trapezoid is averaged between its two heights and multiplied by the width h = (b − a)/n.

The composite formula is:

∫[a→b] f(x) dx ≈ (h/2) [f(x₀) + 2f(x₁) + 2f(x₂) + … + 2f(xₙ₋₁) + f(xₙ)]

The global error is O(h²): halving the interval width reduces the error by a factor of 4. The rule is exact for linear functions.

Simpson's Rule — Why It's More Accurate

Simpson's Rule fits a quadratic (parabola) through every three consecutive points rather than a straight line. Because it captures curvature, the error order jumps to O(h⁴) — halving h reduces the error by a factor of 16.

∫[a→b] f(x) dx ≈ (h/3) [f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + 4f(xₙ₋₁) + f(xₙ)]

Note the alternating 4, 2, 4, 2, … pattern of coefficients (except for the endpoints which have coefficient 1). Simpson's Rule requires n to be even.

It is exact for polynomials of degree 3 or less, which is why it dramatically outperforms the Trapezoidal Rule on smooth functions.

Choosing the Number of Intervals

The appropriate number of intervals n depends on the smoothness of f(x) and the accuracy required:

A practical strategy is Richardson extrapolation: compute the integral with n and 2n intervals. If the results agree to the required decimal places, convergence has been achieved.

Frequently Asked Questions
Numerical integration (quadrature) is the process of approximating a definite integral when an analytic antiderivative is hard or impossible to find. Methods like Simpson's Rule, the Trapezoidal Rule and the Midpoint Rule divide the interval into subintervals and approximate the area under the curve using simple geometric shapes.
Simpson's Rule is generally the most accurate of the three methods here. It achieves O(h⁴) error compared to O(h²) for the Trapezoidal and Midpoint Rules. This is because Simpson's Rule fits a parabola through three points per sub-interval rather than a straight line.
For smooth functions, even n = 10 intervals gives good results with Simpson's Rule. A common rule of thumb is to double n until the result stabilises to the desired number of decimal places. For functions with sharp peaks or discontinuities, a larger n (100–1000) may be necessary.
The global error of the Trapezoidal Rule is proportional to h² (where h = (b−a)/n), giving error ≈ −(b−a)h²f''(ξ)/12 for some ξ in [a, b]. Halving the step size h reduces the error by a factor of 4. Simpson's Rule has O(h⁴) error, meaning halving h reduces the error by a factor of 16.