What this calculator does
This tool evaluates the definite integral of a single-variable function f(x) over a finite interval [a, b] using Double-Exponential (DE) quadrature, also known as the Tanh-Sinh method. DE quadrature is one of the most reliable general-purpose methods for finite intervals and is famously good at handling integrands that blow up at an endpoint, such as \(1/\sqrt{x}\) or \(\log(x)\), where ordinary Gaussian or Simpson rules struggle.
How to use it
Type the integrand in the Integrand f(x) box using ordinary math syntax: + - * / ^, parentheses, and the functions sqrt, exp, log, ln, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, abs plus the constants pi and e. Enter the lower limit a and upper limit b, choose how many significant digits to target, and submit. Singularities are allowed only at the endpoints a and b; the function must otherwise be analytic on the open interval (a, b) and should not be periodic.
The formula explained
First the interval is mapped to [-1, 1] by \(x(u) = \frac{(b+a)+(b-a)u}{2}\). Then the DE transform \(u = \tanh\!\left(\frac{\pi}{2}\sinh t\right)\) stretches the line so that, as t grows, u approaches the endpoints super-exponentially while the weight \(g'(t)\) collapses to zero just as fast. Because the nodes never land exactly on a or b, the endpoint singularity is never actually evaluated — it is "tamed." The transformed integral is then summed with a simple trapezoidal rule of step h, and h is halved until the answer stops changing.
$$\int_{a}^{b} f(x)\,dx \;\approx\; \frac{b-a}{2}\,h\sum_{k} w_k\, f\!\left(x_k\right)$$ $$\text{where}\quad \left\{ \begin{aligned} a &= \text{Lower limit} \\ b &= \text{Upper limit} \\ x_k &= \tfrac{b+a}{2} + \tfrac{b-a}{2}\tanh\!\left(\tfrac{\pi}{2}\sinh(k h)\right) \\ w_k &= \dfrac{\tfrac{\pi}{2}\cosh(k h)}{\cosh^{2}\!\left(\tfrac{\pi}{2}\sinh(k h)\right)} \end{aligned} \right.$$
Worked example
For \(f(x) = 1/\sqrt{x}\) on [0, 1] the exact value is \(\left[2\sqrt{x}\right]_{0}^{1} = 2\). A crude 7-point DE grid (\(h = 0.5\)) already gives about 1.94; refining h drives the estimate to 2.000000000000000. A non-singular check, \(f(x) = x^2\) on [0, 1], returns \(1/3 = 0.3333333333333\).
FAQ
Can it handle a singularity inside the interval? No — DE only tolerates singularities at the endpoints. For an interior singularity at c, split the integral into [a, c] and [c, b] and add the two results.
Why is it bad for periodic functions? For smooth periodic integrands the plain trapezoidal rule already converges exponentially, so the DE change of variable only slows things down.
What does the digits setting do? It sets the relative tolerance that decides when refinement stops, and rounds the displayed value accordingly.