Simpson’s 1/3 Rule Calculator: Numerical Integration

This Simpson’s 1/3 rule calculator approximates a definite integral, the area under a curve between two limits. Type your function of x, set the lower and upper limits and choose an even number of intervals, and it returns the approximate integral to six decimal places.

Math Calculators

Simpson's 1/3 Rule Calculator

Numerically integrate ∫f(x)dx over [a, b] using Simpson's 1/3 rule with a chosen (even) number of intervals.

Use x as the variable, e.g. x^2, sin(x), sqrt(1+x^2).
Simpson's 1/3 rule requires an even number of intervals — an odd count entered here is automatically rounded up to the next even number.

Starting values: the calculator opens with f(x) = x^2, a lower limit of 0, an upper limit of 2 and 10 intervals. The result is 2.666667, which matches the exact answer of 8/3.

The Simpson’s 1/3 rule formula

Simpson’s rule splits the interval from a to b into n equal strips, then fits a parabola through each pair of neighbouring strips instead of joining the points with straight lines. That is why it usually beats the trapezoidal rule on smooth curves. The calculator uses:

∫f(x)dx ≈ (h ÷ 3) × [f(x0) + 4 × Σf(odd points) + 2 × Σf(even points) + f(xn)]

Where:

  • h = (b − a) ÷ n, the width of each strip
  • x0 = a and xn = b, the two end points
  • the odd points are x1, x3, x5 and so on, each weighted 4
  • the even interior points are x2, x4 and so on, each weighted 2

The weights run 1, 4, 2, 4, 2, …, 4, 1. The first and last values count once, which is why n must be even: the parabolas need pairs of strips.

How to enter your function

Write the function with x as the variable. Use ^ for powers, * for multiplication and brackets for function arguments. The box accepts forms such as x^2, sin(x) and sqrt(1+x^2). Trigonometric functions read radians, as they do in the scientific calculator on this site, so an upper limit of 180 degrees must be entered as 3.14159265 radians.

The interval count must be positive. If you enter an odd number, the calculator rounds it up to the next even number, so 5 becomes 6. Using more intervals makes the approximation more accurate for most smooth functions, though a very rough curve may need many.

Worked examples

Example 1: the default

f(x) = x^2 from 0 to 2 with n = 10. Here h = 2 ÷ 10 = 0.2, and the calculator evaluates x squared at the eleven points 0, 0.2, 0.4 and so on up to 2. Applying the 1, 4, 2 pattern and multiplying by h ÷ 3 gives 2.666667. The exact integral is 23 ÷ 3 = 8/3 = 2.666667, so the two agree.

Example 2: a cubic, done in two strips

f(x) = x^3 from 0 to 2 with n = 2. Then h = 1 and the points are 0, 1 and 2, with f values 0, 1 and 8. The rule gives (1 ÷ 3) × [0 + 4(1) + 8] = 12 ÷ 3 = 4. The exact integral is 24 ÷ 4 = 4. Simpson’s rule is exact for polynomials up to degree three, which is why even two strips are enough here.

Example 3: a curve that is not a polynomial

f(x) = 1/x from 1 to 2 with n = 4. Here h = 0.25 and the points are 1, 1.25, 1.5, 1.75 and 2, with f values 1, 0.8, 0.666667, 0.571429 and 0.5. The sum is 1 + 4(0.8) + 2(0.666667) + 4(0.571429) + 0.5 = 8.319048. Multiplying by 0.25 ÷ 3 gives 0.693254. The exact answer is ln 2 = 0.693147, so the error is about 0.0001.

Example 4: sine over half a period

f(x) = sin(x) from 0 to 3.14159265 with n = 4. The exact integral is 2. With four strips, h = 0.785398, and the rule gives about 2.0046, an error of roughly 0.23 percent. Raising n to 10 brings the answer much closer to 2.

How accurate is the answer?

The standard error bound for Simpson’s rule is (b − a) × h4 ÷ 180 × M, where M is the largest value of the fourth derivative of f on the interval. Two things follow from it. Halving h cuts the bound by a factor of 16, so doubling n improves accuracy quickly. And any function whose fourth derivative is zero, such as a quadratic or cubic, is integrated exactly.

For Example 3, the fourth derivative of 1/x is 24/x5, which is at most 24 on the interval from 1 to 2. The bound is 1 × 0.254 ÷ 180 × 24 = 0.00052, and the actual error of 0.00011 sits well inside it.

Limits to keep in mind

  • The function must be defined and finite at every point it is evaluated, so 1/x cannot span x = 0.
  • A sharp spike or a jump between sample points can be missed. Use more intervals, or split the range.
  • The calculator gives a number, not a symbolic antiderivative.
  • The result is an area with sign: parts of the curve below the x-axis count as negative.

For a plain average of a data set rather than an integral, see the statistics calculator.

Frequently asked questions

Why must the number of intervals be even?

Simpson’s rule fits a parabola through each pair of strips, so it needs strips in pairs. If you enter an odd number, the calculator rounds it up to the next even number.

Is Simpson’s 1/3 rule more accurate than the trapezoidal rule?

For smooth curves it usually is, because parabolas follow the curve more closely than straight lines. It is exact for polynomials up to degree three.

How do I enter powers and roots in f(x)?

Use ^ for powers and sqrt for square roots, for example x^2 or sqrt(1+x^2). Use brackets around function arguments such as sin(x).

Does it use degrees or radians for sin and cos?

Radians. To integrate over 180 degrees, enter the upper limit as 3.14159265.

What does a negative result mean?

The integral counts area below the x-axis as negative. A negative total means more of the curve lies below the axis than above it.

Mark Danny

Mark Danny

Mark Danny builds and maintains the free calculators and guides on Area of Irregular Shapes Calculator. Every calculator page explains its formula and shows a worked example, so you can check the working yourself. Spotted a mistake or have a suggestion? Email gulsher.hingoro101@gmail.com.

Articles: 699