Shapes & spaces

Tanh sinh quadrature calculator for integrable endpoint singularities

Integrate a smooth amplitude multiplied by explicitly declared integrable endpoint powers and optional logarithms using endpoint-clustered tanh–sinh quadrature.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Integrate a smooth amplitude multiplied by explicitly declared integrable endpoint powers and optional logarithms using endpoint-clustered tanh–sinh quadrature.

THE FORMULAx(t)=(a+b)/2+(b-a)/2*tanh((π/2)sinh(t)); I=∫ g(x)(x-a)^α(b-x)^β L_a L_b dx, α,β>-1.

A worked example

With g(x)=1, [a,b]=[0,1], alpha=-1/2, beta=0 and no logarithms, the integral is 2. Adding the left logarithm gives -4.

Good to know

Finite [a,b], integrand entered as smooth bounded g(x) times (x−a)^alpha (b−x)^beta and optional single log factors, alpha,beta in [−0.9,2]. Use tanh-sinh transform and stable endpoint distances/log evaluation, at most 10 refinement levels/20000 evaluations. No interior poles, divergent endpoints, infinite interval or blanket convergence proof; report truncation/refinement diagnostics.

Describe endpoint behavior explicitly

The input separates a smooth bounded amplitude g(x) from powers of the distances to the two endpoints. Optional logarithmic factors are also specified separately. This representation lets the numerical method evaluate the small endpoint distances directly rather than trying to recover them by subtracting two nearly equal floating-point coordinates inside an arbitrary expression.

For example, enter g(x)=1 with a left exponent of minus one half for the integral of 1/sqrt(x) over the unit interval. Do not enter the same singular factor again inside g, because that would double the intended exponent. The amplitude is assumed smooth and finite across the closed interval. A hidden interior pole violates the model even if the numerical sampler initially fails to encounter it.

Nodes accumulate near singular endpointsx⁻¹ᐟ²: area = 2Tanh–sinh nodes01
Scroll across to see the full diagram.
The endpoint is excluded while transformed nodes resolve the integrable singularity.

Compare this with the Gauss–Legendre quadrature calculator with nodes and weights. Existing fixed-order finite Gauss rule is not an improper-integral solver. Double-exponential endpoint transformation plus nested trapezoid refinement targets integrable endpoint power/log singularities without sampling the endpoints.

Check mathematical integrability first

A power x^alpha is integrable near zero exactly when alpha is greater than minus one. Multiplying by one logarithm does not change that threshold. The page uses the narrower exponent interval from minus 0.9 through two to keep accepted endpoint strengths within its numerical design. This is an implementation limit rather than a new mathematical criterion for convergence.

The two endpoints must be finite and strictly ordered. An integral with a nonintegrable endpoint cannot be repaired by stopping evaluation a little short of that endpoint. Likewise, a principal-value interpretation of an interior singularity is a different mathematical object. This calculator evaluates ordinary improper integrals with the stated endpoint structure and should reject or leave unresolved inputs outside that class.

Why the transformed nodes cluster

The tanh–sinh map sends the entire real t axis to the finite integration interval. Equal steps in t become extremely small steps near either endpoint. Its Jacobian also decays rapidly, which often transforms an endpoint-singular integrand into a function well suited to repeated trapezoidal refinements. Nodes never need to land exactly on a divergent endpoint value.

In floating-point arithmetic, a transformed x can round to an endpoint before the true endpoint distance is mathematically zero. Stable formulas must retain those distances independently, then form powers and logarithms from them. Simply discarding every node whose rounded x equals a or b can remove a substantial part of a strong singularity. Endpoint-distance evaluation is therefore a core numerical requirement rather than an optional optimization.

Verify the elementary default integral

For the default integrand x^(-1/2) on [0,1], the antiderivative is 2 sqrt(x). Its value at one is two and its limit at zero is zero, so the improper integral is exactly two. This check is sensitive to endpoint handling because a substantial fraction of the area lies near zero even though no quadrature node evaluates the singular endpoint itself.

A second independent check differentiates the identity integral_0^1 x^alpha dx=1/(alpha+1) with respect to alpha. It gives integral_0^1 x^alpha log(x) dx=-1/(alpha+1)^2. At alpha=-1/2 the answer is minus four. The negative sign is meaningful because log(x) is negative within the unit interval, and it tests the optional logarithmic factor as well as the power handling.

Interpret convergence diagnostics carefully

Each refinement reduces the transformed grid spacing and compares the new integral estimate with the preceding estimate. The reported difference measures observed numerical stabilization. Tail diagnostics assess the contributions near the truncated ends of the t range. Both are needed because a stable central sum can coexist with an inadequately sampled or prematurely truncated transformed tail.

A small successive difference is not a universal proof of an error bound. An amplitude with unmodeled rapid variation can fool a finite refinement sequence, and cancellation can make a relative stopping rule misleading when the integral is near zero. Read absolute differences, evaluation counts and termination status together. A work cap should produce an unresolved convergence status with the available estimates, rather than a confident tolerance claim.

Understand the endpoint-node illustration

The drawing shows a few transformed nodes accumulating near the left and right endpoints, together with an integrable singular curve near the left endpoint. The steep curve need not have a finite height at zero to have a finite area. The graphic emphasizes where evaluations are concentrated, not a uniform mesh or an actual inclusion of the endpoint singularity.

For an edited interval, powers of x-a and b-x carry units and introduce interval-length scaling. Substituting u=(x-a)/(b-a) shows a factor of (b-a)^(alpha+beta+1) before any logarithmic factors are expanded. Consequently, moving from [0,1] to a different interval changes more than the node locations. Check the declared distance-based expression when comparing a rescaled integral with a formula written in dimensionless coordinates.

Choose a method matched to the integrand

This tool permits at most ten refinement levels and twenty thousand evaluations. A smooth nonsingular function may be integrated more cheaply by ordinary adaptive quadrature, while an explicitly oscillatory integral may need a carrier-aware method. Endpoint clustering is valuable when the known power or logarithmic behavior is the main numerical difficulty.

Infinite intervals, interior poles and arbitrary divergent endpoints are outside this page. The calculator does not prove that an entered expression satisfies the smooth-amplitude contract. Review the expression analytically before trusting numerical convergence, then use a known special case, a change of variables or an independent integration method when the result matters. Agreement between structurally different checks is stronger evidence than repeatedly tightening the same tolerance.

A few questions, answered

Can the endpoint value be infinite?

Yes, provided the declared power and optional logarithm give an integrable singularity.

What is g(x)?

It is the remaining smooth bounded amplitude after explicit endpoint factors are removed.

Is the refinement difference a proof?

No. It is a numerical convergence diagnostic rather than a universal certified error bound.

Are interior poles supported?

No. The accepted singular structure is confined to the two declared endpoints.

Find your calculator

Start typing to explore the library.