Simpson's Rule Calculator
- Subinterval width h = (2.00 - 0.00) / 4 = 0.5000.
- Odd-index values sum to 2.50 (weight 4) and even-index values sum to 1.00 (weight 2); endpoints are f(0.00) = 0.00 and f(2.00) = 4.00.
- Simpson estimate = (h / 3) x (f(start) + f(end) + 4 x 2.50 + 2 x 1.00) = 2.67.
- The exact integral of the cubic is 2.67, so the absolute error is 0.0000.
- Simpson's rule fits parabolas through triples of points, so it is exact for polynomials up to degree 3 — its error only appears with quartic or non-polynomial curves.
A Simpson's rule calculator approximates a definite integral by fitting parabolas through triples of points along a curve. Using Simpson's 1/3 rule, it computes integral ≈ (h / 3) × (f(x0) + f(xn) + 4 × odd-index values + 2 × even-index values), over an even number n of subintervals. The number of subintervals must be even, because the parabolas consume the interval two slices at a time. Enter your function, bounds, and an even n, and the calculator returns the estimated area under the curve instantly.
Simpson's rule is the accepted standard for this kind of calculation because it is exact for every polynomial of degree 3 or lower. Its parabolas can reproduce a cubic's integral, so error appears only with quartic or non-polynomial curves, where it shrinks roughly with 1/n⁴. For example, x² on [0, 2] with n = 4 gives 2.67, exactly the true integral. Likewise, x³ on [0, 3] with n = 6 gives 20.25, again exact, and x³ - 2x² + x on [0, 2] with n = 4 gives 0.67, exact, as the positive and negative lobes nearly cancel. This page shows the formula, step-by-step workings, worked examples, and sources.
Worked examples
x² on [0, 2], n = 4
Primary result: 2.67 — Simpson's rule is exact here, matching the true integral. (0 · 1 · 0 · 0 · 0 · 2 · 4)
| Simpson's rule estimate | 2.67 |
| Exact integral | 2.67 |
| Absolute error | 0.0000 |
| Subinterval width h | 0.5000 |
x³ on [0, 3], n = 6
Primary result: 20.25 — exact again: the rule integrates cubics perfectly. (1 · 0 · 0 · 0 · 0 · 3 · 6)
| Simpson's rule estimate | 20.25 |
| Exact integral | 20.25 |
| Absolute error | 0.0000 |
| Subinterval width h | 0.5000 |
x³ - 2x² + x on [0, 2], n = 4
Primary result: 0.67 — the positive and negative lobes nearly cancel. (1 · -2 · 1 · 0 · 0 · 2 · 4)
| Simpson's rule estimate | 0.67 |
| Exact integral | 0.67 |
| Absolute error | 0.0000 |
| Subinterval width h | 0.5000 |
Simpson's rule formula
Simpson's 1/3 rule approximates a definite integral by fitting parabolas through triples of points. The full formula is: integral ≈ (h / 3) × (f(x0) + f(xn) + 4 × odd-index values + 2 × even-index values), over an even number n of subintervals. Here h is the width of each subinterval, f(x0) and f(xn) are the function values at the endpoints, and the remaining terms cover every interior point. The pattern that emerges is 4-2-4-2-4, and so on, ending with a final 4 before the last endpoint.
The reason behind the 4-2-4 weighting pattern comes directly from the parabola idea. Each parabola is fitted through three consecutive points, which means it spans two subintervals at a time. The center point of each triple carries more weight because the parabola must pass through it while also matching the curve's shape at the two surrounding points. When you chain parabolas together across the full interval, the shared points between neighboring parabolas receive a weight of 2 — once from the parabola on the left and once from the parabola on the right. The unshared center points each get a weight of 4, while the very first and very last points get a weight of 1.
The number of subintervals must be even because the parabolas consume the interval two slices at a time. If n were odd, you would run out of points before completing the final parabola, leaving one subinterval unaccounted for. A simpson's rule calculator enforces this requirement automatically, but it is worth understanding the logic: every parabola needs three points spanning two subintervals, so the total count of subintervals has to be a multiple of 2.
Simpson's rule is exact for every polynomial of degree 3 or lower, because its parabolas can reproduce a cubic's integral. Error appears only with quartic or non-polynomial curves, where it shrinks roughly with 1/n⁴. This is why the method is so powerful for smooth functions. In the worked example of x² on [0, 2] with n = 4, the result is 2.67 — exactly the true integral. For x³ on [0, 3] with n = 6, the result is 20.25, again exact. Even for x³ - 2x² + x on [0, 2] with n = 4, the result is 0.67, exact, as the positive and negative lobes nearly cancel.
Worked examples
Simpson's 1/3 rule approximates a definite integral by fitting parabolas through triples of points. The formula is integral ≈ (h / 3) × (f(x0) + f(xn) + 4 × odd-index values + 2 × even-index values), applied over an even number n of subintervals. The number of subintervals must be even because the parabolas consume the interval two slices at a time. When you use a simpson's rule calculator, it applies this same formula behind the scenes.
The first worked example is x² on [0, 2] with n = 4. The calculator returns 2.67, which is exactly the true integral. The second worked example is x³ on [0, 3] with n = 6. The result is 20.25, again exact. The third worked example is x³ - 2x² + x on [0, 2] with n = 4. The calculator gives 0.67, exact, as the positive and negative lobes nearly cancel. Each of these results has been checked against the true integral and matches.
Simpson's rule is exact for every polynomial of degree 3 or lower, because its parabolas can reproduce a cubic's integral. Error appears only with quartic or non-polynomial curves, where it shrinks roughly with 1/n⁴. This is why all three worked examples above produce exact results despite using modest values of n.
- The number of subintervals must be even — the parabolas consume the interval two slices at a time.
- Simpson's rule is exact for every polynomial of degree 3 or lower, because its parabolas can reproduce a cubic's integral.
- Error appears only with quartic or non-polynomial curves, where it shrinks roughly with 1/n⁴.
| Function | Interval | n (subintervals) | Result | Exact? |
|---|---|---|---|---|
| x² | [0, 2] | 4 | 2.67 | Yes |
| x³ | [0, 3] | 6 | 20.25 | Yes |
| x³ - 2x² + x | [0, 2] | 4 | 0.67 | Yes |
Why Simpson's rule is exact for cubics
Simpson's 1/3 rule approximates a definite integral by fitting parabolas through triples of points, using the formula integral ≈ (h / 3) × (f(x0) + f(xn) + 4 × odd-index values + 2 × even-index values), over an even number n of subintervals. Since a parabola is a degree-2 curve, you might expect the rule to be exact only for polynomials of degree 2 or lower. Here is the happy accident: the rule's error term involves the fourth derivative of the integrand, not the third. For any cubic polynomial, that fourth derivative is zero, so the error vanishes entirely. The method is therefore exact for every polynomial of degree 3 or lower, giving you one degree more accuracy than its parabolic construction suggests.
A quick worked example shows this in action. Take x² on [0, 2] with n = 4. A Simpson's rule calculator returns 2.67, which matches the true integral exactly. Try x³ on [0, 3] with n = 6 and you get 20.25, again exact. Even a cubic with mixed terms behaves the same way: x³ - 2x² + x on [0, 2] with n = 4 gives 0.67, exact, as the positive and negative lobes nearly cancel. In each case the fitted parabolas reproduce the cubic's integral with no leftover error.
The reason is mechanical. Each parabola consumes the interval two slices at a time, so the number of subintervals must be even. Within each pair of slices, the parabola captures the area under the curve perfectly when the curve itself is no more than quadratic. But the way consecutive parabolas stitch together also cancels the leading error term for cubics, leaving nothing behind. The fourth-derivative dependence is what makes this cancellation show up in the formal error analysis.
Error appears only with quartic or higher-degree polynomials or with non-polynomial curves such as sine or exponential functions. Even there, the error shrinks roughly with 1/n⁴, so doubling the number of subintervals cuts the error by about a factor of sixteen. That rapid convergence is a direct consequence of the same fourth-derivative structure that grants the free cubic accuracy. A Simpson's rule calculator leverages this property to deliver high precision from relatively few points.
Simpson's vs trapezoidal
A simpson's rule calculator generally delivers more accuracy per function evaluation than the trapezoidal approach. Simpson's 1/3 rule works by fitting parabolas through triples of points, using the formula integral ≈ (h / 3) x (f(x0) + f(xn) + 4 x odd-index values + 2 x even-index values). Because each parabola spans three points, the method consumes the interval two slices at a time, which means the number of subintervals must be even. That is the key restriction: you cannot apply Simpson's 1/3 rule with an odd value of n.
The accuracy payoff is substantial. Simpson's rule is exact for every polynomial of degree 3 or lower, because its parabolas can reproduce a cubic's integral. For example, integrating x² on [0, 2] with n = 4 gives 2.67, exactly the true integral. Integrating x³ on [0, 3] with n = 6 gives 20.25, again exact. Even x³ - 2x² + x on [0, 2] with n = 4 gives 0.67, exact, as the positive and negative lobes nearly cancel. Error appears only with quartic or non-polynomial curves, where it shrinks roughly with 1/n⁴. The trapezoidal rule, by contrast, is only exact for linear functions, and its error shrinks more slowly, roughly with 1/n².
Despite Simpson's advantage in accuracy, the trapezoidal rule remains the right tool in one common situation: unevenly spaced data. Simpson's rule requires uniform spacing — every subinterval must have the same width h. When your data points come from measurements taken at irregular intervals, or when you have no underlying function and only a scattered set of values, the trapezoidal rule adapts naturally. It simply connects each pair of adjacent points with a straight line and sums the resulting trapezoid areas, regardless of whether the spacing is uniform.
Choose based on what you have. If you can evaluate a function at equally spaced points and want high accuracy with fewer evaluations, Simpson's rule is the stronger choice. If you are working with irregularly spaced samples and cannot resample at uniform intervals, the trapezoidal rule is the practical option.
FAQs
What is Simpson's rule?
Simpson's rule is a numerical integration method that approximates the area under a curve using parabolas. The formula is (h / 3) x (endpoints + 4 x odd-index values + 2 x even-index values), where h is the width of each subinterval. This approach fits parabolic arcs to successive groups of points, yielding a close estimate of the integral.
Why must n be even in Simpson's rule?
Each parabola in Simpson's rule spans two subintervals, so the total interval must divide into pairs. That means n = 2, 4, 6 and so on. An odd number of subintervals would leave one interval without a partner, making the parabolic fitting impossible without adjusting the method.
Is Simpson's rule exact for x³?
Yes. Simpson's rule is exact for all polynomials up to degree 3. For example, integrating x³ on [0, 3] with n = 6 gives exactly 20.25, matching the true value. The parabolic approximation captures cubic behavior precisely, so no error appears for polynomials of degree three or lower.
How accurate is Simpson's rule compared with the trapezoidal rule?
Simpson's rule is much more accurate for smooth curves. Its error shrinks with about 1/n⁴ as you increase the number of subintervals, compared with the trapezoidal rule's 1/n². This faster convergence means Simpson's rule reaches high precision with fewer intervals, provided the function being integrated is sufficiently smooth.
What is the 4-2-4 pattern?
The 4-2-4 pattern describes how interior points alternate weights of 4 and 2, starting and ending with 4. The endpoints themselves carry weight 1. This weighting reflects the parabolic fitting: odd-indexed points get weight 4, even-indexed interior points get weight 2, and the first and last points get weight 1.
What functions can this calculator integrate?
This calculator integrates cubic polynomials of the form f(x) = a3x³ + a2x² + a1x + a0. For these functions the Simpson's rule estimate is exact, as the comparison with the true integral shows. Because Simpson's rule matches cubic behavior precisely, the computed result equals the analytical integral with no approximation error.