Numerical Integration

Integrate f(x) over [a,b] with trapezoidal or Simpson's rule.

Open tool

Overview

The Numerical Integration tool estimates the definite integral of a function f(x) over a chosen interval [a, b] using either the trapezoidal rule or Simpson's rule. Type an expression in x, pick an interval and a step count and read off the approximate area under the curve.

It is useful for engineering students checking calculus homework, physicists integrating non-elementary functions and developers prototyping signal-processing math. When the antiderivative is ugly or non-existent, numerical methods are the only realistic path.

How it works

Divide [a, b] into n subintervals of width h = (b - a) / n. The trapezoidal rule approximates the integral as T = h * (f(a) / 2 + Σ f(a + i*h) + f(b) / 2). It is exact for linear functions and converges as O(h²).

Simpson's rule fits parabolas through triples of points: S = (h / 3) * (f(a) + 4 * Σ f(a + i*h) (odd i) + 2 * Σ f(a + i*h) (even i) + f(b)). It is exact for polynomials up to degree 3 and converges as O(h⁴), so it usually needs many fewer steps to reach a given accuracy.

Examples

∫_0^1 x^2 dx, Simpson's, n=10  →  ≈ 0.3333 (exact 1/3)
∫_0^π sin(x) dx, trapezoidal, n=100  →  ≈ 2.0000 (exact 2)
∫_0^1 e^x dx, Simpson's, n=20  →  ≈ 1.71828 (exact e - 1)
∫_-1^1 1 / (1 + x^2) dx, Simpson's, n=100  →  ≈ 1.5708 (exact π/2)

FAQ

Which method should I pick?

Simpson's rule is more accurate per step for smooth functions. Use trapezoidal when the integrand has corners or jumps that defeat parabolic fitting.

Why does Simpson's need an even number of intervals?

It groups points in triples, so the count of subintervals must be even. The tool adjusts automatically if you pass an odd number.

What if the integrand is unbounded near an endpoint?

Both rules struggle with improper integrals. Substitute or use an adaptive method for those.

How do I choose n?

Start with n = 100 and double until the answer stabilises to the precision you need. Simpson's usually saturates much faster than trapezoidal.

Can I integrate over an infinite interval?

Not directly. Substitute t = 1 / x or similar to map the infinite interval to a finite one.

Try Numerical Integration

An unhandled error has occurred. Reload ×