Approximate definite integrals using the trapezoidal rule. Visualize trapezoids under the curve, compute error bounds, and compare with high‑precision reference values. Supports standard mathematical syntax (e.g., sin(x), x^2, exp(-x)).
The Trapezoidal Rule is a numerical integration method that approximates the definite integral ∫ab f(x) dx by dividing the area under the curve into trapezoids rather than rectangles (as in Riemann sums). For each subinterval [xi, xi+1] of width h = (b-a)/n, the area is approximated as (h/2)·[f(xi) + f(xi+1)]. Summing these gives the composite trapezoidal rule.
∫ab f(x) dx ≈ \(\frac{h}{2}\left[ f(x_0) + 2\sum_{i=1}^{n-1} f(x_i) + f(x_n) \right]\)
where h = (b-a)/n, xi = a + i·h
The trapezoidal rule can be derived by integrating the linear interpolant of f at the endpoints of each subinterval. The local truncation error on a single interval is: Ei = −(h3/12) f''(ξi) for some ξi in [xi, xi+1]. Summing over n intervals gives the global error bound:
$$ |E| ≤ \frac{(b-a)^3}{12n^2} \max_{x\in[a,b]} |f''(x)| $$
This shows quadratic convergence: doubling n reduces error by a factor of 4 (asymptotically). Our calculator estimates this bound numerically by sampling the second derivative (central differences) at 800 points for better reliability.
sin(x), x^2, exp(-x*x)).
sqrt(x), log(x), or 1/x, ensure the integration interval lies within the valid domain. Reference value may be unreliable if the function is discontinuous or has singularities inside the interval.
| Function | Interval | n | Trapezoidal Approx | True Integral | Error |
|---|---|---|---|---|---|
| sin(x) | [0, π] | 6 | 2.0000 | 2.0000 | ~0.0000* |
| x² | [0, 2] | 4 | 2.6875 | 2.6667 | 0.0208 |
| e-x | [0, 3] | 6 | 0.9496 | 0.9502 | 0.0006 |
| x³ - 2x | [-1, 2] | 6 | 0.7500 | 0.7500 | ~0.0000** |
In automotive engineering, velocity vs. time data from sensors is often discrete. The trapezoidal rule is used to compute total distance traveled (integral of velocity). For a vehicle accelerating from 0 to 100 km/h over 10 seconds, sampling every second and applying the trapezoidal rule gives accurate displacement without needing a continuous function. This method balances simplicity and precision, forming the basis of many onboard diagnostics systems.
The trapezoidal rule traces back to ancient approximations of curved areas, but it was formally studied by Newton, Cotes, and later by Euler. Today it remains a fundamental algorithm in computational physics, finance (option pricing), and signal processing. Its simplicity and stability make it an essential building block for adaptive integrators and multistep methods for differential equations.
sin(x), cos(x), exp(x), log(x), x^3. Multiplication must be explicit: 2*x not 2x. The calculator automatically converts legacy Math.sin and ** to compatible forms.