Simpson’s Rule Calculator
Simpson’s rule approximates an integral by fitting parabolas through groups of three points: (h ÷ 3)[f₀ + 4f₁ + 2f₂ + … + 4fₙ₋₁ + fₙ]. For x⁴ on [0, 2] with n = 4, it gives 6.41667 against the exact value of 6.4.
Last updated · By S. Dilshan · Runs in your browser, nothing is uploaded
Step-by-Step Solution
What Is Simpson’s Rule?
Simpson’s rule is a numerical method for estimating a definite integral. Instead of approximating the curve over each strip by a flat top (rectangles) or a slanted line (trapezoids), it fits a parabola through each set of three consecutive points. Because a parabola bends the way most smooth curves do, the approximation is dramatically more accurate for the same effort.
The rule is exact for every polynomial up to degree three, so it gives the precise integral of x³ with only two subintervals. For other functions, its error shrinks with the fourth power of the step size, so doubling the number of intervals cuts the error to about one sixteenth.
Comparing Methods for ∫₀² x⁴ dx = 6.4 with n = 4
| Method | Approximation | Error |
|---|---|---|
| Trapezoid rule | 7.0625 | +0.6625 |
| Simpson’s rule | 6.4167 | +0.0167 |
Simpson’s rule is about forty times more accurate here, using the same four intervals.
Simpson’s Rule Formula
his the width of each subinterval.fᵢis the function value at the point xᵢ = a + ih.- The coefficients follow the pattern 1, 4, 2, 4, 2, …, 4, 1: the end points get weight 1, odd-numbered points get 4 and even-numbered interior points get 2.
- n must be even because the rule works on pairs of subintervals.
To compare with simpler methods, see the Riemann sum calculator. For the exact value of a polynomial integral, use the polynomial integral calculator.
Worked Example: ∫₀² x⁴ dx with n = 4
- h = (2 − 0) ÷ 4 = 0.5.
- The points are x = 0, 0.5, 1, 1.5, 2, with f(x) = x⁴ values 0, 0.0625, 1, 5.0625, 16.
- Apply the weights 1, 4, 2, 4, 1: 0 + 4(0.0625) + 2(1) + 4(5.0625) + 16 = 0 + 0.25 + 2 + 20.25 + 16 = 38.5.
- Multiply by h ÷ 3 = 0.5 ÷ 3 = 0.16667: 38.5 × 0.16667 = 6.41667.
- The exact integral is 2⁵ ÷ 5 = 6.4, so the error is 0.01667.
Exact for Cubics
For f(x) = x³ on [0, 2] with n = 2, h = 1 and Simpson’s rule gives (1 ÷ 3)[0 + 4(1) + 8] = 4, which equals the exact integral 2⁴ ÷ 4 = 4. The error is zero because the rule is exact up to degree three.
Improving with More Intervals
Doubling n from 4 to 8 for x⁴ reduces the error from 0.0167 to about 0.001, roughly a sixteenth, as the fourth-power law predicts.
A Handy Relationship
Simpson’s rule is a weighted blend of the other two methods: S = (2M + T) ÷ 3, where M is the midpoint sum and T the trapezoid sum. For x² on [0, 3] with n = 6 the sums are M = 8.9375 and T = 9.125, so S = (17.875 + 9.125) ÷ 3 = 9, which is exact.
Predicting the Error
The error is bounded by (b − a)h⁴·max|f⁗(x)| ÷ 180. For x⁴ on [0, 2] with h = 0.5, the fourth derivative is the constant 24, so the bound is 2 × 0.0625 × 24 ÷ 180 = 0.01667, exactly the error we found. Because the formula depends on h⁴, halving the step size reduces the bound sixteen-fold.
How to Use This Simpson’s Rule Calculator
- Type your polynomial f(x), such as
x^4. - Enter the lower limit a and the upper limit b.
- Enter an even number of subintervals n.
- Read the Simpson’s rule approximation, the exact integral, the error and the step size h.
Where Simpson’s Rule Is Used
- Engineering and physics: integrating measured or tabulated data at evenly spaced points.
- Surveying and geoscience: estimating areas and volumes, such as the cross-sectional area of a river from depth soundings.
- Statistics and finance: approximating integrals of density functions without a closed form.
- Scientific computing: a standard building block in numerical integration libraries.
- Calculus courses: a step up from rectangles and trapezoids.
What Are the Most Common Mistakes With the Simpson’s Rule Calculator?
- Using an odd n. Simpson’s rule needs an even number of subintervals.
- Wrong weights. The pattern is 1, 4, 2, 4, …, 4, 1, not 1, 2, 4, 2, ….
- Forgetting the factor h ÷ 3. It is not h ÷ 2 (that is the trapezoid rule).
- Applying it to functions with sharp corners or jumps. The parabola assumption fails, and accuracy suffers.
- Expecting exactness for degree 4 and up. It is exact only up to cubics.
- Confusing the number of points with intervals. n intervals use n + 1 points.
Where Can You Verify These Formulas?
The definitions and formulas on this page follow standard references. Check them against these sources:
- OpenStax: algebra and calculus textbooks
- NIST Digital Library of Mathematical Functions
- Wolfram MathWorld
Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.
Frequently Asked Questions
What is Simpson’s rule?
A numerical integration method that approximates the function by parabolas over pairs of subintervals, giving high accuracy.
Why must n be even?
Each parabola uses three points spanning two subintervals, so the interval must divide into pairs.
How accurate is Simpson’s rule?
Its error decreases with the fourth power of the step size, and it is exact for polynomials up to degree three.
What is the formula for Simpson’s rule?
(h ÷ 3)[f₀ + 4f₁ + 2f₂ + … + 4fₙ₋₁ + fₙ], with h = (b − a) ÷ n.
How does it compare with the trapezoid rule?
It is usually much more accurate for smooth functions. For x⁴ on [0, 2] with n = 4, Simpson’s error is 0.017 against 0.66 for the trapezoid rule.
When should I use Simpson’s rule?
When the function is smooth and you want accuracy with few evaluations, as when integrating sampled data at evenly spaced points.