From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../doc/html/math_toolkit/sf_gamma/digamma.html | 467 ++++++++++ .../math_toolkit/sf_gamma/gamma_derivatives.html | 107 +++ .../html/math_toolkit/sf_gamma/gamma_ratios.html | 418 +++++++++ .../doc/html/math_toolkit/sf_gamma/igamma.html | 963 +++++++++++++++++++++ .../doc/html/math_toolkit/sf_gamma/igamma_inv.html | 622 +++++++++++++ .../doc/html/math_toolkit/sf_gamma/lgamma.html | 487 +++++++++++ .../doc/html/math_toolkit/sf_gamma/polygamma.html | 409 +++++++++ .../doc/html/math_toolkit/sf_gamma/tgamma.html | 531 ++++++++++++ .../doc/html/math_toolkit/sf_gamma/trigamma.html | 205 +++++ 9 files changed, 4209 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/digamma.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_derivatives.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_ratios.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma_inv.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/lgamma.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/polygamma.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/tgamma.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_gamma/trigamma.html (limited to 'boost/libs/math/doc/html/math_toolkit/sf_gamma') diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/digamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/digamma.html new file mode 100644 index 00000000..9df5f1d9 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/digamma.html @@ -0,0 +1,467 @@ + + + +Digamma + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/digamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type digamma(T z);
+
+template <class T, class Policy>
+calculated-result-type digamma(T z, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ Returns the digamma or psi function of x. Digamma is + defined as the logarithmic derivative of the gamma function: +

+

+ +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ The return type of this function is computed using the result + type calculation rules: the result is of type double when T is an integer type, and type + T otherwise. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types. Unless otherwise specified + any floating point type that is narrower than the one shown will have effectively zero error. +

+
+

Table 6.4. Error rates for digamma

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Digamma Function: Large Values +

+
+

+ Max = 0.98ε (Mean = 0.369ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.84ε (Mean = 0.71ε))
(Rmath + 3.0.2: Max = 1.18ε (Mean = 0.331ε))
(Cephes: + Max = 0.919ε (Mean = 0.394ε)) +

+
+

+ Max = 1.39ε (Mean = 0.413ε) +

+
+

+ Max = 1.39ε (Mean = 0.413ε) +

+
+

+ Digamma Function: Near the Positive Root +

+
+

+ Max = 0.997ε (Mean = 0.527ε) +

+
+

+ Max = 0.891ε (Mean = 0.0995ε)
+
(GSL 1.16: Max = 135ε (Mean = 11.9ε))
+ (Rmath 3.0.2: Max = 2.02e+03ε (Mean = 256ε))
+ (Cephes: Max = 1.42e+04ε (Mean = 1.14e+03ε)) +

+
+

+ Max = 1.37ε (Mean = 0.477ε) +

+
+

+ Max = 1.31ε (Mean = 0.451ε) +

+
+

+ Digamma Function: Near Zero +

+
+

+ Max = 0.953ε (Mean = 0.337ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 0.953ε (Mean = 0.348ε))
(Rmath + 3.0.2: Max = 1.17ε (Mean = 0.564ε))
(Cephes: + Max = 3.5ε (Mean = 1.04ε)) +

+
+

+ Max = 0.984ε (Mean = 0.361ε) +

+
+

+ Max = 0.984ε (Mean = 0.361ε) +

+
+

+ Digamma Function: Negative Values +

+
+

+ Max = 214ε (Mean = 16.1ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 4.56e+04ε (Mean = 3.91e+03ε))
(Rmath + 3.0.2: Max = 4.6e+04ε (Mean = 3.94e+03ε))
(Cephes: + Max = 214ε (Mean = 16.4ε)) +

+
+

+ Max = 180ε (Mean = 13ε) +

+
+

+ Max = 180ε (Mean = 13ε) +

+
+

+ Digamma Function: Values near 0 +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 0.866ε (Mean = 0.387ε))
(Rmath + 3.0.2: Max = 3.58e+05ε (Mean = 1.6e+05ε))
(Cephes: + Max = 0.5ε (Mean = 0.224ε)) +

+
+

+ Max = 1ε (Mean = 0.592ε) +

+
+

+ Max = 1ε (Mean = 0.592ε) +

+
+

+ Digamma Function: Integer arguments +

+
+

+ Max = 0.992ε (Mean = 0.452ε) +

+
+

+ Max = 0.992ε (Mean = 0.215ε)

+ (GSL 1.16: Max = 1.18ε (Mean = 0.607ε))
+ (Rmath 3.0.2: Max = 4.33ε (Mean = 0.982ε))
+ (Cephes: Max = 0.992ε (Mean = 0.383ε)) +

+
+

+ Max = 0.888ε (Mean = 0.403ε) +

+
+

+ Max = 0.888ε (Mean = 0.403ε) +

+
+

+ Digamma Function: Half integer arguments +

+
+

+ Max = 0.78ε (Mean = 0.314ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.09ε (Mean = 0.531ε))
(Rmath + 3.0.2: Max = 46.2ε (Mean = 7.24ε))
(Cephes: + Max = 8.56ε (Mean = 1.44ε)) +

+
+

+ Max = 0.906ε (Mean = 0.409ε) +

+
+

+ Max = 0.906ε (Mean = 0.409ε) +

+
+
+

+ As shown above, error rates for positive arguments are generally very low. + For negative arguments there are an infinite number of irrational roots: + relative errors very close to these can be arbitrarily large, although absolute + error will remain very low. +

+
+ + Testing +
+

+ There are two sets of tests: spot values are computed using the online calculator + at functions.wolfram.com, while random test values are generated using the + high-precision reference implementation (a differentiated Lanczos + approximation see below). +

+
+ + Implementation +
+

+ The implementation is divided up into the following domains: +

+

+ For Negative arguments the reflection formula: +

+
digamma(1-x) = digamma(x) + pi/tan(pi*x);
+
+

+ is used to make x positive. +

+

+ For arguments in the range [0,1] the recurrence relation: +

+
digamma(x) = digamma(x+1) - 1/x
+
+

+ is used to shift the evaluation to [1,2]. +

+

+ For arguments in the range [1,2] a rational approximation devised + by JM is used (see below). +

+

+ For arguments in the range [2,BIG] the recurrence relation: +

+
digamma(x+1) = digamma(x) + 1/x;
+
+

+ is used to shift the evaluation to the range [1,2]. +

+

+ For arguments > BIG the asymptotic expansion: +

+

+ +

+

+ can be used. However, this expansion is divergent after a few terms: exactly + how many terms depends on the size of x. Therefore the + value of BIG must be chosen so that the series can be + truncated at a term that is too small to have any effect on the result when + evaluated at BIG. Choosing BIG=10 for up to 80-bit reals, + and BIG=20 for 128-bit reals allows the series to truncated after a suitably + small number of terms and evaluated as a polynomial in 1/(x*x). +

+

+ The arbitrary precision version of this function uses recurrence relations + until x > BIG, and then evaluation via the asymptotic expansion above. + As special cases integer and half integer arguments are handled via: +

+

+ +

+

+ +

+

+ The rational approximation devised + by JM in the range [1,2] is derived as follows. +

+

+ First a high precision approximation to digamma was constructed using a 60-term + differentiated Lanczos approximation, + the form used is: +

+

+ +

+

+ Where P(x) and Q(x) are the polynomials from the rational form of the Lanczos + sum, and P'(x) and Q'(x) are their first derivatives. The Lanzos part of + this approximation has a theoretical precision of ~100 decimal digits. However, + cancellation in the above sum will reduce that to around 99-(1/y) digits + if y is the result. This approximation was used to calculate + the positive root of digamma, and was found to agree with the value used + by Cody to 25 digits (See Math. Comp. 27, 123-127 (1973) by Cody, Strecok + and Thacher) and with the value used by Morris to 35 digits (See TOMS Algorithm + 708). +

