Simpson's Rule Calculator

Approximate a definite integral from a function and an even number of subintervals, with a step size and an error guide.

Math and PercentUpdated 2026-11-184 min read
Simpson's Rule Calculator
Use x as the variable. Allowed: + - * / ^, parentheses, pi, e and sin, cos, tan, exp, log, ln, sqrt, abs. Trig functions take radians.
Must be even. Doubling it is the simplest way to check the result.
Simpson estimate
...
Step size h...
Trapezoidal estimate on the same nodes...
Difference between the two estimates...
Richardson error guide...

What it does

A definite integral gives the signed area under a curve, but many functions have no antiderivative you can write down. Simpson's rule is a way to get a good numerical answer by sampling the function at evenly spaced points and adding weighted values. It is one of the oldest quadrature formulas and still one of the first taught, because a small amount of arithmetic buys a surprisingly accurate result.

The rule is named after Thomas Simpson, who published it in 1743, though the same idea appeared earlier. The NIST Digital Library of Mathematical Functions writes the composite form with weights of one at the ends, four at the odd nodes and two at the even interior nodes, multiplied by one third of the step. The same reference gives the error term as minus (b - a) times h to the fourth times the fourth derivative at some point inside the range, divided by 180. That fourth power is the reason the method improves so quickly when the step shrinks.

The rule works by replacing pairs of subintervals with a parabola through three consecutive points. A parabola can match any quadratic exactly, and because of the symmetry of the sampling it also integrates any cubic exactly. That is a useful fact for checking the tool: integrate a polynomial of degree three or less and the estimate should match the exact answer apart from rounding.

The OpenStax calculus text places Simpson's rule alongside the midpoint and trapezoidal rules and uses it to meet a target accuracy. It also stresses that a numerical answer without an error check is only half a result. This page reports two checks. The first is the difference between the Simpson estimate and the trapezoidal estimate on the same nodes. The second is a Richardson guide, found by comparing the answer with the one from twice as many intervals.

Enter a function of x, the two limits and an even number of intervals. The accepted syntax is small on purpose: arithmetic, powers, parentheses, the constants pi and e, and a handful of standard functions. Trigonometric functions take radians, as they do in calculus. The tool calculates both estimates and their difference, then shows the error guide so you can decide whether to refine the step.

How to use

  1. Enter the function in the first box, using x as the variable, for example x^4 or sin(x).
  2. Use +, -, *, / and ^ for arithmetic, and wrap function arguments in parentheses such as sqrt(1+x^2).
  3. Enter the lower and upper limits of integration. The upper limit may be smaller than the lower one, which changes the sign of the answer.
  4. Choose an even number of intervals. Four is a reasonable start, and doubling it is the simplest way to check the result.
  5. Read the Simpson estimate first, then the step size to see how finely the range was divided.
  6. Compare the trapezoidal estimate and the error guide. If they are still moving, increase the number of intervals and recalculate.

Formula

Composite Simpson's rule: integral is about (h / 3) x (f0 + 4 f1 + 2 f2 + 4 f3 + ... + 4 f(n-1) + fn), with h = (b - a) / n and n even. Trapezoidal estimate = h x (0.5 f0 + f1 + ... + f(n-1) + 0.5 fn).
h
Step width, the length of the interval divided by the number of intervals.
n
Number of equal subintervals, which must be even.
f_k
The function value at x_k = a + k h, for k from 0 to n.
a, b
Lower and upper limits of integration.
S_n
The Simpson estimate using n subintervals.

The weights alternate 4 and 2 between the endpoints, starting and ending with 4 on an odd node. Simpson's rule is exact for polynomials up to degree 3. The error guide divides the change between the n interval and 2n interval answers by 15, which follows from an error proportional to h to the fourth. It is an estimate, not a guaranteed bound, and it can understate the error when the function has a sharp corner.

Worked example

Example: integrating x to the fourth from 0 to 2

