BL2.ru

Numerical integration online(trapezoidal, Simpson, rectangles)

Compute the definite integral of a function on [a; b] with five numerical methods at once and compare their accuracy, or integrate a table of measurements.

Allowed: x^2, 2x, sin(x), cos x, e^x, exp(x), ln(x), lg(x), log(2, x), sqrt(x), abs(x), pi; decimal point or comma.
Calculate

Numerical integration

A definite integral is the area under the graph on [a; b]. When there is no closed-form antiderivative or only measurements are available, the interval is split into n parts with step h = (b − a) / n and simple areas are summed.

  • Rectangles: I ≈ h · Σ f(xi); the midpoint rule has error O(h²), left/right O(h).
  • Trapezoidal rule: I ≈ h · ((f0 + fn)/2 + f1 + … + fn−1), error O(h²).
  • Simpson’s rule: I ≈ h/3 · (f0 + 4f1 + 2f2 + … + 4fn−1 + fn), n even, error O(h⁴).

Runge error estimate

The integral is computed with steps h and h/2: ε ≈ absolute(Ih/2 − Ih) / (2p − 1), p is the order of the method.

Example

∫ x²·sin(x) dx from 0 to π = π² − 4 ≈ 5.869604. With n = 10 the trapezoidal rule gives about 5.788 (error 0.08), Simpson’s rule about 5.8695 (error about 0.0001).

FAQ

Which numerical integration method is most accurate?
Simpson’s rule: its error decreases as h⁴, versus h² for trapezoids and midpoint rectangles.
How to choose n?
Start with 10–100 and watch the Runge error estimate; increase n until it is small enough.
How to integrate tabulated data?
Choose “From table of points” and paste x and f(x) columns. Trapezoids work with any step, Simpson only with equal steps and an even number of intervals.
How to type the function?
Power x^2, multiplication * or just 2x, functions sin(x), exp(x) or e^x, ln(x), sqrt(x). Limits may be expressions: pi, pi/2, 1/3.