keisoku

Simpson's Rule Calculator

Approximate a definite integral ∫f(x)dx with Simpson's 1/3 rule. Just enter f(x), the interval, and an even number of subdivisions.

Input

Enter the integrand f(x), the bounds a and b, and an even number of subdivisions n to approximate the definite integral ∫f(x)dx with Simpson''s 1/3 rule.

e.g. sin(x), x^2, exp(-x^2), 2x+1. Use variable x, constants pi and e, and functions like sin, cos, exp, log, sqrt.

Even number

Result

Simpson''s rule approximation

2.0000000108

Subdivisions n

100

Step size h

0.03141593

Trapezoidal approximation

1.9998355

Comparison with the trapezoidal rule

Difference (absolute): 0.0001645069

Function values at nodes

xf(x)
00
0.157080.156434
0.3141590.309017
0.4712390.45399
0.6283190.587785
0.7853980.707107
0.9424780.809017
1.0995570.891007
1.2566370.951057
1.4137170.987688
1.5707961
1.7278760.987688
1.8849560.951057
2.0420350.891007
2.1991150.809017
2.3561940.707107
2.5132740.587785
2.6703540.45399
2.8274330.309017
2.9845130.156434
3.141593-0
3.1415930

How it works

  • Simpson's 1/3 rule approximates a definite integral over [a, b] by dividing the interval into an even number n of subintervals and fitting a parabola (degree-2 polynomial) to each pair of subintervals.
  • With step size h = (b − a) / n, the approximation is S = h/3 × ( f₀ + 4f₁ + 2f₂ + 4f₃ + … + 4f_{n−1} + f_n ). The endpoints have coefficient 1, odd-indexed nodes have 4, and even-indexed interior nodes have 2.
  • The number of subdivisions n must be even. Increasing n generally improves accuracy; for smooth integrands the error shrinks on the order of h⁴.
  • For comparison, this tool also reports the trapezoidal-rule approximation (each subinterval modeled by a straight line). Simpson's rule is usually more accurate.
  • The integrand is evaluated by a custom expression parser without eval. It supports arithmetic, exponentiation (^), parentheses, unary minus, implicit multiplication (e.g. 2x), the variable x, constants pi and e, and the functions sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, exp, log, ln, log10, sqrt, cbrt and abs.
  • If the function diverges or is undefined inside the interval (division by zero, log of a non-positive value, etc.), the result is not reliable. The output is a numerical approximation and is not suited to integrals with singularities.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Simpson's Rule Calculator