Defaults: f(x) = x^4, lower limit 0, upper limit 2 and n = 4 intervals.

  1. Step: h = (2 - 0) / 4 = 0.5, so the nodes are 0, 0.5, 1, 1.5 and 2.
  2. Function values at those nodes: 0, 0.0625, 1, 5.0625 and 16.
  3. Weighted sum: 0 + 4 x 0.0625 + 2 x 1 + 4 x 5.0625 + 16 = 0.25 + 2 + 20.25 + 16 = 38.5.
  4. Simpson estimate: (0.5 / 3) x 38.5 = 6.416667.
  5. Trapezoidal estimate on the same nodes: 0.5 x (0 + 0.0625 + 1 + 5.0625 + 8) = 7.062500, so the difference is 0.645833.
  6. The exact integral is 2 to the fifth over 5 = 6.4, so the error is 0.016667.
  7. With eight intervals the estimate is 6.401042 and the error guide is 0.001042. The tool shows 6.416667, 0.500000, 7.062500, 0.645833 and 0.001042.

Reference table

Integrating x to the fourth from 0 to 2, whose exact value is 6.400000
Intervals nStep hSimpson estimateError
21.0000006.6666670.266667
40.5000006.4166670.016667
80.2500006.4010420.001042
160.1250006.4000650.000065

Limits

  • Needs an even number of intervals. An odd count is rejected rather than silently patched with a different rule.
  • Assumes equally spaced sample points, which is why the tool works from a function and its limits rather than an arbitrary table.
  • Loses accuracy near a vertical asymptote, a jump or a sharp corner. Sampling more points in the wrong place will not repair that.
  • The error guide uses a fourth power rule of thumb and is not a rigorous bound. It can be too optimistic for a function whose fourth derivative changes rapidly.

Common mistakes

  • Using an odd number of intervals and expecting the weights to pair up.
  • Mixing degrees and radians when entering a trigonometric function; the parser expects radians.
  • Forgetting the factor h / 3 and adding the weighted values as if they were the integral.
  • Reading the trapezoidal difference as the exact error rather than a rough indicator.
  • Assuming a larger interval count always helps when the function is not finite inside the range.

Try it yourself

Quick checks. Answers sit tucked under each question.

Integrate x to the fourth from 0 to 2 with four intervals. What does the tool show?

6.416667 with a step of 0.500000. The exact answer is 6.4, so the error is 0.016667.

Double the intervals for that quartic to eight. How much does the error fall?

The estimate becomes 6.401042, an error of 0.001042 against 6.4. That is about sixteen times smaller, matching an error proportional to h to the fourth.

Estimate the integral of 1/x from 1 to 2 with eight intervals and compare it with ln 2.

The tool gives 0.693155. Since ln 2 is 0.693147, the error is about 0.000008.

Questions

What does Simpson's rule approximate?

A definite integral, that is the signed area between a function and the x axis over a chosen interval. It samples the function at equally spaced points and combines them with fixed weights.

Why must the number of intervals be even?

The rule fits a parabola through three consecutive points, so the subintervals have to pair up. An odd count leaves one interval without a partner, and the plain composite rule is not defined there.

Is Simpson's rule always better than the trapezoidal rule?

For a smooth function it is usually far better, because its error falls with h to the fourth rather than h squared. For a rough or discontinuous function neither rule can be trusted without more samples.

What does the error guide on this page mean?

It compares the n interval answer with the 2n interval answer and divides the change by 15. That is a standard estimate based on the fourth power error, but it is a guide rather than a guarantee.

Which function syntax does the calculator accept?

Arithmetic with +, -, *, / and ^, parentheses, the constants pi and e, and the functions sin, cos, tan, exp, log, ln, sqrt and abs. Write sin(x), not sin x, and remember that trig functions use radians.

Can I integrate from a larger limit to a smaller one?

Yes. The step becomes negative and the result changes sign, which is the usual convention for a definite integral with reversed limits.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.