About the Simpson's Rule Calculator
Many definite integrals cannot be worked out with antiderivatives. The integral of e^(−x²), of sin(x)/x or of a function known only by a formula in a computer model has no simple closed form, yet engineers and scientists need its value. Numerical integration estimates the area under the curve from function values at evenly spaced points, and Simpson's rule is one of the most accurate simple methods.
This Simpson's rule calculator approximates the integral of f(x) from a to b using the composite Simpson's 1/3 rule or 3/8 rule. It shows the step size, the value and weight at each point, the weighted sum and the result. It also repeats the calculation with twice as many subintervals so you can see how accurate the first answer is.
How to Use the Simpson's Rule Calculator
Enter the function f(x) using x as the variable, ^ for powers and functions such as sin(x), ln(x), sqrt(x) or e^x.
Enter the lower limit a and upper limit b. They can be numbers or expressions such as pi or pi/2.
Enter the number of subintervals n. For the 1/3 rule it must be even; for the 3/8 rule it must be a multiple of 3.
Choose the rule: 1/3 or 3/8.
The Formulas
h = (b − a) / n, x_i = a + i·h, f_i = f(x_i)
1/3 rule: ∫ ≈ h/3 × [f0 + 4f1 + 2f2 + 4f3 + … + 2f(n−2) + 4f(n−1) + fn]
3/8 rule: ∫ ≈ 3h/8 × [f0 + 3f1 + 3f2 + 2f3 + 3f4 + 3f5 + 2f6 + … + fn]
error estimate of S_n ≈ (S_2n − S_n) × 16/15
Step-by-Step Example
Estimate the integral of 1/(1 + x²) from 0 to 1 with the 1/3 rule and n = 4. The exact value is π/4 ≈ 0.785398.
h = (1 − 0) / 4 = 0.25
x: 0 0.25 0.5 0.75 1
f: 1 0.941176 0.8 0.64 0.5
w: 1 4 2 4 1
sum = 1 + 3.764706 + 1.6 + 2.56 + 0.5 = 9.424706
S4 = 0.25 / 3 × 9.424706 ≈ 0.785392
The error is about 0.000006 with only five function values. Doubling to n = 8 gives 0.785398, and (0.785398 − 0.785392) × 16/15 estimates the error of the first answer at about 0.000006, which matches the true error closely.
Why Simpson's Rule Is So Accurate
The trapezoidal rule joins neighbouring points with straight lines. Simpson's 1/3 rule instead passes a parabola through each group of three points and integrates it exactly. Because parabolas bend with the curve, much less area is missed. A pleasant surprise is that the rule is exact not only for quadratics but for cubics too, because the error terms for the cubic part cancel by symmetry.
The practical result is that the error is proportional to h⁴. Halve the step size and the error falls by a factor of about 16, compared with a factor of 4 for the trapezoidal rule. That is why a modest number of points often gives six or more correct digits for smooth functions.
The 1/3 Rule and the 3/8 Rule
The 3/8 rule fits a cubic through each group of four points, covering three subintervals at a time. Despite using a higher degree polynomial, it has the same h⁴ order of accuracy as the 1/3 rule, and its error constant is slightly larger. Its main use is practical: when data come in a number of intervals that is a multiple of 3, or when an odd number of intervals can be split into a 1/3 part and a 3/8 part.
For the same example with the 3/8 rule and n = 6, the calculator gives 0.785396, also within a few millionths of π/4. In everyday work either rule is fine; pick the one your course or textbook asks for.
Choosing the Number of Subintervals
Start with a modest even number such as 4, 8 or 10, then look at the accuracy check. If the doubled-n result agrees with the first to the number of digits you need, the first answer is good enough. If not, increase n. Functions that change quickly, oscillate, or have a steep section need more points, and a function with a sharp corner loses the h⁴ advantage near that corner.
If the function is undefined at a point the rule uses, such as 1/x at x = 0 or ln(x) at 0, Simpson's rule cannot be applied directly. Such improper integrals need a substitution or a method designed for singularities.
Uses of Simpson's Rule
Simpson's rule is used to integrate measured data at evenly spaced intervals, such as river cross sections for flow, ship hull offsets for displacement, or velocity readings to find distance travelled. It is a standard topic in AP Calculus, A-level mathematics and first-year numerical methods courses, and it underlies adaptive integration routines used in software.
Understanding Your Result
The headline gives the approximate value of the integral.
The set-up line shows the rule, n and the step size h.
The accuracy check shows the result with twice as many subintervals and the estimated error of your answer.
The steps list each point, its function value and its weight when n is 12 or fewer.
When Should You Use This Calculator?
Use it to approximate definite integrals that have no simple antiderivative.
Use it to check Simpson's rule homework, including the table of weights.
Use it to compare the 1/3 and 3/8 rules on the same function.
Common Mistakes
Using an odd n with the 1/3 rule. The parabolas need subintervals in pairs.
Mixing up the weights. Odd points get 4 and even interior points get 2 in the 1/3 rule.
Forgetting the h/3 factor. The weighted sum must be multiplied by h/3, or 3h/8 for the 3/8 rule.
Using degrees. Trigonometric functions take radians.