NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
|
Subroutine qnthsh
implements integration by tanh-sinh method.
More...
Subroutine qnthsh
implements integration by tanh-sinh method.
This routine is a simple non-adaptive automatic integrator using trapezoidal rule to integrate a the transformed integrand using the double exponential (also called tanh-sinh) method. The tahn-sinh scheme is based on the observation that the trapezoid rule converges very rapidly for functions on the entire real line that go to zero like exp( - exp(t) ). The change of variables transforms an integral over [-1, 1] into an integral with integrand suited to the double exponential rule.
The transformed integral is infinite, but we truncate the domain of integration to [-a, a] ( ). The value of is estimated from the required precision, and the value 3
was chosen for two reasons: for , the transformed values are nearly equal to 1 (up to 12 significant figures). Also, for , the smallest weights are 12 orders of magnitude smaller than the largest weights.
The integration first applies the trapezoid rule to . Then it subsequently cuts the step size in half each time, comparing the results. Integration stops when subsequent iterations are close enough together or the maximum integration points have been used. By cutting in half, the previous integral can be reused; we only need evaluate the integrand at the newly added points.
[in] | f | a real or complex function (as defined in Integrable functions) |
[in] | a | (real(dp)) are the limits of integration |
[in] | b | (real(dp)) are the limits of integration |
[out] | IntValue | (real or complex, depending on f ) Estimated value of the integral |
[in] | epsabs | (real, optional) absolute desired precision. Default: epsabs=1.e-7 |
[in] | epsrel | (real, optional) relative desired precision. Default: epsrel=1.e-5 |
[out] | abserr | (real, optional) absolute estimated error |
[out] | Neval | (integer, optional) Number of function evaluations |