+

+ Likewise a few spot tests agreed with values calculated using functions.wolfram.com + to >40 digits. That's sufficiently precise to insure that the approximation + below is accurate to double precision. Achieving 128-bit long double precision + requires that the location of the root is known to ~70 digits, and it's not + clear whether the value calculated by this method meets that requirement: + the difficulty lies in independently verifying the value obtained. +

+

+ The rational approximation devised + by JM was optimised for absolute error using the form: +

+
digamma(x) = (x - X0)(Y + R(x - 1));
+
+

+ Where X0 is the positive root of digamma, Y is a constant, and R(x - 1) is + the rational approximation. Note that since X0 is irrational, we need twice + as many digits in X0 as in x in order to avoid cancellation error during + the subtraction (this assumes that x is an exact value, + if it's not then all bets are off). That means that even when x is the value + of the root rounded to the nearest representable value, the result of digamma(x) + will not be zero. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_derivatives.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_derivatives.html new file mode 100644 index 00000000..d4b17a75 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_derivatives.html @@ -0,0 +1,107 @@ + + + +Derivative of the Incomplete Gamma Function + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T1, class T2>
+calculated-result-type gamma_p_derivative(T1 a, T2 x);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p_derivative(T1 a, T2 x, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ This function find some uses in statistical distributions: it implements + the partial derivative with respect to x of the incomplete + gamma function. +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ Note that the derivative of the function gamma_q + can be obtained by negating the result of this function. +

+

+ The return type of this function is computed using the result + type calculation rules when T1 and T2 are different types, + otherwise the return type is simply T1. +

+
+ + Accuracy +
+

+ Almost identical to the incomplete gamma function gamma_p: + refer to the documentation for that function for more information. +

+
+ + Implementation +
+

+ This function just expose some of the internals of the incomplete gamma function + gamma_p: refer to the + documentation for that function for more information. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_ratios.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_ratios.html new file mode 100644 index 00000000..21eb71d9 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/gamma_ratios.html @@ -0,0 +1,418 @@ + + + +Ratios of Gamma Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T1, class T2>
+calculated-result-type tgamma_ratio(T1 a, T2 b);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_ratio(T1 a, T2 b, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type tgamma_delta_ratio(T1 a, T2 delta);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_delta_ratio(T1 a, T2 delta, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+
template <class T1, class T2>
+calculated-result-type tgamma_ratio(T1 a, T2 b);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_ratio(T1 a, T2 b, const Policy&);
+
+

+ Returns the ratio of gamma functions: +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ Internally this just calls tgamma_delta_ratio(a, + b-a). +

+
template <class T1, class T2>
+calculated-result-type tgamma_delta_ratio(T1 a, T2 delta);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_delta_ratio(T1 a, T2 delta, const Policy&);
+
+

+ Returns the ratio of gamma functions: +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ Note that the result is calculated accurately even when delta + is small compared to a: indeed even if a+delta + ~ a. The function is typically used when a + is large and delta is very small. +

+

+ The return type of these functions is computed using the result + type calculation rules when T1 and T2 are different types, + otherwise the result type is simple T1. +

+

+ +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types. Unless otherwise specified + any floating point type that is narrower than the one shown will have effectively zero error. +

+
+

Table 6.7. Error rates for tgamma_delta_ratio

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma + small delta ratios +

+
+

+ Max = 10.1ε (Mean = 1.25ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 5.56ε (Mean = 0.969ε) +

+
+

+ Max = 15.4ε (Mean = 2.09ε) +

+
+

+ tgamma + small delta ratios (negative delta) +

+
+

+ Max = 8.04ε (Mean = 1.31ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 8.67ε (Mean = 1.29ε) +

+
+

+ Max = 18.3ε (Mean = 2.03ε) +

+
+

+ tgamma + small integer ratios +

+
+

+ Max = 2.74ε (Mean = 0.736ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 1.96ε (Mean = 0.677ε) +

+
+

+ Max = 1.96ε (Mean = 0.677ε) +

+
+

+ tgamma + small integer ratios (negative delta) +

+
+

+ Max = 2.15ε (Mean = 0.685ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 1.62ε (Mean = 0.451ε) +

+
+

+ Max = 1.62ε (Mean = 0.451ε) +

+
+

+ integer tgamma ratios +

+
+

+ Max = 0.968ε (Mean = 0.386ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0.997ε (Mean = 0.4ε) +

+
+

+ Max = 0.997ε (Mean = 0.4ε) +

+
+

+ integer tgamma ratios (negative delta) +

+
+

+ Max = 0.974ε (Mean = 0.184ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0.853ε (Mean = 0.176ε) +

+
+

+ Max = 0.853ε (Mean = 0.176ε) +

+
+
+
+

Table 6.8. Error rates for tgamma_ratio

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma ratios +

+
+

+ Max = 3.66ε (Mean = 1.27ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 3.09ε (Mean = 1.15ε) +

+
+

+ Max = 174ε (Mean = 61.2ε) +

+
+
+
+ + Testing +
+

+ Accuracy tests use data generated at very high precision (with NTL + RR class set at 1000-bit precision: about 300 decimal digits) and + a deliberately naive calculation of Γ(x)/Γ(y). +

+
+ + Implementation +
+

+ The implementation of these functions is very similar to that of beta, + and is based on combining similar power terms to improve accuracy and avoid + spurious overflow/underflow. +

+

+ In addition there are optimisations for the situation where delta + is a small integer: in which case this function is basically the reciprocal + of a rising factorial, or where both arguments are smallish integers: in + which case table lookup of factorials can be used to calculate the ratio. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html new file mode 100644 index 00000000..1728c612 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html @@ -0,0 +1,963 @@ + + + +Incomplete Gamma Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T1, class T2>
+calculated-result-type gamma_p(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p(T1 a, T2 z, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type gamma_q(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q(T1 a, T2 z, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type tgamma_lower(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_lower(T1 a, T2 z, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type tgamma(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma(T1 a, T2 z, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ There are four incomplete + gamma functions: two are normalised versions (also known as regularized + incomplete gamma functions) that return values in the range [0, 1], and two + are non-normalised and return values in the range [0, Γ(a)]. Users interested + in statistical applications should use the normalised + versions (gamma_p and gamma_q). +

+

+ All of these functions require a > 0 and z + >= 0, otherwise they return the result of domain_error. +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ The return type of these functions is computed using the result + type calculation rules when T1 and T2 are different types, + otherwise the return type is simply T1. +

+
template <class T1, class T2>
+calculated-result-type gamma_p(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p(T1 a, T2 z, const Policy&);
+
+

+ Returns the normalised lower incomplete gamma function of a and z: +

+

+ +

+

+ This function changes rapidly from 0 to 1 around the point z == a: +

+

+ +

+
template <class T1, class T2>
+calculated-result-type gamma_q(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q(T1 a, T2 z, const Policy&);
+
+

+ Returns the normalised upper incomplete gamma function of a and z: +

+

+ +

+

+ This function changes rapidly from 1 to 0 around the point z == a: +

+

+ +

+
template <class T1, class T2>
+calculated-result-type tgamma_lower(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma_lower(T1 a, T2 z, const Policy&);
+
+

+ Returns the full (non-normalised) lower incomplete gamma function of a and + z: +

+

+ +

+
template <class T1, class T2>
+calculated-result-type tgamma(T1 a, T2 z);
+
+template <class T1, class T2, class Policy>
+calculated-result-type tgamma(T1 a, T2 z, const Policy&);
+
+

+ Returns the full (non-normalised) upper incomplete gamma function of a and + z: +

+

+ +

+
+ + Accuracy +
+

+ The following tables give peak and mean relative errors in over various domains + of a and z, along with comparisons to the GSL-1.9 + and Cephes libraries. + Note that only results for the widest floating point type on the system are + given as narrower types have effectively + zero error. +

+

+ Note that errors grow as a grows larger. +

+

+ Note also that the higher error rates for the 80 and 128 bit long double + results are somewhat misleading: expected results that are zero at 64-bit + double precision may be non-zero - but exceptionally small - with the larger + exponent range of a long double. These results therefore reflect the more + extreme nature of the tests conducted for these types. +

+

+ All values are in units of epsilon. +

+
+

Table 6.9. Error rates for gamma_p

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma(a, z) medium values +

+
+

+ Max = 35.1ε (Mean = 6.97ε) +

+
+

+ Max = 0.955ε (Mean = 0.05ε)

+ (GSL 1.16: Max = 342ε (Mean = 45.8ε))
(Rmath + 3.0.2: Max = 389ε (Mean = 44ε))
(Cephes: + Max = 492ε (Mean = 101ε)) +

+
+

+ Max = 41ε (Mean = 8.09ε) +

+
+

+ Max = 239ε (Mean = 30.2ε) +

+
+

+ tgamma(a, z) small values +

+
+

+ Max = 1.54ε (Mean = 0.439ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 4.82ε (Mean = 0.758ε))
(Rmath + 3.0.2: Max = 1.01ε (Mean = 0.306ε))
(Cephes: + Max = 21ε (Mean = 5.65ε)) +

+
+

+ Max = 2ε (Mean = 0.461ε) +

+
+

+ Max = 2ε (Mean = 0.472ε) +

+
+

+ tgamma(a, z) large values +

+
+

+ Max = 244ε (Mean = 20.2ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.02e+03ε (Mean = 105ε))
(Rmath + 3.0.2: Max = 1.11e+03ε (Mean = 67.5ε))
(Cephes: + Max = 8.18e+06ε (Mean = 7.69e+05ε)) +

+
+

+ Max = 3.08e+04ε (Mean = 1.86e+03ε) +

+
+

+ Max = 3.02e+04ε (Mean = 1.91e+03ε) +

+
+

+ tgamma(a, z) integer and half integer values +

+
+

+ Max = 13ε (Mean = 2.93ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 128ε (Mean = 22.6ε))
(Rmath + 3.0.2: Max = 66.2ε (Mean = 12.2ε))
(Cephes: + Max = 83.6ε (Mean = 22.2ε)) +

+
+

+ Max = 11.8ε (Mean = 2.65ε) +

+
+

+ Max = 71.6ε (Mean = 9.47ε) +

+
+
+
+

Table 6.10. Error rates for gamma_q

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma(a, z) medium values +

+
+

+ Max = 23.7ε (Mean = 4.03ε) +

+
+

+ Max = 0.927ε (Mean = 0.035ε)

+ (GSL 1.16: Max = 201ε (Mean = 13.5ε))
(Rmath + 3.0.2: Max = 131ε (Mean = 12.7ε))
(Cephes: + Max = 388ε (Mean = 93.8ε)) +

+
+

+ Max = 31.3ε (Mean = 6.56ε) +

+
+

+ Max = 199ε (Mean = 26.6ε) +

+
+

+ tgamma(a, z) small values +

+
+

+ Max = 2.26ε (Mean = 0.732ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.38e+10ε (Mean = 1.05e+09ε))
+ (Rmath 3.0.2: Max = 65.6ε (Mean = 11ε))
+ (Cephes: Max = 3.42e+11ε (Mean + = 4.1e+10ε)) +

+
+

+ Max = 2.45ε (Mean = 0.832ε) +

+
+

+ Max = 2.25ε (Mean = 0.81ε) +

+
+

+ tgamma(a, z) large values +

+
+

+ Max = 470ε (Mean = 31.5ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 2.71e+04ε (Mean = 2.16e+03ε))
(Rmath + 3.0.2: Max = 1.02e+03ε (Mean = 62.7ε))
(Cephes: + Max = 8.17e+06ε (Mean = 7.7e+05ε)) +

+
+

+ Max = 6.82e+03ε (Mean = 414ε) +

+
+

+ Max = 1.15e+04ε (Mean = 733ε) +

+
+

+ tgamma(a, z) integer and half integer values +

+
+

+ Max = 8.48ε (Mean = 1.42ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 118ε (Mean = 12.5ε))
(Rmath + 3.0.2: Max = 138ε (Mean = 16.9ε))
(Cephes: + Max = 129ε (Mean = 26.5ε)) +

+
+

+ Max = 11.1ε (Mean = 2.09ε) +

+
+

+ Max = 54.7ε (Mean = 6.16ε) +

+
+
+
+

Table 6.11. Error rates for tgamma_lower

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma(a, z) medium values +

+
+

+ Max = 5.62ε (Mean = 1.43ε) +

+
+

+ Max = 0.833ε (Mean = 0.0315ε)
+
(GSL 1.16: Max = 0.833ε (Mean = 0.0315ε)) +

+
+

+ Max = 6.79ε (Mean = 1.38ε) +

+
+

+ Max = 363ε (Mean = 63.8ε) +

+
+

+ tgamma(a, z) small values +

+
+

+ Max = 1.57ε (Mean = 0.527ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 1.97ε (Mean = 0.552ε) +

+
+

+ Max = 1.97ε (Mean = 0.567ε) +

+
+

+ tgamma(a, z) integer and half integer values +

+
+

+ Max = 2.69ε (Mean = 0.866ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 4.83ε (Mean = 1.12ε) +

+
+

+ Max = 84.7ε (Mean = 17.5ε) +

+
+
+
+

Table 6.12. Error rates for tgamma (incomplete)

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma(a, z) medium values +

+
+

+ Max = 8.14ε (Mean = 1.71ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 200ε (Mean = 13.3ε)) +

+
+

+ Max = 7.35ε (Mean = 1.69ε) +

+
+

+ Max = 412ε (Mean = 95.5ε) +

+
+

+ tgamma(a, z) small values +

+
+

+ Max = 2.53ε (Mean = 0.66ε) +

+
+

+ Max = 0.753ε (Mean = 0.0474ε)
+
(GSL 1.16: Max = + 1.38e+10ε (Mean = 1.05e+09ε)) +

+
+

+ Max = 2.13ε (Mean = 0.717ε) +

+
+

+ Max = 2.13ε (Mean = 0.712ε) +

+
+

+ tgamma(a, z) integer and half integer values +

+
+

+ Max = 5.16ε (Mean = 1.44ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 117ε (Mean = 12.5ε)) +

+
+

+ Max = 5.52ε (Mean = 1.52ε) +

+
+

+ Max = 79.6ε (Mean = 20.9ε) +

+
+
+
+ + Testing +
+

+ There are two sets of tests: spot tests compare values taken from Mathworld's online evaluator + with this implementation to perform a basic "sanity check". Accuracy + tests use data generated at very high precision (using NTL's RR class set + at 1000-bit precision) using this implementation with a very high precision + 60-term Lanczos approximation, + and some but not all of the special case handling disabled. This is less + than satisfactory: an independent method should really be used, but apparently + a complete lack of such methods are available. We can't even use a deliberately + naive implementation without special case handling since Legendre's continued + fraction (see below) is unstable for small a and z. +

+
+ + Implementation +
+

+ These four functions share a common implementation since they are all related + via: +

+

+ 1) +

+

+ 2) +

+

+ 3) +

+

+ The lower incomplete gamma is computed from its series representation: +

+

+ 4) +

+

+ Or by subtraction of the upper integral from either Γ(a) or 1 when x + - (1(3x)) > a and x > 1.1/. +

+

+ The upper integral is computed from Legendre's continued fraction representation: +

+

+ 5) +

+

+ When (x > 1.1) or by subtraction of the lower integral + from either Γ(a) or 1 when x - (1(3x)) < a/. +

+

+ For x < 1.1 computation of the upper integral is + more complex as the continued fraction representation is unstable in this + area. However there is another series representation for the lower integral: +

+

+ 6) +

+

+ That lends itself to calculation of the upper integral via rearrangement + to: +

+

+ 7) +

+

+ Refer to the documentation for powm1 + and tgamma1pm1 for details + of their implementation. Note however that the precision of tgamma1pm1 + is capped to either around 35 digits, or to that of the Lanczos + approximation associated with type T - if there is one - whichever + of the two is the greater. That therefore imposes a similar limit on the + precision of this function in this region. +

+

+ For x < 1.1 the crossover point where the result + is ~0.5 no longer occurs for x ~ y. Using x + * 0.75 < a as the crossover criterion for 0.5 < + x <= 1.1 keeps the maximum value computed (whether it's the + upper or lower interval) to around 0.75. Likewise for x <= 0.5 + then using -0.4 / log(x) < a as the crossover criterion + keeps the maximum value computed to around 0.7 (whether it's the upper or + lower interval). +

+

+ There are two special cases used when a is an integer or half integer, and + the crossover conditions listed above indicate that we should compute the + upper integral Q. If a is an integer in the range 1 <= a < + 30 then the following finite sum is used: +

+

+ 9) +

+

+ While for half integers in the range 0.5 <= a < 30 + then the following finite sum is used: +

+

+ 10) +

+

+ These are both more stable and more efficient than the continued fraction + alternative. +

+

+ When the argument a is large, and x ~ a + then the series (4) and continued fraction (5) above are very slow to converge. + In this area an expansion due to Temme is used: +

+

+ 11) +

+

+ 12) +

+

+ 13) +

+

+ 14) +

+

+ The double sum is truncated to a fixed number of terms - to give a specific + target precision - and evaluated as a polynomial-of-polynomials. There are + versions for up to 128-bit long double precision: types requiring greater + precision than that do not use these expansions. The coefficients Ckn are + computed in advance using the recurrence relations given by Temme. The zone + where these expansions are used is +

+
(a > 20) && (a < 200) && fabs(x-a)/a < 0.4
+
+

+ And: +

+
(a > 200) && (fabs(x-a)/a < 4.5/sqrt(a))
+
+

+ The latter range is valid for all types up to 128-bit long doubles, and is + designed to ensure that the result is larger than 10-6, the first range is + used only for types up to 80-bit long doubles. These domains are narrower + than the ones recommended by either Temme or Didonato and Morris. However, + using a wider range results in large and inexact (i.e. computed) values being + passed to the exp and erfc functions resulting in significantly + larger error rates. In other words there is a fine trade off here between + efficiency and error. The current limits should keep the number of terms + required by (4) and (5) to no more than ~20 at double precision. +

+

+ For the normalised incomplete gamma functions, calculation of the leading + power terms is central to the accuracy of the function. For smallish a and + x combining the power terms with the Lanczos + approximation gives the greatest accuracy: +

+

+ 15) +

+

+ In the event that this causes underflow/overflow then the exponent can be + reduced by a factor of a and brought inside the power + term. +

+

+ When a and x are large, we end up with a very large exponent with a base + near one: this will not be computed accurately via the pow function, and + taking logs simply leads to cancellation errors. The worst of the errors + can be avoided by using: +

+

+ 16) +

+

+ when a-x is small and a and x are large. There is still + a subtraction and therefore some cancellation errors - but the terms are + small so the absolute error will be small - and it is absolute rather than + relative error that counts in the argument to the exp + function. Note that for sufficiently large a and x the errors will still + get you eventually, although this does delay the inevitable much longer than + other methods. Use of log(1+x)-x here is inspired by + Temme (see references below). +

+
+ + References +
+
    +
  • + N. M. Temme, A Set of Algorithms for the Incomplete Gamma Functions, + Probability in the Engineering and Informational Sciences, 8, 1994. +
  • +
  • + N. M. Temme, The Asymptotic Expansion of the Incomplete Gamma Functions, + Siam J. Math Anal. Vol 10 No 4, July 1979, p757. +
  • +
  • + A. R. Didonato and A. H. Morris, Computation of the Incomplete Gamma + Function Ratios and their Inverse. ACM TOMS, Vol 12, No 4, Dec 1986, + p377. +
  • +
  • + W. Gautschi, The Incomplete Gamma Functions Since Tricomi, In Tricomi's + Ideas and Contemporary Applied Mathematics, Atti dei Convegni Lincei, + n. 147, Accademia Nazionale dei Lincei, Roma, 1998, pp. 203--237. http://citeseer.ist.psu.edu/gautschi98incomplete.html +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma_inv.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma_inv.html new file mode 100644 index 00000000..a84fe53a --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/igamma_inv.html @@ -0,0 +1,622 @@ + + + +Incomplete Gamma Function Inverses + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T1, class T2>
+calculated-result-type gamma_q_inv(T1 a, T2 q);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q_inv(T1 a, T2 q, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type gamma_p_inv(T1 a, T2 p);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p_inv(T1 a, T2 p, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type gamma_q_inva(T1 x, T2 q);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q_inva(T1 x, T2 q, const Policy&);
+
+template <class T1, class T2>
+calculated-result-type gamma_p_inva(T1 x, T2 p);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p_inva(T1 x, T2 p, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ There are four incomplete + gamma function inverses which either compute x + given a and p or q, + or else compute a given x and either + p or q. +

+

+ The return type of these functions is computed using the result + type calculation rules when T1 and T2 are different types, + otherwise the return type is simply T1. +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+
+ + + + + +
[Tip]Tip
+

+ When people normally talk about the inverse of the incomplete gamma function, + they are talking about inverting on parameter x. These + are implemented here as gamma_p_inv and gamma_q_inv, and are by far the + most efficient of the inverses presented here. +

+

+ The inverse on the a parameter finds use in some statistical + applications but has to be computed by rather brute force numerical techniques + and is consequently several times slower. These are implemented here as + gamma_p_inva and gamma_q_inva. +

+
+
template <class T1, class T2>
+calculated-result-type gamma_q_inv(T1 a, T2 q);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q_inv(T1 a, T2 q, const Policy&);
+
+

+ Returns a value x such that: q + = gamma_q(a, + x); +

+

+ Requires: a > 0 and 1 >= p,q >= 0. +

+
template <class T1, class T2>
+calculated-result-type gamma_p_inv(T1 a, T2 p);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p_inv(T1 a, T2 p, const Policy&);
+
+

+ Returns a value x such that: p + = gamma_p(a, + x); +

+

+ Requires: a > 0 and 1 >= p,q >= 0. +

+
template <class T1, class T2>
+calculated-result-type gamma_q_inva(T1 x, T2 q);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_q_inva(T1 x, T2 q, const Policy&);
+
+

+ Returns a value a such that: q + = gamma_q(a, + x); +

+

+ Requires: x > 0 and 1 >= p,q >= 0. +

+
template <class T1, class T2>
+calculated-result-type gamma_p_inva(T1 x, T2 p);
+
+template <class T1, class T2, class Policy>
+calculated-result-type gamma_p_inva(T1 x, T2 p, const Policy&);
+
+

+ Returns a value a such that: p + = gamma_p(a, + x); +

+

+ Requires: x > 0 and 1 >= p,q >= 0. +

+
+ + Accuracy +
+

+ The accuracy of these functions doesn't vary much by platform or by the type + T. Given that these functions are computed by iterative methods, they are + deliberately "detuned" so as not to be too accurate: it is in any + case impossible for these function to be more accurate than the regular forward + incomplete gamma functions. In practice, the accuracy of these functions + is very similar to that of gamma_p + and gamma_q functions: +

+
+

Table 6.13. Error rates for gamma_p_inv

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ incomplete gamma inverse(a, z) medium values +

+
+

+ Max = 1.01ε (Mean = 0.307ε) +

+
+

+ Max = 0.993ε (Mean = 0.15ε)

+ (Rmath 3.0.2: Max = 4.88ε (Mean = 0.868ε)) +

+
+

+ Max = 1.62ε (Mean = 0.365ε) +

+
+

+ Max = 1.86ε (Mean = 0.405ε) +

+
+

+ incomplete gamma inverse(a, z) large values +

+
+

+ Max = 0.924ε (Mean = 0.118ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = 0.816ε (Mean = 0.0874ε)) +

+
+

+ Max = 0.509ε (Mean = 0.0447ε) +

+
+

+ Max = 0.509ε (Mean = 0.0447ε) +

+
+

+ incomplete gamma inverse(a, z) small values +

+
+

+ Max = 1.1e+003ε (Mean = 108ε) +

+
+

+ Max = 441ε (Mean = 53.9ε)

+ (Rmath 3.0.2: Max = 547ε (Mean = 61.6ε)) +

+
+

+ Max = 9.17e+03ε (Mean = 1.32e+03ε) +

+
+

+ Max = 1.09e+04ε (Mean = 1.46e+03ε) +

+
+
+
+

Table 6.14. Error rates for gamma_q_inv

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ incomplete gamma inverse(a, z) medium values +

+
+

+ Max = 3.46ε (Mean = 0.475ε) +

+
+

+ Max = 0.912ε (Mean = 0.154ε)

+ (Rmath 3.0.2: Max = 4.66ε (Mean = 0.792ε)) +

+
+

+ Max = 6.2ε (Mean = 0.659ε) +

+
+

+ Max = 6.2ε (Mean = 0.661ε) +

+
+

+ incomplete gamma inverse(a, z) large values +

+
+

+ Max = 0.814ε (Mean = 0.0856ε) +

+
+

+ Max = 0.894ε (Mean = 0.0915ε)
+
(Rmath 3.0.2: Max = 0.894ε (Mean = 0.106ε)) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ incomplete gamma inverse(a, z) small values +

+
+

+ Max = 451ε (Mean = 65ε) +

+
+

+ Max = 292ε (Mean = 36.4ε)

+ (Rmath 3.0.2: Max = 415ε (Mean = 48.7ε)) +

+
+

+ Max = 8.28e+03ε (Mean = 963ε) +

+
+

+ Max = 8.98e+03ε (Mean = 877ε) +

+
+
+
+

Table 6.15. Error rates for gamma_p_inva

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Incomplete gamma inverses. +

+
+

+ Max = 3.52ε (Mean = 0.997ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 6.44ε (Mean = 1.1ε) +

+
+

+ Max = 4.08ε (Mean = 1.12ε) +

+
+
+
+

Table 6.16. Error rates for gamma_q_inva

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Incomplete gamma inverses. +

+
+

+ Max = 5.64ε (Mean = 1.09ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 6.91ε (Mean = 1.17ε) +

+
+

+ Max = 7.86ε (Mean = 1.25ε) +

+
+
+
+ + Testing +
+

+ There are two sets of tests: +

+
    +
  • + Basic sanity checks attempt to "round-trip" from a + and x to p or q + and back again. These tests have quite generous tolerances: in general + both the incomplete gamma, and its inverses, change so rapidly that round + tripping to more than a couple of significant digits isn't possible. + This is especially true when p or q + is very near one: in this case there isn't enough "information content" + in the input to the inverse function to get back where you started. +
  • +
  • + Accuracy checks using high precision test values. These measure the accuracy + of the result, given exact input values. +
  • +
+
+ + Implementation +
+

+ The functions gamma_p_inv and gamma_q_inv + share a common implementation. +

+

+ First an initial approximation is computed using the methodology described + in: +

+

+ A. + R. Didonato and A. H. Morris, Computation of the Incomplete Gamma Function + Ratios and their Inverse, ACM Trans. Math. Software 12 (1986), 377-393. +

+

+ Finally, the last few bits are cleaned up using Halley iteration, the iteration + limit is set to 2/3 of the number of bits in T, which by experiment is sufficient + to ensure that the inverses are at least as accurate as the normal incomplete + gamma functions. In testing, no more than 3 iterations are required to produce + a result as accurate as the forward incomplete gamma function, and in many + cases only one iteration is required. +

+

+ The functions gamma_p_inva and gamma_q_inva also share a common implementation + but are handled separately from gamma_p_inv and gamma_q_inv. +

+

+ An initial approximation for a is computed very crudely + so that gamma_p(a, x) ~ 0.5, this value is then used + as a starting point for a generic derivative-free root finding algorithm. + As a consequence, these two functions are rather more expensive to compute + than the gamma_p_inv or gamma_q_inv functions. Even so, the root is usually + found in fewer than 10 iterations. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/lgamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/lgamma.html new file mode 100644 index 00000000..86127f28 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/lgamma.html @@ -0,0 +1,487 @@ + + + +Log Gamma + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type lgamma(T z);
+
+template <class T, class Policy>
+calculated-result-type lgamma(T z, const Policy&);
+
+template <class T>
+calculated-result-type lgamma(T z, int* sign);
+
+template <class T, class Policy>
+calculated-result-type lgamma(T z, int* sign, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ The lgamma function + is defined by: +

+

+ +

+

+ The second form of the function takes a pointer to an integer, which if non-null + is set on output to the sign of tgamma(z). +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ +

+

+ There are effectively two versions of this function internally: a fully generic + version that is slow, but reasonably accurate, and a much more efficient + approximation that is used where the number of digits in the significand + of T correspond to a certain Lanczos + approximation. In practice, any built-in floating-point type you will + encounter has an appropriate Lanczos + approximation defined for it. It is also possible, given enough machine + time, to generate further Lanczos approximation's + using the program libs/math/tools/lanczos_generator.cpp. +

+

+ The return type of these functions is computed using the result + type calculation rules: the result is of type double if T is an integer type, or type T + otherwise. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types, along with comparisons + to various other libraries. Unless otherwise specified any floating point + type that is narrower than the one shown will have effectively + zero error. +

+

+ Note that while the relative errors near the positive roots of lgamma are + very low, the lgamma function has an infinite number of irrational roots + for negative arguments: very close to these negative roots only a low absolute + error can be guaranteed. +

+
+

Table 6.3. Error rates for lgamma

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ factorials +

+
+

+ Max = 0.914ε (Mean = 0.167ε)

+ (<math.h>: Max = 0.958ε (Mean = 0.38ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 33.6ε (Mean = 2.78ε))
(Rmath + 3.0.2: Max = 1.55ε (Mean = 0.592ε))
(Cephes: + Max = 1.55ε (Mean = 0.512ε)) +

+
+

+ Max = 0.991ε (Mean = 0.311ε)

+ (<tr1/cmath>: Max = 1.67ε (Mean = 0.487ε))
+ (<math.h>: Max = 1.67ε (Mean = 0.487ε)) +

+
+

+ Max = 0.991ε (Mean = 0.383ε)

+ (<math.h>: Max = 1.36ε (Mean = 0.476ε)) +

+
+

+ near 0 +

+
+

+ Max = 0.964ε (Mean = 0.462ε)

+ (<math.h>: Max = 0.962ε (Mean = 0.372ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 5.21ε (Mean = 1.57ε))
(Rmath + 3.0.2: Max = 0ε (Mean = 0ε))
(Cephes: + Max = 1.16ε (Mean = 0.341ε)) +

+
+

+ Max = 1.42ε (Mean = 0.566ε)

+ (<tr1/cmath>: Max = 0.964ε (Mean = 0.543ε))
+ (<math.h>: Max = 0.964ε (Mean = 0.543ε)) +

+
+

+ Max = 1.42ε (Mean = 0.566ε)

+ (<math.h>: Max = 0.964ε (Mean = 0.543ε)) +

+
+

+ near 1 +

+
+

+ Max = 0.867ε (Mean = 0.468ε)

+ (<math.h>: Max = 0.906ε (Mean = 0.565ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 442ε (Mean = 88.8ε))
(Rmath + 3.0.2: Max = 7.99e+04ε (Mean = 1.68e+04ε))
(Cephes: + Max = 1.14e+05ε (Mean = 2.64e+04ε)) +

+
+

+ Max = 0.948ε (Mean = 0.36ε)

+ (<tr1/cmath>: Max = 0.615ε (Mean = 0.096ε))
+ (<math.h>: Max = 0.615ε (Mean = 0.096ε)) +

+
+

+ Max = 0.866ε (Mean = 0.355ε)

+ (<math.h>: Max = 1.71ε (Mean = 0.581ε)) +

+
+

+ near 2 +

+
+

+ Max = 0.591ε (Mean = 0.159ε)

+ (<math.h>: Max = 0.741ε (Mean = 0.473ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.17e+03ε (Mean = 274ε))
(Rmath + 3.0.2: Max = 2.63e+05ε (Mean = 5.84e+04ε))
(Cephes: + Max = 5.08e+05ε (Mean = 9.04e+04ε)) +

+
+

+ Max = 0.878ε (Mean = 0.242ε)

+ (<tr1/cmath>: Max = 0.741ε (Mean = 0.263ε))
+ (<math.h>: Max = 0.741ε (Mean = 0.263ε)) +

+
+

+ Max = 0.878ε (Mean = 0.241ε)

+ (<math.h>: Max = 0.598ε (Mean = 0.235ε)) +

+
+

+ near -10 +

+
+

+ Max = 4.22ε (Mean = 1.33ε)

+ (<math.h>: Max = 0.997ε (Mean = 0.444ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 24.9ε (Mean = 4.6ε))
(Rmath + 3.0.2: Max = 2.41e+05ε (Mean = 4.29e+04ε))
(Cephes: + Max = 0.997ε (Mean = 0.429ε)) +

+
+

+ Max = 3.81ε (Mean = 1.01ε)

+ (<tr1/cmath>: Max = 3.01ε (Mean = 0.86ε))
+ (<math.h>: Max = 3.01ε (Mean = 0.86ε)) +

+
+

+ Max = 3.81ε (Mean = 1.01ε)

+ (<math.h>: Max = 3.04ε (Mean = 1.01ε)) +

+
+

+ near -55 +

+
+

+ Max = 0.821ε (Mean = 0.419ε)

+ (<math.h>: Max = 249ε (Mean = 43.1ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 7.02ε (Mean = 1.47ε))
(Rmath + 3.0.2: Max = 4.08e+04ε (Mean = 7.26e+03ε))
(Cephes: + Max = 1.64ε (Mean = 0.693ε)) +

+
+

+ Max = 0.821ε (Mean = 0.513ε)

+ (<tr1/cmath>: Max = 1.58ε (Mean = 0.672ε))
+ (<math.h>: Max = 1.58ε (Mean = 0.672ε)) +

+
+

+ Max = 1.59ε (Mean = 0.587ε)

+ (<math.h>: Max = 0.821ε (Mean = 0.674ε)) +

+
+
+
+ + Testing +
+

+ The main tests for this function involve comparisons against the logs of + the factorials which can be independently calculated to very high accuracy. +

+

+ Random tests in key problem areas are also used. +

+
+ + Implementation +
+

+ The generic version of this function is implemented using Sterling's approximation + for large arguments: +

+

+ +

+

+ For small arguments, the logarithm of tgamma is used. +

+

+ For negative z the logarithm version of the reflection + formula is used: +

+

+ +

+

+ For types of known precision, the Lanczos + approximation is used, a traits class boost::math::lanczos::lanczos_traits + maps type T to an appropriate approximation. The logarithmic version of the + Lanczos approximation is: +

+

+ +

+

+ Where Le,g   is the Lanczos sum, scaled by eg. +

+

+ As before the reflection formula is used for z < 0. +

+

+ When z is very near 1 or 2, then the logarithmic version of the Lanczos + approximation suffers very badly from cancellation error: indeed for + values sufficiently close to 1 or 2, arbitrarily large relative errors can + be obtained (even though the absolute error is tiny). +

+

+ For types with up to 113 bits of precision (up to and including 128-bit long + doubles), root-preserving rational approximations devised + by JM are used over the intervals [1,2] and [2,3]. Over the interval + [2,3] the approximation form used is: +

+
lgamma(z) = (z-2)(z+1)(Y + R(z-2));
+
+

+ Where Y is a constant, and R(z-2) is the rational approximation: optimised + so that it's absolute error is tiny compared to Y. In addition small values + of z greater than 3 can handled by argument reduction using the recurrence + relation: +

+
lgamma(z+1) = log(z) + lgamma(z);
+
+

+ Over the interval [1,2] two approximations have to be used, one for small + z uses: +

+
lgamma(z) = (z-1)(z-2)(Y + R(z-1));
+
+

+ Once again Y is a constant, and R(z-1) is optimised for low absolute error + compared to Y. For z > 1.5 the above form wouldn't converge to a minimax + solution but this similar form does: +

+
lgamma(z) = (2-z)(1-z)(Y + R(2-z));
+
+

+ Finally for z < 1 the recurrence relation can be used to move to z > + 1: +

+
lgamma(z) = lgamma(z+1) - log(z);
+
+

+ Note that while this involves a subtraction, it appears not to suffer from + cancellation error: as z decreases from 1 the -log(z) term grows positive much more rapidly than + the lgamma(z+1) term becomes negative. So in this specific + case, significant digits are preserved, rather than cancelled. +

+

+ For other types which do have a Lanczos + approximation defined for them the current solution is as follows: + imagine we balance the two terms in the Lanczos + approximation by dividing the power term by its value at z + = 1, and then multiplying the Lanczos coefficients by the same + value. Now each term will take the value 1 at z = 1 + and we can rearrange the power terms in terms of log1p. Likewise if we subtract + 1 from the Lanczos sum part (algebraically, by subtracting the value of each + term at z = 1), we obtain a new summation that can be + also be fed into log1p. Crucially, all of the terms tend to zero, as z + -> 1: +

+

+ +

+

+ The Ck   terms in the above are the same as in the Lanczos + approximation. +

+

+ A similar rearrangement can be performed at z = 2: +

+

+ +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/polygamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/polygamma.html new file mode 100644 index 00000000..850f88be --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/polygamma.html @@ -0,0 +1,409 @@ + + + +Polygamma + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/polygamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type polygamma(int n, T z);
+
+template <class T, class Policy>
+calculated-result-type polygamma(int n, T z, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ Returns the polygamma function of x. Polygamma is defined + as the n'th derivative of the digamma function: +

+

+ +

+

+ The following graphs illustrate the behaviour of the function for odd and + even order: +

+

+ + +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ The return type of this function is computed using the result + type calculation rules: the result is of type double when T is an integer type, and type + T otherwise. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types. Unless otherwise specified + any floating point type that is narrower than the one shown will have effectively zero error. +

+
+

Table 6.6. Error rates for polygamma

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Mathematica Data +

+
+

+ Max = 6.34ε (Mean = 1.53ε) +

+
+

+ Max = 0.824ε (Mean = 0.0574ε)
+
(Rmath 3.0.2: Max = 108ε (Mean = 15.2ε))
+ (GSL 1.16: Max = 62.9ε (Mean = 12.8ε)) +

+
+

+ Max = 7.38ε (Mean = 1.84ε) +

+
+

+ Max = 18.3ε (Mean = 4.16ε) +

+
+

+ Mathematica Data - large arguments +

+
+

+ Max = 150ε (Mean = 15.1ε) +

+
+

+ Max = 0.998ε (Mean = 0.0592ε)
+
(Rmath 3.0.2: Max + = 1.71e+56ε (Mean = 1.01e+55ε) And + other failures.)
(GSL 1.16: + Max = 244ε (Mean = 32.8ε) And + other failures.) +

+
+

+ Max = 2.23ε (Mean = 0.323ε) +

+
+

+ Max = 2.35ε (Mean = 0.34ε) +

+
+

+ Mathematica Data - negative arguments +

+
+

+ Max = 497ε (Mean = 129ε) +

+
+

+ Max = 0.516ε (Mean = 0.022ε)

+ (Rmath 3.0.2: Max = +INFε (Mean + = +INFε) And + other failures.)
(GSL 1.16: + Max = 36.6ε (Mean = 3.04ε) And + other failures.) +

+
+

+ Max = 269ε (Mean = 87.7ε) +

+
+

+ Max = 269ε (Mean = 87.9ε) +

+
+

+ Mathematica Data - large negative arguments +

+
+

+ Max = 162ε (Mean = 101ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = +INFε (Mean = +INFε) And + other failures.)
(GSL 1.16: + Max = 1.79ε (Mean = 0.197ε) And + other failures.) +

+
+

+ Max = 155ε (Mean = 96.4ε) +

+
+

+ Max = 155ε (Mean = 96.4ε) +

+
+

+ Mathematica Data - small arguments +

+
+

+ Max = 3ε (Mean = 0.496ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = 106ε (Mean = 20ε))
(GSL 1.16: + Max = 15.2ε (Mean = 5.03ε)) +

+
+

+ Max = 3.33ε (Mean = 0.75ε) +

+
+

+ Max = 3.33ε (Mean = 0.75ε) +

+
+

+ Mathematica Data - Large orders and other bug cases +

+
+

+ Max = 200ε (Mean = 57.2ε) +

+
+

+ Max = 0ε (Mean = 0ε)

(Rmath + 3.0.2: Max = +INFε (Mean = +INFε) And + other failures.)
(GSL 1.16: + Max = 151ε (Mean = 39.3ε) And + other failures.) +

+
+

+ Max = 54.5ε (Mean = 13.3ε) +

+
+

+ Max = 90.1ε (Mean = 30.6ε) +

+
+
+

+ As shown above, error rates are generally very acceptable for moderately + sized arguments. Error rates should stay low for exact inputs, however, please + note that the function becomes exceptionally sensitive to small changes in + input for large n and negative x, indeed for cases where n! + would overflow, the function changes directly from -∞ to +∞ somewhere between + each negative integer - these cases are not handled correctly. +

+

+ For these reasons results should be treated with extreme + caution when n is large and x negative. +

+
+ + Testing +
+

+ Testing is against Mathematica generated spot values to 35 digit precision. +

+
+ + Implementation +
+

+ For x < 0 the following reflection formula is used: +

+

+ +

+

+ The n'th derivative of cot(x) is tabulated for small + n, and for larger n has the general form: +

+

+ +

+

+ The coefficients of the cosine terms can be calculated iteratively starting + from C1,0 = -1 and then using +

+

+ +

+

+ to generate coefficients for n+1. +

+

+ Note that every other coefficient is zero, and therefore what we have are + even or odd polynomials depending on whether n is even or odd. +

+

+ Once x is positive then we have two methods available to us, for small x + we use the series expansion: +

+

+ +

+

+ Note that the evaluation of zeta functions at integer values is essentially + a table lookup as zeta is + optimized for those cases. +

+

+ For large x we use the asymptotic expansion: +

+

+ +

+

+ For x in-between the two extremes we use the relation: +

+

+ +

+

+ to make x large enough for the asymptotic expansion to be used. +

+

+ There are also two special cases: +

+

+ +

+

+ +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/tgamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/tgamma.html new file mode 100644 index 00000000..7415b7a7 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/tgamma.html @@ -0,0 +1,531 @@ + + + +Gamma + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+Gamma +

+
+ + Synopsis +
+
#include <boost/math/special_functions/gamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type tgamma(T z);
+
+template <class T, class Policy>
+calculated-result-type tgamma(T z, const Policy&);
+
+template <class T>
+calculated-result-type tgamma1pm1(T dz);
+
+template <class T, class Policy>
+calculated-result-type tgamma1pm1(T dz, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+
template <class T>
+calculated-result-type tgamma(T z);
+
+template <class T, class Policy>
+calculated-result-type tgamma(T z, const Policy&);
+
+

+ Returns the "true gamma" (hence name tgamma) of value z: +

+

+ +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ There are effectively two versions of the tgamma + function internally: a fully generic version that is slow, but reasonably + accurate, and a much more efficient approximation that is used where the + number of digits in the significand of T correspond to a certain Lanczos + approximation. In practice any built in floating point type you will + encounter has an appropriate Lanczos + approximation defined for it. It is also possible, given enough machine + time, to generate further Lanczos approximation's + using the program libs/math/tools/lanczos_generator.cpp. +

+

+ The return type of this function is computed using the result + type calculation rules: the result is double + when T is an integer type, and T otherwise. +

+
template <class T>
+calculated-result-type tgamma1pm1(T dz);
+
+template <class T, class Policy>
+calculated-result-type tgamma1pm1(T dz, const Policy&);
+
+

+ Returns tgamma(dz + 1) - 1. + Internally the implementation does not make use of the addition and subtraction + implied by the definition, leading to accurate results even for very small + dz. However, the implementation + is capped to either 35 digit accuracy, or to the precision of the Lanczos + approximation associated with type T, whichever is more accurate. +

+

+ The return type of this function is computed using the result + type calculation rules: the result is double + when T is an integer type, and T otherwise. +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types, along with comparisons + to other common libraries. Unless otherwise specified any floating point + type that is narrower than the one shown will have effectively + zero error. +

+
+

Table 6.1. Error rates for tgamma

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ factorials +

+
+

+ Max = 1.85ε (Mean = 0.491ε)

+ (<math.h>: Max = 3.17ε (Mean = 0.928ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 3.95ε (Mean = 0.783ε))
(Rmath + 3.0.2: Max = 314ε (Mean = 93.4ε))
(Cephes: + Max = 3.19ε (Mean = 0.884ε)) +

+
+

+ Max = 1.96ε (Mean = 0.483ε)

+ (<tr1/cmath>: Max = 1.66ε (Mean = 0.584ε))
+ (<math.h>: Max = 1.66ε (Mean = 0.584ε)) +

+
+

+ Max = 172ε (Mean = 41ε)

+ (<math.h>: Max = 0ε (Mean = 0ε)) +

+
+

+ near 0 +

+
+

+ Max = 1.96ε (Mean = 0.684ε)

+ (<math.h>: Max = 1ε (Mean = 0.405ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 4.51ε (Mean = 1.92ε))
(Rmath + 3.0.2: Max = 1ε (Mean = 0.335ε))
(Cephes: + Max = 1ε (Mean = 0.548ε)) +

+
+

+ Max = 2ε (Mean = 0.73ε)

+ (<tr1/cmath>: Max = 1ε (Mean = 0.376ε))
+ (<math.h>: Max = 1ε (Mean = 0.376ε)) +

+
+

+ Max = 2ε (Mean = 0.647ε)

+ (<math.h>: Max = 0.5ε (Mean = 0.0791ε)) +

+
+

+ near 1 +

+
+

+ Max = 2ε (Mean = 0.865ε)

+ (<math.h>: Max = 1ε (Mean = 0.4ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 4.41ε (Mean = 1.81ε))
(Rmath + 3.0.2: Max = 1ε (Mean = 0.32ε))
(Cephes: + Max = 1ε (Mean = 0.518ε)) +

+
+

+ Max = 2ε (Mean = 0.85ε)

+ (<tr1/cmath>: Max = 0.918ε (Mean = 0.203ε))
+ (<math.h>: Max = 0.918ε (Mean = 0.203ε)) +

+
+

+ Max = 3.01ε (Mean = 1.06ε)

+ (<math.h>: Max = 1ε (Mean = 0.175ε)) +

+
+

+ near 2 +

+
+

+ Max = 2ε (Mean = 0.995ε)

+ (<math.h>: Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 7.95ε (Mean = 3.12ε))
(Rmath + 3.0.2: Max = 1ε (Mean = 0.191ε))
(Cephes: + Max = 1.09ε (Mean = 0.502ε)) +

+
+

+ Max = 2ε (Mean = 0.913ε)

+ (<tr1/cmath>: Max = 0.558ε (Mean = 0.298ε))
+ (<math.h>: Max = 0.558ε (Mean = 0.298ε)) +

+
+

+ Max = 5.01ε (Mean = 1.89ε)

+ (<math.h>: Max = 0ε (Mean = 0ε)) +

+
+

+ near -10 +

+
+

+ Max = 1.73ε (Mean = 0.729ε)

+ (<math.h>: Max = 0.866ε (Mean = 0.445ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 2.6ε (Mean = 1.05ε))
(Rmath + 3.0.2: Max = 6.34e+05ε (Mean = 1.2e+05ε))
(Cephes: + Max = 2.6ε (Mean = 0.956ε)) +

+
+

+ Max = 2.6ε (Mean = 0.985ε)

+ (<tr1/cmath>: Max = 2.26ε (Mean = 1.08ε))
+ (<math.h>: Max = 2.26ε (Mean = 1.08ε)) +

+
+

+ Max = 1.75ε (Mean = 0.819ε)

+ (<math.h>: Max = 0ε (Mean = 0ε)) +

+
+

+ near -55 +

+
+

+ Max = 1.8ε (Mean = 0.817ε)

+ (<math.h>: Max = 3.87e+004ε (Mean = 6.71e+003ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 1.8ε (Mean = 0.782ε))
(Rmath + 3.0.2: Max = 6.36e+06ε (Mean = 1.13e+06ε))
(Cephes: + Max = 2.7ε (Mean = 0.988ε)) +

+
+

+ Max = 1.8ε (Mean = 0.847ε)

+ (<tr1/cmath>: Max = 1.79ε (Mean = 0.75ε))
+ (<math.h>: Max = 1.79ε (Mean = 0.75ε)) +

+
+

+ Max = 98.5ε (Mean = 53.4ε)

+ (<math.h>: Max = 0ε (Mean = 0ε)) +

+
+
+
+

Table 6.2. Error rates for tgamma1pm1

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ tgamma1pm1(dz) +

+
+

+ Max = 0.982ε (Mean = 0.399ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 1.12ε (Mean = 0.49ε) +

+
+

+ Max = 3.97ε (Mean = 0.713ε) +

+
+
+
+ + Testing +
+

+ The gamma is relatively easy to test: factorials and half-integer factorials + can be calculated exactly by other means and compared with the gamma function. + In addition, some accuracy tests in known tricky areas were computed at high + precision using the generic version of this function. +

+

+ The function tgamma1pm1 is + tested against values calculated very naively using the formula tgamma(1+dz)-1 with a + lanczos approximation accurate to around 100 decimal digits. +

+
+ + Implementation +
+

+ The generic version of the tgamma + function is implemented Sterling's approximation for lgamma for large z: +

+

+ +

+

+ Following exponentiation, downward recursion is then used for small values + of z. +

+

+ For types of known precision the Lanczos + approximation is used, a traits class boost::math::lanczos::lanczos_traits + maps type T to an appropriate approximation. +

+

+ For z in the range -20 < z < 1 then recursion is used to shift to z + > 1 via: +

+

+ +

+

+ For very small z, this helps to preserve the identity: +

+

+ +

+

+ For z < -20 the reflection formula: +

+

+ +

+

+ is used. Particular care has to be taken to evaluate the z * sin(π   * + z) part: a special routine is used to reduce z prior to multiplying + by π   to ensure that the result in is the range [0, π/2]. Without this an excessive + amount of error occurs in this region (which is hard enough already, as the + rate of change near a negative pole is exceptionally + high). +

+

+ Finally if the argument is a small integer then table lookup of the factorial + is used. +

+

+ The function tgamma1pm1 is + implemented using rational approximations devised + by JM in the region -0.5 < dz + < 2. + These are the same approximations (and internal routines) that are used for + lgamma, and so aren't + detailed further here. The result of the approximation is log(tgamma(dz+1)) which can + fed into expm1 to give the + desired result. Outside the range -0.5 < dz + < 2 + then the naive formula tgamma1pm1(dz) + = tgamma(dz+1)-1 + can be used directly. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_gamma/trigamma.html b/boost/libs/math/doc/html/math_toolkit/sf_gamma/trigamma.html new file mode 100644 index 00000000..28aacc06 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_gamma/trigamma.html @@ -0,0 +1,205 @@ + + + +Trigamma + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/trigamma.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type trigamma(T z);
+
+template <class T, class Policy>
+calculated-result-type trigamma(T z, const Policy&);
+
+}} // namespaces
+
+
+ + Description +
+

+ Returns the trigamma function of x. Trigamma is defined + as the derivative of the digamma function: +

+

+ +

+

+ +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+

+ The return type of this function is computed using the result + type calculation rules: the result is of type double when T is an integer type, and type + T otherwise. +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types. Unless otherwise specified + any floating point type that is narrower than the one shown will have effectively zero error. +

+
+

Table 6.5. Error rates for trigamma

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Mathematica Data +

+
+

+ Max = 1ε (Mean = 0.382ε) +

+
+

+ Max = 0.998ε (Mean = 0.105ε)

+ (Rmath 3.0.2: Max = 1.34e+04ε (Mean = 1.51e+03ε))
+ (GSL 1.16: Max = 1.34e+04ε (Mean = 1.49e+03ε)) +

+
+

+ Max = 1.28ε (Mean = 0.449ε) +

+
+

+ Max = 1.28ε (Mean = 0.447ε) +

+
+
+

+ As shown above, error rates are generally very low for built in types. For + multiprecision types, error rates are typically in the order of a few epsilon. +

+
+ + Testing +
+

+ Testing is against Mathematica generated spot values to 35 digit precision. +

+
+ + Implementation +
+

+ The arbitrary precision version of this function simply calls polygamma. +

+

+ For built in fixed precision types, negative arguments are first made positive + via: +

+

+ +

+

+ Then arguments in the range [0, 1) are shifted to >= 1 via: +

+

+ +

+

+ Then evaluation is via one of a number of rational approximations, for small + x these are of the form: +

+

+ +

+

+ and for large x of the form: +

+

+ +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3