Numerical Integration Calculator
Approximate the area under a curve using the trapezoidal rule and Simpson rule.
Enter function f(x), integration bounds, and number of intervals.
Numerical integration is the process of approximating the area enclosed between a curve and the x-axis over a defined interval. When an exact analytical antiderivative is difficult or impossible to compute, numerical methods step in.
Trapezoidal Rule formula:
∫ f(x) dx ≈ (h/2) × [f(x₀) + 2f(x₁) + 2f(x₂) + ... + 2f(xₙ₋₁) + f(xₙ)]
Left/Right Riemann Sum formula:
∫ f(x) dx ≈ h × Σ f(xᵢ) (left endpoints) or h × Σ f(xᵢ₊₁) (right endpoints)
What each variable means:
- h = (b − a) / n — the width of each sub-interval (strip)
- a — lower bound of integration
- b — upper bound of integration
- n — number of intervals; more intervals = more accuracy
- f(xᵢ) — the function value at each sample point
Worked example: Estimate ∫ x² dx from 0 to 3 using the trapezoidal rule with n = 6.
h = (3 − 0) / 6 = 0.5 Sample points: x = 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 f values: 0, 0.25, 1.0, 2.25, 4.0, 6.25, 9.0
Sum = 0 + 2(0.25) + 2(1.0) + 2(2.25) + 2(4.0) + 2(6.25) + 9.0 = 36.0 Area ≈ (0.5 / 2) × 36.0 = 9.0
Exact answer: [x³/3] from 0 to 3 = 27/3 = 9.0 — perfect at this resolution!
Accuracy notes: The trapezoidal rule has an error of O(h²), meaning halving h reduces error by ~4×. For most practical work, n = 100–1000 gives excellent results. Simpson’s Rule (not shown here) uses parabolic arcs instead of straight lines and is more accurate for smooth functions. Functions with sharp peaks or discontinuities need very high n values near those points.
Real-world uses: Physics (work done by a variable force), economics (consumer surplus area), engineering (signal energy), and statistics (computing probabilities under a PDF curve).