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
| x | f(x) |
|---|---|
| 0 | 0 |
| 0.15708 | 0.156434 |
| 0.314159 | 0.309017 |
| 0.471239 | 0.45399 |
| 0.628319 | 0.587785 |
| 0.785398 | 0.707107 |
| 0.942478 | 0.809017 |
| 1.099557 | 0.891007 |
| 1.256637 | 0.951057 |
| 1.413717 | 0.987688 |
| 1.570796 | 1 |
| 1.727876 | 0.987688 |
| 1.884956 | 0.951057 |
| 2.042035 | 0.891007 |
| 2.199115 | 0.809017 |
| 2.356194 | 0.707107 |
| 2.513274 | 0.587785 |
| 2.670354 | 0.45399 |
| 2.827433 | 0.309017 |
| 2.984513 | 0.156434 |
| 3.141593 | -0 |
| 3.141593 | 0 |
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
- Home
Simpson's Rule Calculator