The Simpson's rule calculator approximates definite integrals using the composite Simpson's 1/3 rule. Enter a function, lower and upper bounds, and the number of intervals to get the integral value with a full step-by-step computation table.
Function & Bounds
Use: +, -, *, /, ^, sqrt(), sin(), cos(), tan(), exp(), log(), abs(), PI, E
Result
Step-by-Step Computation
| i | xᵢ | f(xᵢ) | Coefficient | Contribution |
|---|
How to Use Simpson's Rule Calculator
Simpson's 1/3 rule is a numerical integration method that approximates definite integrals with greater accuracy than the trapezoidal rule by using parabolic arcs instead of straight-line segments.
Step 1: Enter Your Function
Type any mathematical function in terms of x. Examples: x^2, sin(x), 1/x, exp(-x*x), x^3 + 2*x - 1. Always use * for multiplication. Available functions: sin, cos, tan, sqrt, exp, log, abs. Constants: PI (~3.14159), E (~2.71828).
Step 2: Set the Integration Bounds
Enter the lower bound a and upper bound b. For ∫₀¹ x² dx, set a = 0 and b = 1. The exact answer is 1/3 ≈ 0.3333. Simpson's rule gives exactly 1/3 even with just 2 intervals because x² is a polynomial of degree ≤ 3.
Step 3: Choose Number of Intervals
The number of intervals n must be even. More intervals = more accuracy. For ∫₀^π sin(x) dx (exact answer = 2.0): n=2 gives ~2.094 (4.7% error), n=4 gives ~2.005 (0.25% error), n=10 gives ~2.0001 (0.005% error). Doubling n reduces error by ~16×.
Understanding the Step Table
The computation table shows each xᵢ value and its f(xᵢ) evaluation. The coefficients follow the pattern 1, 4, 2, 4, 2, ..., 4, 1 — endpoints get weight 1, middle points alternate between 4 (odd indices) and 2 (even indices). The final sum is multiplied by h/3 to get the approximation.
FAQ
What is Simpson's rule?
Simpson's 1/3 rule approximates a definite integral by fitting parabolas over pairs of subintervals. The formula is: ∫f(x)dx ≈ (h/3)[f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + f(xₙ)], where h = (b−a)/n. It's more accurate than the trapezoidal rule for smooth functions.
Why must the number of intervals n be even?
Simpson's rule pairs up subintervals, fitting one parabola over each pair. An odd number of intervals would leave an unpaired subinterval with no parabola to fit. Composite Simpson's 3/8 rule can use n divisible by 3, but the standard 1/3 rule requires n to be even.
How accurate is Simpson's rule?
Simpson's rule has error proportional to h⁴ × f''''(c)/180 for some c in [a,b]. For x² from 0 to 1 with just 2 intervals: exact = 1/3, Simpson = 1/3 exactly (error = 0, since x² is a polynomial of degree ≤ 3). For smoother functions, doubling n reduces error by a factor of 16.
What functions can I use?
You can use any valid JavaScript math expression: x^2, sin(x), cos(x), sqrt(x), exp(x), log(x), 1/x, x^3 + 2*x - 1, etc. Use * for multiplication (not implicit: write 2*x not 2x). Constants: PI, E. Functions: abs, ceil, floor, round, min, max.
Is this tool free?
Yes, completely free with no signup required. All calculations run locally in your browser.
Is my data private?
Yes. All computations happen in your browser. No function inputs or results are sent to any server.
How does Simpson's rule compare to the trapezoidal rule?
The trapezoidal rule fits straight lines (linear approximation), with error proportional to h². Simpson's rule fits parabolas (quadratic approximation), with error proportional to h⁴ — much more accurate for the same number of intervals. For most smooth functions, Simpson's rule needs far fewer intervals to achieve the same precision.