Approximate definite integrals using Simpson's 1/3 rule — a powerful numerical method that fits parabolas to subintervals. Visualize the function, data points, and the area under the curve.
Simpson's rule (also known as Simpson's 1/3 rule) is a numerical integration technique that provides higher accuracy than the trapezoidal rule for smooth functions. Instead of approximating the area with straight lines, it fits a quadratic polynomial (parabola) through every three consecutive points, then integrates the parabola exactly. The result is remarkably accurate, especially for functions with continuous fourth derivatives.
\[ \int_{a}^{b} f(x) \, dx \approx \frac{h}{3} \left[ f(x_0) + 4\sum_{i=1,3,5}^{n-1} f(x_i) + 2\sum_{j=2,4,6}^{n-2} f(x_j) + f(x_n) \right] \]
where \( h = \frac{b-a}{n} \), \( n \) is even, and \( x_k = a + k h \).
Although named after the English mathematician Thomas Simpson (1710–1761), the rule was known earlier to Johannes Kepler and even to Cavalieri. It belongs to the family of Newton–Cotes formulas. The error term for Simpson's rule depends on the fourth derivative: \( E = -\frac{(b-a)^5}{180 n^4} f^{(4)}(\xi) \) for some \( \xi \in [a,b] \). Because of the \( n^4 \) denominator, Simpson's rule converges quickly as \( n \) increases. For periodic functions and smooth integrands, it often yields spectacular precision.
The fourth‑derivative term explains why Simpson's rule yields exact results for polynomials up to degree 3 (since the fourth derivative is zero). For functions with discontinuities or sharp peaks, the error may increase; increasing \( n \) reduces error at a rate of \( O(1/n^4) \), much faster than the trapezoidal rule's \( O(1/n^2) \). However, for functions with high oscillation, using too large an \( n \) might lead to round‑off errors. Our calculator provides a local error estimate based on the maximum fourth derivative approximated via finite differences, giving you insight into reliability.
Evaluate \( \int_{0}^{1} \frac{4}{1+x^2} dx = \pi \). Using 8 subintervals, Simpson's rule yields ≈ 3.1415926, accurate to 6 decimal places. In contrast, the trapezoidal rule with the same n gives ≈ 3.138988. The dramatic improvement showcases Simpson's superior convergence. This is why numerical analysts prefer Simpson's rule for smooth integrands.
| Method | Order of accuracy | Error constant factor | Exact for polynomials degree |
|---|---|---|---|
| Midpoint Rule | O(h²) | 1/24 | 0 |
| Trapezoidal Rule | O(h²) | 1/12 | 1 |
| Simpson's Rule | O(h⁴) | 1/90 | 3 |
Math.sin(x), x**2 for power, Math.exp(x).