TANH_QUAD is a FORTRAN90 library which sets up the tanh quadrature scheme and related rules.
These schemes typically have two parameters, N the (truncated) order, and H, a discretization size. To construct a family of quadrature rules, it is typical to ensure that H goes to zero as N goes to infinity. Sometimes this is done by fixing the value of the product N*H, and sometimes in other ways.
The tanh quadrature scheme approximates the integral
Integral ( -1 <= X <= 1 ) F(X) dxby
Sum ( -N <= I <= N ) W(i) * F ( X(i) )where Kahaner, Moler and Nash suggest choosing N freely, and then taking H as
H = pi * sqrt ( 2 / N ) - ( 1 / N ).and
X(i) = tanh(i*H/2)and
W(i) = H / 2 / cosh(I*H/2) / cosh(I*H/2)
This rule has some unusual properties. In particular, it is not exact for any polynomial; it can't even integrate the function f(x)=1 exactly. But while it is not exact, it can be highly accurate, that is, for relatively low values of N and for a wide range of integrals, the estimate will have a very low error, and as N increases, the error can decrease exponentially.
The tanh-sinh quadrature scheme approximates the integral
Integral ( -1 <= X <= 1 ) F(X) dxby
Sum ( -N <= I <= N ) W(i) * F ( X(i) )where Bailey suggests parameterizing by an integer M, with
N = 8 * 2^M, H = 1 / 2^M, N * H = 8.and
Ti = i * H, X(i) = tanh(pi/2*sinh(Ti))and
W(i) = H * ( pi / 2 ) * cosh(Ti) / cosh^2(pi/2*sinh(Ti))
Quadrature rules can be transformed from the [-1,1] interval to the interval [a,b] by using the rule_adjust routine.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
TANH_QUAD is available in a C++ version and a FORTRAN90 version and a MATLAB version.
CHEBYSHEV1_RULE, a FORTRAN90 program which can compute and print a Gauss-Chebyshev type 1 quadrature rule.
CHEBYSHEV2_RULE, a FORTRAN90 program which can compute and print a Gauss-Chebyshev type 2 quadrature rule.
GEGENBAUER_RULE, a FORTRAN90 program which can compute and print a Gauss-Gegenbauer quadrature rule.
GEN_HERMITE_RULE, a FORTRAN90 program which can compute and print a generalized Gauss-Hermite quadrature rule.
GEN_LAGUERRE_RULE, a FORTRAN90 program which can compute and print a generalized Gauss-Laguerre quadrature rule.
HERMITE_RULE, a FORTRAN90 program which can compute and print a Gauss-Hermite quadrature rule.
INT_EXACTNESS, a FORTRAN90 program which checks the polynomial exactness of a 1-dimensional quadrature rule for a finite interval.
INTLIB, a FORTRAN90 library which contains a variety of routines for numerical estimation of integrals in 1D.
JACOBI_RULE, a FORTRAN90 program which can compute and print a Gauss-Jacobi quadrature rule.
LAGUERRE_RULE, a FORTRAN90 program which can compute and print a Gauss-Laguerre quadrature rule.
LEGENDRE_RULE, a FORTRAN90 program which computes a Gauss-Legendre quadrature rule.
QUADRULE, a FORTRAN90 library which defines quadrature rules for 1D domains.
QUADPACK, a FORTRAN90 library which contains a variety of routines for numerical estimation of integrals in 1D.
QUADRATURE_RULES, a dataset directory which contains sets of files that define quadrature rules over various 1D intervals or multidimensional hypercubes.
TEST_INT, a FORTRAN90 library which contains a number of functions that may be used as test integrands for quadrature rules in 1D.
You can go up one level to the FORTRAN90 source codes.