# How do I apply Simpson's rule?

Estimates a definite integral ∫ f(x) dx from a to b with Simpson’s rule and n even subintervals, beside the midpoint and trapezoidal rules, with every point and weight.

- Page: https://www.acalculator.org/math/simpsons-rule-calculator
- JSON spec: https://www.acalculator.org/math/simpsons-rule-calculator.json
- Version: 183558700517

## Default answer

Example with the default inputs (f(x) sqrt(1 + x^2), Lower limit (a) 1, Upper limit (b) 4, Subintervals (n) 6, Rule Simpson’s rule): The Simpson’s rule estimate of the integral of sqrt(1 + x^2) from 1 to 4 with n = 6 is 8.145943735.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | f(x) | The function to integrate, in x, for example x^2, sqrt(1 + x^2) or sin(x). |
| a | Lower limit (a) | Where the integral starts. |
| b | Upper limit (b) | Where the integral ends; it may be below a. |
| n | Subintervals (n) | How many equal pieces [a, b] is cut into; Simpson’s rule needs an even number. |
| rule | Rule | Which rule heads the answer; the other two are shown below for comparison. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| estimate | Estimate of the integral | The chosen rule’s estimate of ∫ₐᵇ f(x) dx. |
| simpson | Simpson’s rule (Sₙ) | Δx/3 × [f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)]; needs an even n. |
| midpoint | Midpoint rule (Mₙ) | Δx × [f(m₁) + f(m₂) + … + f(mₙ)], with mᵢ the middle of each piece. |
| trapezoid | Trapezoidal rule (Tₙ) | Δx/2 × [f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]. |
| dx | Width Δx | (b − a) ÷ n, exact from the typed decimals. |
| steps | Points used | Each point of the chosen rule with f there and its weight, for n up to 20. |
| name | Rule | The rule that heads the answer. |

## Method

Sₙ = Δx/3 × [f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + 4f(xₙ₋₁) + f(xₙ)], Δx = (b − a) ÷ n, n even.

## Assumptions

- n is even for Simpson’s rule; the midpoint and trapezoidal rules take any n from 1 to 1,000.
- The points xᵢ = a + iΔx are exact from the typed decimals before f is evaluated in double precision.
- f must have a real value at every point the rule uses; angles are in radians.

## Worked examples

1. f = sqrt(1 + x^2), a = 1, b = 4, n = 6, rule = simpson gives estimate = 8.145944, midpoint = 8.143073, trapezoid = 8.151209, dx = 0.5. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration, https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (retrieved 2026-10-02) (Example 3.46: S₆ ≈ 8.14594; Example 3.40: M₆ ≈ 8.1431).
2. f = x^3, a = 0, b = 1, n = 2, rule = simpson gives estimate = 0.25, simpson = 0.25, dx = 0.5. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration, https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (retrieved 2026-10-02) (Example 3.45: S₂ = 1/4).
3. f = x^2, a = 0, b = 1, n = 4, rule = trapezoid gives estimate = 0.34375, midpoint = 0.328125, simpson = 0.333333, steps = x₀ = 0: f = 0, weight 1; x₁ = 0.25: f = 0.0625, weight 2; x₂ = 0.5: f = 0.25, weight 2; x₃ = 0.75: f = 0.5625, weight 2; x₄ = 1: f = 1, weight 1. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration, https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (retrieved 2026-10-02) (Example 3.41: T₄ = 11/32; Example 3.39: M₄ = 21/64).

## FAQ

### What is Simpson's rule?

A way to estimate a definite integral by fitting parabolas through the curve two subintervals at a time. With Δx = (b − a) ÷ n and n even, Sₙ = Δx/3 × [f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + 4f(xₙ₋₁) + f(xₙ)].

### Why does Simpson's rule need an even number of subintervals?

Each parabola spans two subintervals, so the subintervals must come in pairs. That is also why the weights alternate 4, 2, 4, …: the middle point of each pair gets 4 and the shared ends get 2.

### How accurate is Simpson's rule?

Its error is at most M(b − a)⁵ ÷ (180n⁴), where M bounds |f⁽⁴⁾(x)| on [a, b]. Doubling n cuts that bound by 16. It is exact for polynomials of degree 3 or less: S₂ for ∫₀¹ x³ dx gives exactly 1/4.

### How do I use Simpson's rule step by step?

Find Δx = (b − a) ÷ n, list x₀ = a, x₁ = a + Δx, … xₙ = b, evaluate f at each, multiply by 1, 4, 2, 4, …, 4, 1, add, and multiply by Δx/3. For ∫₁⁴ √(1 + x²) dx with n = 6, Δx = 0.5 and S₆ ≈ 8.14594.

### How does Simpson's rule compare with the midpoint and trapezoidal rules?

It is usually far more accurate for smooth functions. In fact Sₙ = (2Mₙ/₂ + Tₙ/₂) ÷ 3: a weighted average of the midpoint and trapezoidal estimates on half as many subintervals.

### What can I type for f(x)?

Numbers, x, + − * / ^, brackets and functions such as sqrt, sin, cos, tan, exp, ln, log10 and abs, with pi and e. Angles are in radians, so sin(x) from 0 to pi is about 2.

## Sources

- OpenStax, Calculus Volume 2, §3.6 Numerical Integration (the midpoint, trapezoidal and Simpson’s rules, Theorems 3.3 to 3.6, their error bounds, and Examples 3.39 to 3.46). https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (retrieved 2026-10-02)
