acalculator

How do I apply Simpson's rule?

Type f(x), the limits a and b, and an even number of subintervals n. The Simpson's rule calculator estimates the integral, lists each point with its 1, 4, 2, … 4, 1 weight, and shows the midpoint and trapezoidal estimates for the same n.

Your numbers

Rule
Estimate of the integral
8.145943735

The Simpson’s rule estimate of the integral of sqrt(1 + x^2) from 1 to 4 with n = 6 is 8.145943735.

Simpson’s rule (Sₙ)
8.145943735
Midpoint rule (Mₙ)
8.143073113
Trapezoidal rule (Tₙ)
8.151209109
Width Δx
0.5
Points used
x₀ = 1: f = 1.414213562, weight 1; x₁ = 1.5: f = 1.802775638, weight 4; x₂ = 2: f = 2.236067977, weight 2; x₃ = 2.5: f = 2.692582404, weight 4; x₄ = 3: f = 3.16227766, weight 2; x₅ = 3.5: f = 3.640054945, weight 4; x₆ = 4: f = 4.123105626, weight 1
Rule
Simpson’s rule

Estimate of the integral: 8.145943735. The Simpson’s rule estimate of the integral of sqrt(1 + x^2) from 1 to 4 with n = 6 is 8.145943735.

How to calculate

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.

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.

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

  • 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.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. f(x) sqrt(1 + x^2), Lower limit (a) 1, Upper limit (b) 4, Subintervals (n) 6, Rule Simpson’s rule gives Estimate of the integral 8.145944, Midpoint rule (Mₙ) 8.143073, Trapezoidal rule (Tₙ) 8.151209, Width Δx 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) x^3, Lower limit (a) 0, Upper limit (b) 1, Subintervals (n) 2, Rule Simpson’s rule gives Estimate of the integral 0.25, Simpson’s rule (Sₙ) 0.25, Width Δx 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) x^2, Lower limit (a) 0, Upper limit (b) 1, Subintervals (n) 4, Rule Trapezoidal rule gives Estimate of the integral 0.34375, Midpoint rule (Mₙ) 0.328125, Simpson’s rule (Sₙ) 0.333333, Points used 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)

How it works

Type f(x), the limits a and b (each from −10⁹ to 10⁹; b may be below a) and n (1 to 1,000). Then Δx = (b − a) ÷ n, worked out exactly from the typed decimals, and:

  • Points xᵢ = a + iΔx for i = 0 to n; midpoints mᵢ = a + (i − ½)Δx for i = 1 to n. Each is exact before it becomes a double, so xₙ is exactly b.
  • Simpson’s rule (n even): Sₙ = Δx/3 × [f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)]
  • Midpoint rule: Mₙ = Δx × [f(m₁) + … + f(mₙ)]
  • Trapezoidal rule: Tₙ = Δx/2 × [f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]

The rule you pick heads the answer; the other two are listed for comparison (Simpson’s only when n is even), each only when f has a real value at every point it uses and its estimate is in range. The f values are divided by one power of two near the largest |f| before the weighted sum (which changes no digit), so the sum cannot overflow.

What f(x) can hold

Numbers (2, 0.5, 1e-3), the letter x, + − * / and ^ (power), brackets, and implicit products (2x is 2 × x). Functions: sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, abs, exp, ln and log (both natural logarithms), log10; constants pi and e. Angles are in radians.

Rules

  • Simpson’s rule needs an even n; an odd n has no answer when Simpson’s rule is picked.
  • There is no answer when f(x) cannot be read, or when f has no real value at a point the rule uses (for example sqrt(x) below 0, or a division by 0), or when |f| passes 10³⁰⁰ there. The message names the point.
  • There is no answer when the estimate is past the double range.

Output format. Estimates and Δx to 10 significant digits. For n up to 20, “Points used” lists each point of the chosen rule as “x₀ = 1: f = 1.414213562, weight 1” (midpoints as m₁, m₂, …), numbers to 10 significant digits with a true minus sign, joined by “; ”.

Worked examples by hand

∫₁⁴ √(1 + x²) dx, n = 6. Δx = 0.5; x = 1, 1.5, 2, 2.5, 3, 3.5, 4; f = 1.414214, 1.802776, 2.236068, 2.692582, 3.162278, 3.640055, 4.123106. Weighted sum 1.414214 + 4(1.802776) + 2(2.236068) + 4(2.692582) + 2(3.162278) + 4(3.640055) + 4.123106 = 48.875662; × 0.5/3 = 8.145944 (OpenStax: 8.14594). The midpoint rule gives 8.143073 and the trapezoidal rule 8.151209.

∫₀¹ x³ dx, n = 2. Δx = 0.5: (0.5/3)(0 + 4 × 0.125 + 1) = 0.25, the exact value.

∫₀¹ x² dx, n = 4, trapezoidal. Δx = 0.25: (0.25/2)(0 + 2 × 0.0625 + 2 × 0.25 + 2 × 0.5625 + 1) = 11/32 = 0.34375. Midpoint: 0.25 × (0.015625 + 0.140625 + 0.390625 + 0.765625) = 21/64 = 0.328125. Simpson: (0.25/3)(0 + 0.25 + 0.5 + 2.25 + 1) = 1/3.

Other questions people ask

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.