Integral Calculator (Numerical)
Definite integrals over [a, b]Compute the definite integral \(\displaystyle \int_a^b f(x)\,dx\) of a real-valued function using composite Simpson’s rule with refinement and an error estimate. Ideal for engineering, data analysis, and teaching calculus.
Focus: high-quality numerical integration on a finite interval. For symbolic antiderivatives and step-by-step algebra, use a CAS – then check or explore the result here.
1. Define the integral
Use x as the variable. Allowed: +, -, *, /, ^,
sin, cos, tan, asin, acos, atan, ln, log, sqrt, abs, exp, floor, ceil, max, min,
constants pi, e. Trigonometric functions use radians.
Works best when f(x) is continuous or reasonably smooth on [a, b].
Must be even. The calculator will adjust it if necessary.
Display precision for integral and sample values.
Number of (x, f(x)) pairs shown in the sample table.
2. Numerical results
3. Sample points (x, f(x)) on [a, b]
Use this table to inspect how the function behaves on the integration interval and to spot peaks, sign changes or potential numerical issues.
| x | f(x) |
|---|
What is a definite integral?
The definite integral of a function \(f(x)\) over an interval \([a, b]\) is written as
\[ \int_a^b f(x)\,\mathrm{d}x. \]
Geometrically, for functions that stay above the x-axis, this represents the signed area under the graph of \(f(x)\) from x = a to x = b. When the function crosses the axis, areas above and below the axis can cancel.
In calculus, definite integrals are defined via limits of Riemann sums, and they form one half of the fundamental theorem of calculus, connecting antiderivatives and area.
Numerical integration with Simpson’s rule
Not every integral has a closed-form antiderivative. Even when it does, in practical engineering and data analysis it is often easier to evaluate the integral numerically. Composite Simpson’s rule approximates the function by parabolas over small subintervals, then sums the areas:
Divide \([a, b]\) into \(n\) subintervals (with \(n\) even) of width \(h = \dfrac{b-a}{n}\). Let \(x_k = a + kh\) and \(f_k = f(x_k)\). Then:
\[ \int_a^b f(x)\,dx \approx \frac{h}{3} \left( f_0 + f_n + 4 \sum_{k=1,3,\dots,n-1} f_k + 2 \sum_{k=2,4,\dots,n-2} f_k \right). \]
Our calculator computes this approximation with a base number of subintervals \(n\) and again with \(2n\) subintervals; the difference \(|I_{2n} - I_n|\) is used as a simple error estimate.
Signed area, absolute area and average value
The signed integral may be small even when the graph of \(f(x)\) has large positive and negative lobes that cancel. For that reason the tool also reports:
- The absolute area \(\int_a^b |f(x)|\,dx\), which treats negative contributions as positive;
- The average value of the function on \([a,b]\): \[ f_{\text{avg}} = \frac{1}{b-a}\int_a^b f(x)\,dx. \]
These summaries are very useful in physics, signal processing and statistics (for example when computing mean energy or average load over time).
FAQ: integrals and this calculator
What is the difference between a definite and an indefinite integral?
An indefinite integral \(\int f(x)\,dx\) represents the family of antiderivatives of \(f\), written as \(F(x) + C\). A definite integral \(\int_a^b f(x)\,dx\) is a specific number, obtained (when an antiderivative exists) as \(F(b) - F(a)\). This calculator focuses on definite integrals, computed numerically.
Why do I sometimes get “NaN” or warnings?
Numerical integration assumes that the function is well-behaved on \([a, b]\). If your expression leads to division by zero, square roots of negative numbers, logarithms of non-positive values, or very steep spikes, some points may be undefined or extremely large. The calculator flags these situations so that you can adjust the interval, reformulate the problem, or use analytic methods.
How can I improve accuracy?
Try increasing the number of subintervals, as long as it stays within a reasonable range (e.g. up to a few thousands for smooth functions). You can also break the interval into pieces and integrate separately if the function behaves differently in different regions. Always interpret numerical results together with domain knowledge and, when important decisions are involved, cross-check with alternative methods.