Simpson's Rule Calculator
Inputs
| Lower limit | 0 |
|---|---|
| Upper limit | 1 |
| Subintervals (even) | 4 |
| Function values | 1, 0.94, 0.78, 0.64, 0.5 |
Simpson's Rule Calculator
Approximate a definite integral with Simpson's 1/3 rule from sampled function values. Enter the limits, an even number of subintervals, and the values f(x₀)…f(xₙ) to get the parabolic area estimate and the step size.
Inputs
Results
Enter a value to see results.
Simpson's rule
Simpson's rule estimates a definite integral by replacing the curve with parabolas rather than straight line segments. Each pair of adjacent strips is fitted with a parabola through three points, and the integral is approximated by the total area under those parabolas. Because a parabola tracks curvature that a straight chord misses, Simpson's rule is usually far more accurate than the trapezoidal rule for the same sampling effort.
Split the interval [a, b] into n equal subintervals of width h = (b − a) / n, where n is even. This creates n + 1 grid points x₀ = a, x₁, x₂, …, xₙ = b. Sampling the function at each point gives the values f(x₀), f(x₁), …, f(xₙ), and the estimate is:
∫ₐᵇ f(x) dx ≈ (h/3)·[f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + 4f(xₙ₋₁) + f(xₙ)]
This calculator works from sampled function values rather than a typed formula: you provide f at the n + 1 evenly spaced points, which is exactly the situation you face when the data comes from measurements or a table.
Why the weights are 1, 4, 2, 4, 2, …, 4, 1
Take a single block of three points [x₀, x₁, x₂] with spacing h. Fit the unique parabola through them and integrate it exactly over the block; the result is
(h/3)·(f₀ + 4f₁ + f₂)
so the block midpoint carries weight 4 and the two ends weight 1. Now join consecutive blocks — [x₀, x₁, x₂], [x₂, x₃, x₄], and so on. Every block midpoint keeps its weight of 4, while each shared boundary point belongs to two blocks and picks up weight 1 + 1 = 2. The two outer endpoints belong to a single block and stay at weight 1. Collecting terms produces the alternating pattern 1, 4, 2, 4, 2, …, 4, 1, all multiplied by h/3. The pairing of blocks is exactly why n must be even.
Worked example
Estimate ∫₀¹ x² dx using n = 4 subintervals. The step size is h = (1 − 0) / 4 = 0.25, and the grid points are 0, 0.25, 0.5, 0.75, 1. The sampled values of x² are:
| x | 0 | 0.25 | 0.5 | 0.75 | 1 |
|---|---|---|---|---|---|
| f(x) = x² | 0 | 0.0625 | 0.25 | 0.5625 | 1 |
Apply the rule with weights 1, 4, 2, 4, 1:
∫ ≈ (0.25/3)·[0 + 4(0.0625) + 2(0.25) + 4(0.5625) + 1] ∫ ≈ (0.25/3)·[0 + 0.25 + 0.5 + 2.25 + 1] = (0.25/3)·4 = 1/3
The result is exactly 1/3, which is the true value of the integral. This is not luck: Simpson's rule integrates any polynomial up to degree three exactly, so a quadratic like x² is captured with zero error regardless of how many strips are used.
How the error behaves
Simpson's rule is fourth-order accurate: halving h cuts the error by about a factor of sixteen. For a function with a continuous fourth derivative, the error over [a, b] is
E = −((b − a)·h⁴/180)·f⁽⁴⁾(ξ)
for some point ξ in the interval. Two consequences follow:
- Because the error depends on the fourth derivative, any polynomial of degree three or less is integrated exactly — its fourth derivative is zero.
- For smooth curves the h⁴ factor drives the error down very quickly, so a modest number of strips often suffices for high accuracy.
Simpson's rule versus the trapezoidal rule
The trapezoidal rule joins points with straight segments, so its error is proportional to h² (second-order). Simpson's rule fits parabolas and reaches h⁴ (fourth-order), converging far faster for smooth functions at the same number of points. The trade-offs:
- Simpson's rule requires an even number of subintervals, whereas the trapezoidal rule works with any n.
- For noisy or irregular data, forcing parabolas through scattered points can amplify the noise; the trapezoidal rule is sometimes more robust there.
A practical rule of thumb: reach for Simpson's rule whenever the function is smooth and you want high accuracy for the same sampling effort; use the trapezoidal rule for quick estimates, noisy data, or when n must be odd.
Practical notes
- Even subintervals only. Simpson's 1/3 rule pairs the strips, so n must be even. The calculator flags an odd n.
- Match the count. With n subintervals you must supply exactly n + 1 values, one per grid point. The calculator flags a mismatch so the spacing stays uniform.
- Keep the order. List values from x₀ = a to xₙ = b. Interior odd- and even-indexed points are weighted differently, so the order matters.
- Reversed limits. If a is greater than b, the step size is negative and the result changes sign — matching the convention that swapping integration limits negates the integral.
- Equal spacing only. This is the uniform-grid Simpson's rule. Unequally spaced data needs a more general quadrature formula.
Related calculators
- Definite Integral of Polynomial Calculator — exact integral of a polynomial via the fundamental theorem of calculus
- Polynomial Derivative Calculator — numerical derivative at a single point
- Arithmetic Sequence Calculator — terms and sums of evenly spaced values
Frequently Asked Questions (FAQ)
How many function values do I need to enter?
Dividing the interval [a, b] into n subintervals creates n + 1 grid points: x₀ = a, x₁, x₂, …, xₙ = b. You enter the function value at each of those points, so n subintervals require n + 1 values.
Because Simpson’s rule groups the strips in pairs, n must be even — for example, 4 subintervals over [0, 1] use the points 0, 0.25, 0.5, 0.75, 1, which is five values. If your value count and subinterval count do not match, the calculator flags it so the spacing stays consistent.
Why do the weights alternate 1, 4, 2, 4, 2, …, 4, 1?
Simpson’s rule fits a parabola through each block of three consecutive points and integrates that parabola exactly. Over one block [x₀, x₂] the area works out to (h/3)(f₀ + 4f₁ + f₂): the midpoint of the parabola carries weight 4, the two ends weight 1.
When adjacent blocks are joined, each shared boundary point belongs to two parabolas, so its weights add to 2, while every block midpoint keeps its weight of 4. The two outer endpoints belong to a single block and stay at weight 1. Collecting the terms gives the familiar pattern 1, 4, 2, 4, 2, …, 4, 1, all multiplied by h/3.
How accurate is Simpson’s rule compared with the trapezoidal rule?
Simpson’s rule approximates the curve with parabolas rather than straight segments, so its error shrinks proportionally to h⁴ (fourth-order accurate), while the trapezoidal rule is only second-order (error proportional to h²). For smooth functions Simpson’s rule is therefore far more accurate for the same number of points, and it is exact for any polynomial up to degree three.
The trade-off is that Simpson’s rule requires an even number of subintervals, whereas the trapezoidal rule works with any n. For noisy or irregular data, forcing parabolas through scattered points can amplify the noise, so the trapezoidal rule is sometimes the safer choice.
What if the lower limit is larger than the upper limit?
If a is greater than b, the step size h = (b − a) / n is negative, which flips the sign of the result — consistent with the convention that swapping the limits of an integral negates it. The magnitude of the estimate is unchanged. List the function values in order from x₀ = a to xₙ = b so the pairing with the grid points stays correct.
Recommended Next
Definite Integral of Polynomial Calculator
Compute the exact definite integral ∫_a^b P(x) dx for any polynomial using the Fundamental Theorem of Calculus — exact result, no approximation.