diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 22:58:32 +0100 |
| commit | e0737c56c1e384e05064a0c6e1ac46979371041b (patch) | |
| tree | a0123d694a2d36c43dabdf0a3907392fce11d457 /boost/libs/math/doc/html/math_toolkit/sf_gamma | |
| parent | b4aebf2d137b892f53503b13785ecae900062ff7 (diff) | |
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'boost/libs/math/doc/html/math_toolkit/sf_gamma')
9 files changed, 4209 insertions, 0 deletions
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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Digamma</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="lgamma.html" title="Log Gamma"> +<link rel="next" href="trigamma.html" title="Trigamma"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="lgamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="trigamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.digamma"></a><a class="link" href="digamma.html" title="Digamma">Digamma</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.digamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.digamma.synopsis"></a></span><a class="link" href="digamma.html#math_toolkit.sf_gamma.digamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">digamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">digamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">digamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.digamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.digamma.description"></a></span><a class="link" href="digamma.html#math_toolkit.sf_gamma.digamma.description">Description</a> + </h5> +<p> + Returns the digamma or psi function of <span class="emphasis"><em>x</em></span>. Digamma is + defined as the logarithmic derivative of the gamma function: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/digamma1.svg"></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/digamma.svg" align="middle"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type + T otherwise. + </p> +<h5> +<a name="math_toolkit.sf_gamma.digamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.digamma.accuracy"></a></span><a class="link" href="digamma.html#math_toolkit.sf_gamma.digamma.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively zero error</a>. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.digamma.table_digamma"></a><p class="title"><b>Table 6.4. Error rates for digamma</b></p> +<div class="table-contents"><table class="table" summary="Error rates for digamma"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + Digamma Function: Large Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.98ε (Mean = 0.369ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 1.84ε (Mean = 0.71ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.18ε (Mean = 0.331ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 0.919ε (Mean = 0.394ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.39ε (Mean = 0.413ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.39ε (Mean = 0.413ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Near the Positive Root + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.997ε (Mean = 0.527ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.891ε (Mean = 0.0995ε)</span><br> + <br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 135ε (Mean = 11.9ε))<br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 2.02e+03ε (Mean = 256ε))<br> + (<span class="emphasis"><em>Cephes:</em></span> Max = 1.42e+04ε (Mean = 1.14e+03ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.37ε (Mean = 0.477ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.31ε (Mean = 0.451ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Near Zero + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.953ε (Mean = 0.337ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 0.953ε (Mean = 0.348ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.17ε (Mean = 0.564ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 3.5ε (Mean = 1.04ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.984ε (Mean = 0.361ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.984ε (Mean = 0.361ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Negative Values + </p> + </td> +<td> + <p> + <span class="blue">Max = 214ε (Mean = 16.1ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 4.56e+04ε (Mean = 3.91e+03ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 4.6e+04ε (Mean = 3.94e+03ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 214ε (Mean = 16.4ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 180ε (Mean = 13ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 180ε (Mean = 13ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Values near 0 + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 0.866ε (Mean = 0.387ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 3.58e+05ε (Mean = 1.6e+05ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 0.5ε (Mean = 0.224ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1ε (Mean = 0.592ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1ε (Mean = 0.592ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Integer arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.992ε (Mean = 0.452ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.992ε (Mean = 0.215ε)</span><br> <br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.18ε (Mean = 0.607ε))<br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.33ε (Mean = 0.982ε))<br> + (<span class="emphasis"><em>Cephes:</em></span> Max = 0.992ε (Mean = 0.383ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.888ε (Mean = 0.403ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.888ε (Mean = 0.403ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Digamma Function: Half integer arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.78ε (Mean = 0.314ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 1.09ε (Mean = 0.531ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 46.2ε (Mean = 7.24ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 8.56ε (Mean = 1.44ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.906ε (Mean = 0.409ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.906ε (Mean = 0.409ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + 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. + </p> +<h5> +<a name="math_toolkit.sf_gamma.digamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.digamma.testing"></a></span><a class="link" href="digamma.html#math_toolkit.sf_gamma.digamma.testing">Testing</a> + </h5> +<p> + 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 <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> see below). + </p> +<h5> +<a name="math_toolkit.sf_gamma.digamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.digamma.implementation"></a></span><a class="link" href="digamma.html#math_toolkit.sf_gamma.digamma.implementation">Implementation</a> + </h5> +<p> + The implementation is divided up into the following domains: + </p> +<p> + For Negative arguments the reflection formula: + </p> +<pre class="programlisting"><span class="identifier">digamma</span><span class="special">(</span><span class="number">1</span><span class="special">-</span><span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">pi</span><span class="special">/</span><span class="identifier">tan</span><span class="special">(</span><span class="identifier">pi</span><span class="special">*</span><span class="identifier">x</span><span class="special">);</span> +</pre> +<p> + is used to make <span class="emphasis"><em>x</em></span> positive. + </p> +<p> + For arguments in the range [0,1] the recurrence relation: + </p> +<pre class="programlisting"><span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">-</span> <span class="number">1</span><span class="special">/</span><span class="identifier">x</span> +</pre> +<p> + is used to shift the evaluation to [1,2]. + </p> +<p> + For arguments in the range [1,2] a rational approximation <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised + by JM</a> is used (see below). + </p> +<p> + For arguments in the range [2,BIG] the recurrence relation: + </p> +<pre class="programlisting"><span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">+</span> <span class="number">1</span><span class="special">/</span><span class="identifier">x</span><span class="special">;</span> +</pre> +<p> + is used to shift the evaluation to the range [1,2]. + </p> +<p> + For arguments > BIG the asymptotic expansion: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/digamma2.svg"></span> + </p> +<p> + can be used. However, this expansion is divergent after a few terms: exactly + how many terms depends on the size of <span class="emphasis"><em>x</em></span>. Therefore the + value of <span class="emphasis"><em>BIG</em></span> 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 <span class="emphasis"><em>BIG</em></span>. 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 <code class="computeroutput"><span class="number">1</span><span class="special">/(</span><span class="identifier">x</span><span class="special">*</span><span class="identifier">x</span><span class="special">)</span></code>. + </p> +<p> + 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: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/digamma4.svg"></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/digamma5.svg"></span> + </p> +<p> + The rational approximation <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised + by JM</a> in the range [1,2] is derived as follows. + </p> +<p> + First a high precision approximation to digamma was constructed using a 60-term + differentiated <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>, + the form used is: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/digamma3.svg"></span> + </p> +<p> + 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 <code class="computeroutput"><span class="number">99</span><span class="special">-(</span><span class="number">1</span><span class="special">/</span><span class="identifier">y</span><span class="special">)</span></code> digits + if <span class="emphasis"><em>y</em></span> 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). + </p> +<p> + 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. + </p> +<p> + The rational approximation <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised + by JM</a> was optimised for absolute error using the form: + </p> +<pre class="programlisting"><span class="identifier">digamma</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">x</span> <span class="special">-</span> <span class="identifier">X0</span><span class="special">)(</span><span class="identifier">Y</span> <span class="special">+</span> <span class="identifier">R</span><span class="special">(</span><span class="identifier">x</span> <span class="special">-</span> <span class="number">1</span><span class="special">));</span> +</pre> +<p> + 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 <span class="emphasis"><em>x</em></span> 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) + <span class="emphasis"><em><span class="bold"><strong>will not be zero</strong></span></em></span>. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="lgamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="trigamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Derivative of the Incomplete Gamma Function</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="igamma_inv.html" title="Incomplete Gamma Function Inverses"> +<link rel="next" href="../factorials.html" title="Factorials and Binomial Coefficients"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="igamma_inv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../factorials.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.gamma_derivatives"></a><a class="link" href="gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function">Derivative of + the Incomplete Gamma Function</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.gamma_derivatives.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_derivatives.synopsis"></a></span><a class="link" href="gamma_derivatives.html#math_toolkit.sf_gamma.gamma_derivatives.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_derivative</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_derivative</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.gamma_derivatives.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_derivatives.description"></a></span><a class="link" href="gamma_derivatives.html#math_toolkit.sf_gamma.gamma_derivatives.description">Description</a> + </h5> +<p> + This function find some uses in statistical distributions: it implements + the partial derivative with respect to <span class="emphasis"><em>x</em></span> of the incomplete + gamma function. + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/derivative1.svg"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + Note that the derivative of the function <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_q</a> + can be obtained by negating the result of this function. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a> when T1 and T2 are different types, + otherwise the return type is simply T1. + </p> +<h5> +<a name="math_toolkit.sf_gamma.gamma_derivatives.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_derivatives.accuracy"></a></span><a class="link" href="gamma_derivatives.html#math_toolkit.sf_gamma.gamma_derivatives.accuracy">Accuracy</a> + </h5> +<p> + Almost identical to the incomplete gamma function <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_p</a>: + refer to the documentation for that function for more information. + </p> +<h5> +<a name="math_toolkit.sf_gamma.gamma_derivatives.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_derivatives.implementation"></a></span><a class="link" href="gamma_derivatives.html#math_toolkit.sf_gamma.gamma_derivatives.implementation">Implementation</a> + </h5> +<p> + This function just expose some of the internals of the incomplete gamma function + <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_p</a>: refer to the + documentation for that function for more information. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="igamma_inv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../factorials.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Ratios of Gamma Functions</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="polygamma.html" title="Polygamma"> +<link rel="next" href="igamma.html" title="Incomplete Gamma Functions"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="polygamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="igamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.gamma_ratios"></a><a class="link" href="gamma_ratios.html" title="Ratios of Gamma Functions">Ratios of Gamma Functions</a> +</h3></div></div></div> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_delta_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">delta</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_delta_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">delta</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.gamma_ratios.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_ratios.description"></a></span><a class="link" href="gamma_ratios.html#math_toolkit.sf_gamma.gamma_ratios.description">Description</a> + </h5> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">b</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the ratio of gamma functions: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamma_ratio0.svg"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + Internally this just calls <code class="computeroutput"><span class="identifier">tgamma_delta_ratio</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> + <span class="identifier">b</span><span class="special">-</span><span class="identifier">a</span><span class="special">)</span></code>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_delta_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">delta</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_delta_ratio</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">delta</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the ratio of gamma functions: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamma_ratio1.svg"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + Note that the result is calculated accurately even when <span class="emphasis"><em>delta</em></span> + is small compared to <span class="emphasis"><em>a</em></span>: indeed even if <span class="emphasis"><em>a+delta + ~ a</em></span>. The function is typically used when <span class="emphasis"><em>a</em></span> + is large and <span class="emphasis"><em>delta</em></span> is very small. + </p> +<p> + The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a> when T1 and T2 are different types, + otherwise the result type is simple T1. + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/tgamma_delta_ratio.svg" align="middle"></span> + </p> +<h5> +<a name="math_toolkit.sf_gamma.gamma_ratios.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_ratios.accuracy"></a></span><a class="link" href="gamma_ratios.html#math_toolkit.sf_gamma.gamma_ratios.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively zero error</a>. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.gamma_ratios.table_tgamma_delta_ratio"></a><p class="title"><b>Table 6.7. Error rates for tgamma_delta_ratio</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma_delta_ratio"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + tgamma + small delta ratios + </p> + </td> +<td> + <p> + <span class="blue">Max = 10.1ε (Mean = 1.25ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.56ε (Mean = 0.969ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 15.4ε (Mean = 2.09ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma + small delta ratios (negative delta) + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.04ε (Mean = 1.31ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.67ε (Mean = 1.29ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 18.3ε (Mean = 2.03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma + small integer ratios + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.74ε (Mean = 0.736ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.96ε (Mean = 0.677ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.96ε (Mean = 0.677ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma + small integer ratios (negative delta) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.15ε (Mean = 0.685ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.62ε (Mean = 0.451ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.62ε (Mean = 0.451ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + integer tgamma ratios + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.968ε (Mean = 0.386ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.997ε (Mean = 0.4ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.997ε (Mean = 0.4ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + integer tgamma ratios (negative delta) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.974ε (Mean = 0.184ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.853ε (Mean = 0.176ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.853ε (Mean = 0.176ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.gamma_ratios.table_tgamma_ratio"></a><p class="title"><b>Table 6.8. Error rates for tgamma_ratio</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma_ratio"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + tgamma ratios + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.66ε (Mean = 1.27ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.09ε (Mean = 1.15ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 174ε (Mean = 61.2ε)</span> + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"><h5> +<a name="math_toolkit.sf_gamma.gamma_ratios.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_ratios.testing"></a></span><a class="link" href="gamma_ratios.html#math_toolkit.sf_gamma.gamma_ratios.testing">Testing</a> + </h5> +<p> + Accuracy tests use data generated at very high precision (with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL + RR class</a> set at 1000-bit precision: about 300 decimal digits) and + a deliberately naive calculation of Γ(x)/Γ(y). + </p> +<h5> +<a name="math_toolkit.sf_gamma.gamma_ratios.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.gamma_ratios.implementation"></a></span><a class="link" href="gamma_ratios.html#math_toolkit.sf_gamma.gamma_ratios.implementation">Implementation</a> + </h5> +<p> + The implementation of these functions is very similar to that of <a class="link" href="../sf_beta/beta_function.html" title="Beta">beta</a>, + and is based on combining similar power terms to improve accuracy and avoid + spurious overflow/underflow. + </p> +<p> + In addition there are optimisations for the situation where <span class="emphasis"><em>delta</em></span> + 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. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="polygamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="igamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Incomplete Gamma Functions</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="gamma_ratios.html" title="Ratios of Gamma Functions"> +<link rel="next" href="igamma_inv.html" title="Incomplete Gamma Function Inverses"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="gamma_ratios.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="igamma_inv.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.igamma"></a><a class="link" href="igamma.html" title="Incomplete Gamma Functions">Incomplete Gamma Functions</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.igamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.synopsis"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_lower</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_lower</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.igamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.description"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.description">Description</a> + </h5> +<p> + There are four <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html" target="_top">incomplete + gamma functions</a>: two are normalised versions (also known as <span class="emphasis"><em>regularized</em></span> + 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 <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html" target="_top">normalised + versions (gamma_p and gamma_q)</a>. + </p> +<p> + All of these functions require <span class="emphasis"><em>a > 0</em></span> and <span class="emphasis"><em>z + >= 0</em></span>, otherwise they return the result of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a> when T1 and T2 are different types, + otherwise the return type is simply T1. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the normalised lower incomplete gamma function of a and z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/igamma4.svg"></span> + </p> +<p> + This function changes rapidly from 0 to 1 around the point z == a: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/gamma_p.svg" align="middle"></span> + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the normalised upper incomplete gamma function of a and z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/igamma3.svg"></span> + </p> +<p> + This function changes rapidly from 1 to 0 around the point z == a: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/gamma_q.svg" align="middle"></span> + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_lower</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma_lower</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the full (non-normalised) lower incomplete gamma function of a and + z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/igamma2.svg"></span> + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the full (non-normalised) upper incomplete gamma function of a and + z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/igamma1.svg"></span> + </p> +<h5> +<a name="math_toolkit.sf_gamma.igamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.accuracy"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.accuracy">Accuracy</a> + </h5> +<p> + The following tables give peak and mean relative errors in over various domains + of a and z, along with comparisons to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a> + and <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries. + Note that only results for the widest floating point type on the system are + given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively + zero error</a>. + </p> +<p> + Note that errors grow as <span class="emphasis"><em>a</em></span> grows larger. + </p> +<p> + 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. + </p> +<p> + All values are in units of epsilon. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.igamma.table_gamma_p"></a><p class="title"><b>Table 6.9. Error rates for gamma_p</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_p"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + tgamma(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 35.1ε (Mean = 6.97ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.955ε (Mean = 0.05ε)</span><br> <br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 342ε (Mean = 45.8ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 389ε (Mean = 44ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 492ε (Mean = 101ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 41ε (Mean = 8.09ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 239ε (Mean = 30.2ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.54ε (Mean = 0.439ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 4.82ε (Mean = 0.758ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.01ε (Mean = 0.306ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 21ε (Mean = 5.65ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.461ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.472ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) large values + </p> + </td> +<td> + <p> + <span class="blue">Max = 244ε (Mean = 20.2ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 1.02e+03ε (Mean = 105ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.11e+03ε (Mean = 67.5ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 8.18e+06ε (Mean = 7.69e+05ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.08e+04ε (Mean = 1.86e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.02e+04ε (Mean = 1.91e+03ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) integer and half integer values + </p> + </td> +<td> + <p> + <span class="blue">Max = 13ε (Mean = 2.93ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 128ε (Mean = 22.6ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 66.2ε (Mean = 12.2ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 83.6ε (Mean = 22.2ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 11.8ε (Mean = 2.65ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 71.6ε (Mean = 9.47ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma.table_gamma_q"></a><p class="title"><b>Table 6.10. Error rates for gamma_q</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_q"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + tgamma(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 23.7ε (Mean = 4.03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.927ε (Mean = 0.035ε)</span><br> <br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 201ε (Mean = 13.5ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 131ε (Mean = 12.7ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 388ε (Mean = 93.8ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 31.3ε (Mean = 6.56ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 199ε (Mean = 26.6ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.26ε (Mean = 0.732ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> <span class="red">Max = 1.38e+10ε (Mean = 1.05e+09ε))</span><br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 65.6ε (Mean = 11ε))<br> + (<span class="emphasis"><em>Cephes:</em></span> <span class="red">Max = 3.42e+11ε (Mean + = 4.1e+10ε))</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.45ε (Mean = 0.832ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.25ε (Mean = 0.81ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) large values + </p> + </td> +<td> + <p> + <span class="blue">Max = 470ε (Mean = 31.5ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 2.71e+04ε (Mean = 2.16e+03ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.02e+03ε (Mean = 62.7ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 8.17e+06ε (Mean = 7.7e+05ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.82e+03ε (Mean = 414ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.15e+04ε (Mean = 733ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) integer and half integer values + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.48ε (Mean = 1.42ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 118ε (Mean = 12.5ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 138ε (Mean = 16.9ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 129ε (Mean = 26.5ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 11.1ε (Mean = 2.09ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 54.7ε (Mean = 6.16ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma.table_tgamma_lower"></a><p class="title"><b>Table 6.11. Error rates for tgamma_lower</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma_lower"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + tgamma(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.62ε (Mean = 1.43ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.833ε (Mean = 0.0315ε)</span><br> + <br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 0.833ε (Mean = 0.0315ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.79ε (Mean = 1.38ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 363ε (Mean = 63.8ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.57ε (Mean = 0.527ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.97ε (Mean = 0.552ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.97ε (Mean = 0.567ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) integer and half integer values + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.69ε (Mean = 0.866ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.83ε (Mean = 1.12ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 84.7ε (Mean = 17.5ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma.table_tgamma_incomplete_"></a><p class="title"><b>Table 6.12. Error rates for tgamma (incomplete)</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma (incomplete)"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + tgamma(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.14ε (Mean = 1.71ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 200ε (Mean = 13.3ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 7.35ε (Mean = 1.69ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 412ε (Mean = 95.5ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.53ε (Mean = 0.66ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.753ε (Mean = 0.0474ε)</span><br> + <br> (<span class="emphasis"><em>GSL 1.16:</em></span> <span class="red">Max = + 1.38e+10ε (Mean = 1.05e+09ε))</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.13ε (Mean = 0.717ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.13ε (Mean = 0.712ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + tgamma(a, z) integer and half integer values + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.16ε (Mean = 1.44ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 117ε (Mean = 12.5ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.52ε (Mean = 1.52ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 79.6ε (Mean = 20.9ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><h5> +<a name="math_toolkit.sf_gamma.igamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.testing"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.testing">Testing</a> + </h5> +<p> + There are two sets of tests: spot tests compare values taken from <a href="http://functions.wolfram.com/GammaBetaErf/" target="_top">Mathworld's online evaluator</a> + 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 <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>, + 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. + </p> +<h5> +<a name="math_toolkit.sf_gamma.igamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.implementation"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.implementation">Implementation</a> + </h5> +<p> + These four functions share a common implementation since they are all related + via: + </p> +<p> + 1) <span class="inlinemediaobject"><img src="../../../equations/igamma5.svg"></span> + </p> +<p> + 2) <span class="inlinemediaobject"><img src="../../../equations/igamma6.svg"></span> + </p> +<p> + 3) <span class="inlinemediaobject"><img src="../../../equations/igamma7.svg"></span> + </p> +<p> + The lower incomplete gamma is computed from its series representation: + </p> +<p> + 4) <span class="inlinemediaobject"><img src="../../../equations/igamma8.svg"></span> + </p> +<p> + Or by subtraction of the upper integral from either Γ(a) or 1 when <span class="emphasis"><em>x + - (1</em></span>(3x)) > a and x > 1.1/. + </p> +<p> + The upper integral is computed from Legendre's continued fraction representation: + </p> +<p> + 5) <span class="inlinemediaobject"><img src="../../../equations/igamma9.svg"></span> + </p> +<p> + When <span class="emphasis"><em>(x > 1.1)</em></span> or by subtraction of the lower integral + from either Γ(a) or 1 when <span class="emphasis"><em>x - (1</em></span>(3x)) < a/. + </p> +<p> + For <span class="emphasis"><em>x < 1.1</em></span> 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: + </p> +<p> + 6) <span class="inlinemediaobject"><img src="../../../equations/igamma10.svg"></span> + </p> +<p> + That lends itself to calculation of the upper integral via rearrangement + to: + </p> +<p> + 7) <span class="inlinemediaobject"><img src="../../../equations/igamma11.svg"></span> + </p> +<p> + Refer to the documentation for <a class="link" href="../powers/powm1.html" title="powm1">powm1</a> + and <a class="link" href="tgamma.html" title="Gamma">tgamma1pm1</a> for details + of their implementation. Note however that the precision of <a class="link" href="tgamma.html" title="Gamma">tgamma1pm1</a> + is capped to either around 35 digits, or to that of the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> 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. + </p> +<p> + For <span class="emphasis"><em>x < 1.1</em></span> the crossover point where the result + is ~0.5 no longer occurs for <span class="emphasis"><em>x ~ y</em></span>. Using <span class="emphasis"><em>x + * 0.75 < a</em></span> as the crossover criterion for <span class="emphasis"><em>0.5 < + x <= 1.1</em></span> keeps the maximum value computed (whether it's the + upper or lower interval) to around 0.75. Likewise for <span class="emphasis"><em>x <= 0.5</em></span> + then using <span class="emphasis"><em>-0.4 / log(x) < a</em></span> as the crossover criterion + keeps the maximum value computed to around 0.7 (whether it's the upper or + lower interval). + </p> +<p> + 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 <span class="emphasis"><em>1 <= a < + 30</em></span> then the following finite sum is used: + </p> +<p> + 9) <span class="inlinemediaobject"><img src="../../../equations/igamma1f.svg"></span> + </p> +<p> + While for half integers in the range <span class="emphasis"><em>0.5 <= a < 30</em></span> + then the following finite sum is used: + </p> +<p> + 10) <span class="inlinemediaobject"><img src="../../../equations/igamma2f.svg"></span> + </p> +<p> + These are both more stable and more efficient than the continued fraction + alternative. + </p> +<p> + When the argument <span class="emphasis"><em>a</em></span> is large, and <span class="emphasis"><em>x ~ a</em></span> + then the series (4) and continued fraction (5) above are very slow to converge. + In this area an expansion due to Temme is used: + </p> +<p> + 11) <span class="inlinemediaobject"><img src="../../../equations/igamma16.svg"></span> + </p> +<p> + 12) <span class="inlinemediaobject"><img src="../../../equations/igamma17.svg"></span> + </p> +<p> + 13) <span class="inlinemediaobject"><img src="../../../equations/igamma18.svg"></span> + </p> +<p> + 14) <span class="inlinemediaobject"><img src="../../../equations/igamma19.svg"></span> + </p> +<p> + 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 C<sub>k</sub><sup>n</sup> are + computed in advance using the recurrence relations given by Temme. The zone + where these expansions are used is + </p> +<pre class="programlisting"><span class="special">(</span><span class="identifier">a</span> <span class="special">></span> <span class="number">20</span><span class="special">)</span> <span class="special">&&</span> <span class="special">(</span><span class="identifier">a</span> <span class="special"><</span> <span class="number">200</span><span class="special">)</span> <span class="special">&&</span> <span class="identifier">fabs</span><span class="special">(</span><span class="identifier">x</span><span class="special">-</span><span class="identifier">a</span><span class="special">)/</span><span class="identifier">a</span> <span class="special"><</span> <span class="number">0.4</span> +</pre> +<p> + And: + </p> +<pre class="programlisting"><span class="special">(</span><span class="identifier">a</span> <span class="special">></span> <span class="number">200</span><span class="special">)</span> <span class="special">&&</span> <span class="special">(</span><span class="identifier">fabs</span><span class="special">(</span><span class="identifier">x</span><span class="special">-</span><span class="identifier">a</span><span class="special">)/</span><span class="identifier">a</span> <span class="special"><</span> <span class="number">4.5</span><span class="special">/</span><span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span><span class="special">))</span> +</pre> +<p> + 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<sup>-6</sup>, 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 <code class="computeroutput"><span class="identifier">exp</span></code> and <code class="computeroutput"><span class="identifier">erfc</span></code> 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. + </p> +<p> + 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 <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> gives the greatest accuracy: + </p> +<p> + 15) <span class="inlinemediaobject"><img src="../../../equations/igamma12.svg"></span> + </p> +<p> + In the event that this causes underflow/overflow then the exponent can be + reduced by a factor of <span class="emphasis"><em>a</em></span> and brought inside the power + term. + </p> +<p> + 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: + </p> +<p> + 16) <span class="inlinemediaobject"><img src="../../../equations/igamma13.svg"></span> + </p> +<p> + when <span class="emphasis"><em>a-x</em></span> 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 <span class="emphasis"><em>exp</em></span> + 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 <span class="emphasis"><em>log(1+x)-x</em></span> here is inspired by + Temme (see references below). + </p> +<h5> +<a name="math_toolkit.sf_gamma.igamma.h5"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma.references"></a></span><a class="link" href="igamma.html#math_toolkit.sf_gamma.igamma.references">References</a> + </h5> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> +<li class="listitem"> + N. M. Temme, A Set of Algorithms for the Incomplete Gamma Functions, + Probability in the Engineering and Informational Sciences, 8, 1994. + </li> +<li class="listitem"> + N. M. Temme, The Asymptotic Expansion of the Incomplete Gamma Functions, + Siam J. Math Anal. Vol 10 No 4, July 1979, p757. + </li> +<li class="listitem"> + 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. + </li> +<li class="listitem"> + 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. <a href="http://citeseer.ist.psu.edu/gautschi98incomplete.html" target="_top">http://citeseer.ist.psu.edu/gautschi98incomplete.html</a> + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="gamma_ratios.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="igamma_inv.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Incomplete Gamma Function Inverses</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="igamma.html" title="Incomplete Gamma Functions"> +<link rel="next" href="gamma_derivatives.html" title="Derivative of the Incomplete Gamma Function"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="igamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="gamma_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.igamma_inv"></a><a class="link" href="igamma_inv.html" title="Incomplete Gamma Function Inverses">Incomplete Gamma Function + Inverses</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.igamma_inv.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.synopsis"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.igamma_inv.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.description"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.description">Description</a> + </h5> +<p> + There are four <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html" target="_top">incomplete + gamma function</a> inverses which either compute <span class="emphasis"><em>x</em></span> + given <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span>, + or else compute <span class="emphasis"><em>a</em></span> given <span class="emphasis"><em>x</em></span> and either + <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span>. + </p> +<p> + The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a> when T1 and T2 are different types, + otherwise the return type is simply T1. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<div class="tip"><table border="0" summary="Tip"> +<tr> +<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td> +<th align="left">Tip</th> +</tr> +<tr><td align="left" valign="top"> +<p> + When people normally talk about the inverse of the incomplete gamma function, + they are talking about inverting on parameter <span class="emphasis"><em>x</em></span>. These + are implemented here as gamma_p_inv and gamma_q_inv, and are by far the + most efficient of the inverses presented here. + </p> +<p> + The inverse on the <span class="emphasis"><em>a</em></span> 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. + </p> +</td></tr> +</table></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns a value x such that: <code class="computeroutput"><span class="identifier">q</span> + <span class="special">=</span> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> + <span class="identifier">x</span><span class="special">);</span></code> + </p> +<p> + Requires: <span class="emphasis"><em>a > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inv</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns a value x such that: <code class="computeroutput"><span class="identifier">p</span> + <span class="special">=</span> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> + <span class="identifier">x</span><span class="special">);</span></code> + </p> +<p> + Requires: <span class="emphasis"><em>a > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_q_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns a value a such that: <code class="computeroutput"><span class="identifier">q</span> + <span class="special">=</span> <span class="identifier">gamma_q</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> + <span class="identifier">x</span><span class="special">);</span></code> + </p> +<p> + Requires: <span class="emphasis"><em>x > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">gamma_p_inva</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns a value a such that: <code class="computeroutput"><span class="identifier">p</span> + <span class="special">=</span> <span class="identifier">gamma_p</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> + <span class="identifier">x</span><span class="special">);</span></code> + </p> +<p> + Requires: <span class="emphasis"><em>x > 0</em></span> and <span class="emphasis"><em>1 >= p,q >= 0</em></span>. + </p> +<h5> +<a name="math_toolkit.sf_gamma.igamma_inv.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.accuracy"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_p</a> + and <a class="link" href="igamma.html" title="Incomplete Gamma Functions">gamma_q</a> functions: + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_p_inv"></a><p class="title"><b>Table 6.13. Error rates for gamma_p_inv</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_p_inv"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.01ε (Mean = 0.307ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.993ε (Mean = 0.15ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.88ε (Mean = 0.868ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.62ε (Mean = 0.365ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.86ε (Mean = 0.405ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) large values + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.924ε (Mean = 0.118ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 0.816ε (Mean = 0.0874ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.509ε (Mean = 0.0447ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.509ε (Mean = 0.0447ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.1e+003ε (Mean = 108ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 441ε (Mean = 53.9ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 547ε (Mean = 61.6ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 9.17e+03ε (Mean = 1.32e+03ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.09e+04ε (Mean = 1.46e+03ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_q_inv"></a><p class="title"><b>Table 6.14. Error rates for gamma_q_inv</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_q_inv"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) medium values + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.46ε (Mean = 0.475ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.912ε (Mean = 0.154ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.66ε (Mean = 0.792ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.2ε (Mean = 0.659ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.2ε (Mean = 0.661ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) large values + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.814ε (Mean = 0.0856ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.894ε (Mean = 0.0915ε)</span><br> + <br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 0.894ε (Mean = 0.106ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + incomplete gamma inverse(a, z) small values + </p> + </td> +<td> + <p> + <span class="blue">Max = 451ε (Mean = 65ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 292ε (Mean = 36.4ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 415ε (Mean = 48.7ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.28e+03ε (Mean = 963ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 8.98e+03ε (Mean = 877ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_p_inva"></a><p class="title"><b>Table 6.15. Error rates for gamma_p_inva</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_p_inva"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + Incomplete gamma inverses. + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.52ε (Mean = 0.997ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.44ε (Mean = 1.1ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.08ε (Mean = 1.12ε)</span> + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.igamma_inv.table_gamma_q_inva"></a><p class="title"><b>Table 6.16. Error rates for gamma_q_inva</b></p> +<div class="table-contents"><table class="table" summary="Error rates for gamma_q_inva"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + Incomplete gamma inverses. + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.64ε (Mean = 1.09ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.91ε (Mean = 1.17ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 7.86ε (Mean = 1.25ε)</span> + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"><h5> +<a name="math_toolkit.sf_gamma.igamma_inv.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.testing"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.testing">Testing</a> + </h5> +<p> + There are two sets of tests: + </p> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> +<li class="listitem"> + Basic sanity checks attempt to "round-trip" from <span class="emphasis"><em>a</em></span> + and <span class="emphasis"><em>x</em></span> to <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span> + 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 <span class="emphasis"><em>p</em></span> or <span class="emphasis"><em>q</em></span> + 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. + </li> +<li class="listitem"> + Accuracy checks using high precision test values. These measure the accuracy + of the result, given exact input values. + </li> +</ul></div> +<h5> +<a name="math_toolkit.sf_gamma.igamma_inv.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.igamma_inv.implementation"></a></span><a class="link" href="igamma_inv.html#math_toolkit.sf_gamma.igamma_inv.implementation">Implementation</a> + </h5> +<p> + The functions gamma_p_inv and <a href="http://functions.wolfram.com/GammaBetaErf/InverseGammaRegularized/" target="_top">gamma_q_inv</a> + share a common implementation. + </p> +<p> + First an initial approximation is computed using the methodology described + in: + </p> +<p> + <a href="http://portal.acm.org/citation.cfm?id=23109&coll=portal&dl=ACM" target="_top">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.</a> + </p> +<p> + 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. + </p> +<p> + 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. + </p> +<p> + An initial approximation for <span class="emphasis"><em>a</em></span> is computed very crudely + so that <span class="emphasis"><em>gamma_p(a, x) ~ 0.5</em></span>, 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. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="igamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="gamma_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Log Gamma</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="tgamma.html" title="Gamma"> +<link rel="next" href="digamma.html" title="Digamma"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tgamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="digamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.lgamma"></a><a class="link" href="lgamma.html" title="Log Gamma">Log Gamma</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.lgamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.lgamma.synopsis"></a></span><a class="link" href="lgamma.html#math_toolkit.sf_gamma.lgamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">int</span><span class="special">*</span> <span class="identifier">sign</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">int</span><span class="special">*</span> <span class="identifier">sign</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.lgamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.lgamma.description"></a></span><a class="link" href="lgamma.html#math_toolkit.sf_gamma.lgamma.description">Description</a> + </h5> +<p> + The <a href="http://en.wikipedia.org/wiki/Gamma_function" target="_top">lgamma function</a> + is defined by: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/lgamm1.svg"></span> + </p> +<p> + 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). + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/lgamma.svg" align="middle"></span> + </p> +<p> + 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 <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a>. In practice, any built-in floating-point type you will + encounter has an appropriate <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> defined for it. It is also possible, given enough machine + time, to generate further <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>'s + using the program libs/math/tools/lanczos_generator.cpp. + </p> +<p> + The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> if T is an integer type, or type T + otherwise. + </p> +<h5> +<a name="math_toolkit.sf_gamma.lgamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.lgamma.accuracy"></a></span><a class="link" href="lgamma.html#math_toolkit.sf_gamma.lgamma.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively + zero error</a>. + </p> +<p> + 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. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.lgamma.table_lgamma"></a><p class="title"><b>Table 6.3. Error rates for lgamma</b></p> +<div class="table-contents"><table class="table" summary="Error rates for lgamma"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + factorials + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.914ε (Mean = 0.167ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.958ε (Mean = 0.38ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 33.6ε (Mean = 2.78ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1.55ε (Mean = 0.592ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.55ε (Mean = 0.512ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.991ε (Mean = 0.311ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.67ε (Mean = 0.487ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.67ε (Mean = 0.487ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.991ε (Mean = 0.383ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.36ε (Mean = 0.476ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 0 + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.964ε (Mean = 0.462ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.962ε (Mean = 0.372ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 5.21ε (Mean = 1.57ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 0ε (Mean = 0ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.16ε (Mean = 0.341ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.42ε (Mean = 0.566ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 0.964ε (Mean = 0.543ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.964ε (Mean = 0.543ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.42ε (Mean = 0.566ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.964ε (Mean = 0.543ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 1 + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.867ε (Mean = 0.468ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.906ε (Mean = 0.565ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 442ε (Mean = 88.8ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 7.99e+04ε (Mean = 1.68e+04ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.14e+05ε (Mean = 2.64e+04ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.948ε (Mean = 0.36ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 0.615ε (Mean = 0.096ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.615ε (Mean = 0.096ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.866ε (Mean = 0.355ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.71ε (Mean = 0.581ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 2 + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.591ε (Mean = 0.159ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.741ε (Mean = 0.473ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 1.17e+03ε (Mean = 274ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 2.63e+05ε (Mean = 5.84e+04ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 5.08e+05ε (Mean = 9.04e+04ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.878ε (Mean = 0.242ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 0.741ε (Mean = 0.263ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.741ε (Mean = 0.263ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.878ε (Mean = 0.241ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.598ε (Mean = 0.235ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near -10 + </p> + </td> +<td> + <p> + <span class="blue">Max = 4.22ε (Mean = 1.33ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.997ε (Mean = 0.444ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 24.9ε (Mean = 4.6ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 2.41e+05ε (Mean = 4.29e+04ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 0.997ε (Mean = 0.429ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.81ε (Mean = 1.01ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 3.01ε (Mean = 0.86ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 3.01ε (Mean = 0.86ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.81ε (Mean = 1.01ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 3.04ε (Mean = 1.01ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near -55 + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.821ε (Mean = 0.419ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 249ε (Mean = 43.1ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 7.02ε (Mean = 1.47ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 4.08e+04ε (Mean = 7.26e+03ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.64ε (Mean = 0.693ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.821ε (Mean = 0.513ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.58ε (Mean = 0.672ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.58ε (Mean = 0.672ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.59ε (Mean = 0.587ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.821ε (Mean = 0.674ε)) + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><h5> +<a name="math_toolkit.sf_gamma.lgamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.lgamma.testing"></a></span><a class="link" href="lgamma.html#math_toolkit.sf_gamma.lgamma.testing">Testing</a> + </h5> +<p> + The main tests for this function involve comparisons against the logs of + the factorials which can be independently calculated to very high accuracy. + </p> +<p> + Random tests in key problem areas are also used. + </p> +<h5> +<a name="math_toolkit.sf_gamma.lgamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.lgamma.implementation"></a></span><a class="link" href="lgamma.html#math_toolkit.sf_gamma.lgamma.implementation">Implementation</a> + </h5> +<p> + The generic version of this function is implemented using Sterling's approximation + for large arguments: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamma6.svg"></span> + </p> +<p> + For small arguments, the logarithm of tgamma is used. + </p> +<p> + For negative <span class="emphasis"><em>z</em></span> the logarithm version of the reflection + formula is used: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/lgamm3.svg"></span> + </p> +<p> + For types of known precision, the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> is used, a traits class <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lanczos</span><span class="special">::</span><span class="identifier">lanczos_traits</span></code> + maps type T to an appropriate approximation. The logarithmic version of the + <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a> is: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/lgamm4.svg"></span> + </p> +<p> + Where L<sub>e,g</sub>   is the Lanczos sum, scaled by e<sup>g</sup>. + </p> +<p> + As before the reflection formula is used for <span class="emphasis"><em>z < 0</em></span>. + </p> +<p> + When z is very near 1 or 2, then the logarithmic version of the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> 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). + </p> +<p> + For types with up to 113 bits of precision (up to and including 128-bit long + doubles), root-preserving rational approximations <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised + by JM</a> are used over the intervals [1,2] and [2,3]. Over the interval + [2,3] the approximation form used is: + </p> +<pre class="programlisting"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">z</span><span class="special">-</span><span class="number">2</span><span class="special">)(</span><span class="identifier">z</span><span class="special">+</span><span class="number">1</span><span class="special">)(</span><span class="identifier">Y</span> <span class="special">+</span> <span class="identifier">R</span><span class="special">(</span><span class="identifier">z</span><span class="special">-</span><span class="number">2</span><span class="special">));</span> +</pre> +<p> + 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: + </p> +<pre class="programlisting"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span> +</pre> +<p> + Over the interval [1,2] two approximations have to be used, one for small + z uses: + </p> +<pre class="programlisting"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">z</span><span class="special">-</span><span class="number">1</span><span class="special">)(</span><span class="identifier">z</span><span class="special">-</span><span class="number">2</span><span class="special">)(</span><span class="identifier">Y</span> <span class="special">+</span> <span class="identifier">R</span><span class="special">(</span><span class="identifier">z</span><span class="special">-</span><span class="number">1</span><span class="special">));</span> +</pre> +<p> + 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: + </p> +<pre class="programlisting"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span> <span class="special">=</span> <span class="special">(</span><span class="number">2</span><span class="special">-</span><span class="identifier">z</span><span class="special">)(</span><span class="number">1</span><span class="special">-</span><span class="identifier">z</span><span class="special">)(</span><span class="identifier">Y</span> <span class="special">+</span> <span class="identifier">R</span><span class="special">(</span><span class="number">2</span><span class="special">-</span><span class="identifier">z</span><span class="special">));</span> +</pre> +<p> + Finally for z < 1 the recurrence relation can be used to move to z > + 1: + </p> +<pre class="programlisting"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">-</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span> +</pre> +<p> + Note that while this involves a subtraction, it appears not to suffer from + cancellation error: as z decreases from 1 the <code class="computeroutput"><span class="special">-</span><span class="identifier">log</span><span class="special">(</span><span class="identifier">z</span><span class="special">)</span></code> term grows positive much more rapidly than + the <code class="computeroutput"><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">z</span><span class="special">+</span><span class="number">1</span><span class="special">)</span></code> term becomes negative. So in this specific + case, significant digits are preserved, rather than cancelled. + </p> +<p> + For other types which do have a <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> defined for them the current solution is as follows: + imagine we balance the two terms in the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> by dividing the power term by its value at <span class="emphasis"><em>z + = 1</em></span>, and then multiplying the Lanczos coefficients by the same + value. Now each term will take the value 1 at <span class="emphasis"><em>z = 1</em></span> + 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 <span class="emphasis"><em>z = 1</em></span>), we obtain a new summation that can be + also be fed into log1p. Crucially, all of the terms tend to zero, as <span class="emphasis"><em>z + -> 1</em></span>: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/lgamm5.svg"></span> + </p> +<p> + The C<sub>k</sub>   terms in the above are the same as in the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a>. + </p> +<p> + A similar rearrangement can be performed at <span class="emphasis"><em>z = 2</em></span>: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/lgamm6.svg"></span> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tgamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="digamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Polygamma</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="trigamma.html" title="Trigamma"> +<link rel="next" href="gamma_ratios.html" title="Ratios of Gamma Functions"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="trigamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="gamma_ratios.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.polygamma"></a><a class="link" href="polygamma.html" title="Polygamma">Polygamma</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.polygamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.polygamma.synopsis"></a></span><a class="link" href="polygamma.html#math_toolkit.sf_gamma.polygamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">polygamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">polygamma</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">polygamma</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.polygamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.polygamma.description"></a></span><a class="link" href="polygamma.html#math_toolkit.sf_gamma.polygamma.description">Description</a> + </h5> +<p> + Returns the polygamma function of <span class="emphasis"><em>x</em></span>. Polygamma is defined + as the n'th derivative of the digamma function: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma1.svg"></span> + </p> +<p> + The following graphs illustrate the behaviour of the function for odd and + even order: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/polygamma2.svg" align="middle"></span> + <span class="inlinemediaobject"><img src="../../../graphs/polygamma3.svg" align="middle"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type + T otherwise. + </p> +<h5> +<a name="math_toolkit.sf_gamma.polygamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.polygamma.accuracy"></a></span><a class="link" href="polygamma.html#math_toolkit.sf_gamma.polygamma.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively zero error</a>. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.polygamma.table_polygamma"></a><p class="title"><b>Table 6.6. Error rates for polygamma</b></p> +<div class="table-contents"><table class="table" summary="Error rates for polygamma"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + Mathematica Data + </p> + </td> +<td> + <p> + <span class="blue">Max = 6.34ε (Mean = 1.53ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.824ε (Mean = 0.0574ε)</span><br> + <br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 108ε (Mean = 15.2ε))<br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 62.9ε (Mean = 12.8ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 7.38ε (Mean = 1.84ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 18.3ε (Mean = 4.16ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Mathematica Data - large arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 150ε (Mean = 15.1ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.998ε (Mean = 0.0592ε)</span><br> + <br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max + = 1.71e+56ε (Mean = 1.01e+55ε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_Rmath_3_0_2_Mathematica_Data_large_arguments">And + other failures.</a>)</span><br> (<span class="emphasis"><em>GSL 1.16:</em></span> + Max = 244ε (Mean = 32.8ε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_GSL_1_16_Mathematica_Data_large_arguments">And + other failures.</a>) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.23ε (Mean = 0.323ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.35ε (Mean = 0.34ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Mathematica Data - negative arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 497ε (Mean = 129ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.516ε (Mean = 0.022ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INFε (Mean + = +INFε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_Rmath_3_0_2_Mathematica_Data_negative_arguments">And + other failures.</a>)</span><br> (<span class="emphasis"><em>GSL 1.16:</em></span> + Max = 36.6ε (Mean = 3.04ε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_GSL_1_16_Mathematica_Data_negative_arguments">And + other failures.</a>) + </p> + </td> +<td> + <p> + <span class="blue">Max = 269ε (Mean = 87.7ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 269ε (Mean = 87.9ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Mathematica Data - large negative arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 162ε (Mean = 101ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> <span class="red">Max = +INFε (Mean = +INFε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_Rmath_3_0_2_Mathematica_Data_large_negative_arguments">And + other failures.</a>)</span><br> (<span class="emphasis"><em>GSL 1.16:</em></span> + Max = 1.79ε (Mean = 0.197ε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_GSL_1_16_Mathematica_Data_large_negative_arguments">And + other failures.</a>) + </p> + </td> +<td> + <p> + <span class="blue">Max = 155ε (Mean = 96.4ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 155ε (Mean = 96.4ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Mathematica Data - small arguments + </p> + </td> +<td> + <p> + <span class="blue">Max = 3ε (Mean = 0.496ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 106ε (Mean = 20ε))<br> (<span class="emphasis"><em>GSL 1.16:</em></span> + Max = 15.2ε (Mean = 5.03ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.33ε (Mean = 0.75ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.33ε (Mean = 0.75ε)</span> + </p> + </td> +</tr> +<tr> +<td> + <p> + Mathematica Data - Large orders and other bug cases + </p> + </td> +<td> + <p> + <span class="blue">Max = 200ε (Mean = 57.2ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> <span class="red">Max = +INFε (Mean = +INFε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_Rmath_3_0_2_Mathematica_Data_Large_orders_and_other_bug_cases">And + other failures.</a>)</span><br> (<span class="emphasis"><em>GSL 1.16:</em></span> + Max = 151ε (Mean = 39.3ε) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_polygamma_GSL_1_16_Mathematica_Data_Large_orders_and_other_bug_cases">And + other failures.</a>) + </p> + </td> +<td> + <p> + <span class="blue">Max = 54.5ε (Mean = 13.3ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 90.1ε (Mean = 30.6ε)</span> + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + 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 <span class="emphasis"><em>n!</em></span> + would overflow, the function changes directly from -∞ to +∞ somewhere between + each negative integer - <span class="emphasis"><em>these cases are not handled correctly</em></span>. + </p> +<p> + <span class="bold"><strong>For these reasons results should be treated with extreme + caution when <span class="emphasis"><em>n</em></span> is large and x negative</strong></span>. + </p> +<h5> +<a name="math_toolkit.sf_gamma.polygamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.polygamma.testing"></a></span><a class="link" href="polygamma.html#math_toolkit.sf_gamma.polygamma.testing">Testing</a> + </h5> +<p> + Testing is against Mathematica generated spot values to 35 digit precision. + </p> +<h5> +<a name="math_toolkit.sf_gamma.polygamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.polygamma.implementation"></a></span><a class="link" href="polygamma.html#math_toolkit.sf_gamma.polygamma.implementation">Implementation</a> + </h5> +<p> + For x < 0 the following reflection formula is used: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma2.svg"></span> + </p> +<p> + The n'th derivative of <span class="emphasis"><em>cot(x)</em></span> is tabulated for small + <span class="emphasis"><em>n</em></span>, and for larger n has the general form: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma3.svg"></span> + </p> +<p> + The coefficients of the cosine terms can be calculated iteratively starting + from <span class="emphasis"><em>C<sub>1,0</sub> = -1</em></span> and then using + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma7.svg"></span> + </p> +<p> + to generate coefficients for n+1. + </p> +<p> + 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. + </p> +<p> + Once x is positive then we have two methods available to us, for small x + we use the series expansion: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma4.svg"></span> + </p> +<p> + Note that the evaluation of zeta functions at integer values is essentially + a table lookup as <a class="link" href="../zetas/zeta.html" title="Riemann Zeta Function">zeta</a> is + optimized for those cases. + </p> +<p> + For large x we use the asymptotic expansion: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma5.svg"></span> + </p> +<p> + For x in-between the two extremes we use the relation: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma6.svg"></span> + </p> +<p> + to make x large enough for the asymptotic expansion to be used. + </p> +<p> + There are also two special cases: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma8.svg"></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/polygamma9.svg"></span> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="trigamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="gamma_ratios.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Gamma</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="next" href="lgamma.html" title="Log Gamma"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lgamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.tgamma"></a><a class="link" href="tgamma.html" title="Gamma">Gamma</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.tgamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.tgamma.synopsis"></a></span><a class="link" href="tgamma.html#math_toolkit.sf_gamma.tgamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">gamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma1pm1</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">dz</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma1pm1</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">dz</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.tgamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.tgamma.description"></a></span><a class="link" href="tgamma.html#math_toolkit.sf_gamma.tgamma.description">Description</a> + </h5> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns the "true gamma" (hence name tgamma) of value z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamm1.svg"></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/tgamma.svg" align="middle"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + There are effectively two versions of the <a href="http://en.wikipedia.org/wiki/Gamma_function" target="_top">tgamma</a> + 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 <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a>. In practice any built in floating point type you will + encounter has an appropriate <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> defined for it. It is also possible, given enough machine + time, to generate further <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>'s + using the program libs/math/tools/lanczos_generator.cpp. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is <code class="computeroutput"><span class="keyword">double</span></code> + when T is an integer type, and T otherwise. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma1pm1</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">dz</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">tgamma1pm1</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">dz</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> +</pre> +<p> + Returns <code class="computeroutput"><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">dz</span> <span class="special">+</span> <span class="number">1</span><span class="special">)</span> <span class="special">-</span> <span class="number">1</span></code>. + Internally the implementation does not make use of the addition and subtraction + implied by the definition, leading to accurate results even for very small + <code class="computeroutput"><span class="identifier">dz</span></code>. However, the implementation + is capped to either 35 digit accuracy, or to the precision of the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> associated with type T, whichever is more accurate. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is <code class="computeroutput"><span class="keyword">double</span></code> + when T is an integer type, and T otherwise. + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<h5> +<a name="math_toolkit.sf_gamma.tgamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.tgamma.accuracy"></a></span><a class="link" href="tgamma.html#math_toolkit.sf_gamma.tgamma.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively + zero error</a>. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.tgamma.table_tgamma"></a><p class="title"><b>Table 6.1. Error rates for tgamma</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + factorials + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.85ε (Mean = 0.491ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 3.17ε (Mean = 0.928ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 3.95ε (Mean = 0.783ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 314ε (Mean = 93.4ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 3.19ε (Mean = 0.884ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.96ε (Mean = 0.483ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.66ε (Mean = 0.584ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.66ε (Mean = 0.584ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 172ε (Mean = 41ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 0 + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.96ε (Mean = 0.684ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1ε (Mean = 0.405ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 4.51ε (Mean = 1.92ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1ε (Mean = 0.335ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1ε (Mean = 0.548ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.73ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1ε (Mean = 0.376ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1ε (Mean = 0.376ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.647ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.5ε (Mean = 0.0791ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 1 + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.865ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1ε (Mean = 0.4ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 4.41ε (Mean = 1.81ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1ε (Mean = 0.32ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1ε (Mean = 0.518ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.85ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 0.918ε (Mean = 0.203ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.918ε (Mean = 0.203ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.01ε (Mean = 1.06ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1ε (Mean = 0.175ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near 2 + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.995ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 7.95ε (Mean = 3.12ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 1ε (Mean = 0.191ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 1.09ε (Mean = 0.502ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2ε (Mean = 0.913ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 0.558ε (Mean = 0.298ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.558ε (Mean = 0.298ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 5.01ε (Mean = 1.89ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near -10 + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.73ε (Mean = 0.729ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0.866ε (Mean = 0.445ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 2.6ε (Mean = 1.05ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 6.34e+05ε (Mean = 1.2e+05ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 2.6ε (Mean = 0.956ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 2.6ε (Mean = 0.985ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 2.26ε (Mean = 1.08ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 2.26ε (Mean = 1.08ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.75ε (Mean = 0.819ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +</tr> +<tr> +<td> + <p> + near -55 + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.8ε (Mean = 0.817ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 3.87e+004ε (Mean = 6.71e+003ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL + 1.16:</em></span> Max = 1.8ε (Mean = 0.782ε))<br> (<span class="emphasis"><em>Rmath + 3.0.2:</em></span> Max = 6.36e+06ε (Mean = 1.13e+06ε))<br> (<span class="emphasis"><em>Cephes:</em></span> + Max = 2.7ε (Mean = 0.988ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.8ε (Mean = 0.847ε)</span><br> <br> + (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.79ε (Mean = 0.75ε))<br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 1.79ε (Mean = 0.75ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 98.5ε (Mean = 53.4ε)</span><br> <br> + (<span class="emphasis"><em><math.h>:</em></span> Max = 0ε (Mean = 0ε)) + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="math_toolkit.sf_gamma.tgamma.table_tgamma1pm1"></a><p class="title"><b>Table 6.2. Error rates for tgamma1pm1</b></p> +<div class="table-contents"><table class="table" summary="Error rates for tgamma1pm1"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + tgamma1pm1(dz) + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.982ε (Mean = 0.399ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0ε (Mean = 0ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.12ε (Mean = 0.49ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 3.97ε (Mean = 0.713ε)</span> + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"><h5> +<a name="math_toolkit.sf_gamma.tgamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.tgamma.testing"></a></span><a class="link" href="tgamma.html#math_toolkit.sf_gamma.tgamma.testing">Testing</a> + </h5> +<p> + 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. + </p> +<p> + The function <code class="computeroutput"><span class="identifier">tgamma1pm1</span></code> is + tested against values calculated very naively using the formula <code class="computeroutput"><span class="identifier">tgamma</span><span class="special">(</span><span class="number">1</span><span class="special">+</span><span class="identifier">dz</span><span class="special">)-</span><span class="number">1</span></code> with a + lanczos approximation accurate to around 100 decimal digits. + </p> +<h5> +<a name="math_toolkit.sf_gamma.tgamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.tgamma.implementation"></a></span><a class="link" href="tgamma.html#math_toolkit.sf_gamma.tgamma.implementation">Implementation</a> + </h5> +<p> + The generic version of the <code class="computeroutput"><span class="identifier">tgamma</span></code> + function is implemented Sterling's approximation for lgamma for large z: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamma6.svg"></span> + </p> +<p> + Following exponentiation, downward recursion is then used for small values + of z. + </p> +<p> + For types of known precision the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos + approximation</a> is used, a traits class <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lanczos</span><span class="special">::</span><span class="identifier">lanczos_traits</span></code> + maps type T to an appropriate approximation. + </p> +<p> + For z in the range -20 < z < 1 then recursion is used to shift to z + > 1 via: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamm3.svg"></span> + </p> +<p> + For very small z, this helps to preserve the identity: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamm4.svg"></span> + </p> +<p> + For z < -20 the reflection formula: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/gamm5.svg"></span> + </p> +<p> + is used. Particular care has to be taken to evaluate the <code class="literal">z * sin(π   * + z)</code> 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 <span class="emphasis"><em>exceptionally</em></span> + high). + </p> +<p> + Finally if the argument is a small integer then table lookup of the factorial + is used. + </p> +<p> + The function <code class="computeroutput"><span class="identifier">tgamma1pm1</span></code> is + implemented using rational approximations <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised + by JM</a> in the region <code class="computeroutput"><span class="special">-</span><span class="number">0.5</span> <span class="special"><</span> <span class="identifier">dz</span> + <span class="special"><</span> <span class="number">2</span></code>. + These are the same approximations (and internal routines) that are used for + <a class="link" href="lgamma.html" title="Log Gamma">lgamma</a>, and so aren't + detailed further here. The result of the approximation is <code class="computeroutput"><span class="identifier">log</span><span class="special">(</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">dz</span><span class="special">+</span><span class="number">1</span><span class="special">))</span></code> which can + fed into <a class="link" href="../powers/expm1.html" title="expm1">expm1</a> to give the + desired result. Outside the range <code class="computeroutput"><span class="special">-</span><span class="number">0.5</span> <span class="special"><</span> <span class="identifier">dz</span> + <span class="special"><</span> <span class="number">2</span></code> + then the naive formula <code class="computeroutput"><span class="identifier">tgamma1pm1</span><span class="special">(</span><span class="identifier">dz</span><span class="special">)</span> + <span class="special">=</span> <span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">dz</span><span class="special">+</span><span class="number">1</span><span class="special">)-</span><span class="number">1</span></code> + can be used directly. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lgamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> 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 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Trigamma</title> +<link rel="stylesheet" href="../../math.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> +<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> +<link rel="up" href="../sf_gamma.html" title="Gamma Functions"> +<link rel="prev" href="digamma.html" title="Digamma"> +<link rel="next" href="polygamma.html" title="Polygamma"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> +<td align="center"><a href="../../../../../../index.html">Home</a></td> +<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="digamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="polygamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="math_toolkit.sf_gamma.trigamma"></a><a class="link" href="trigamma.html" title="Trigamma">Trigamma</a> +</h3></div></div></div> +<h5> +<a name="math_toolkit.sf_gamma.trigamma.h0"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.trigamma.synopsis"></a></span><a class="link" href="trigamma.html#math_toolkit.sf_gamma.trigamma.synopsis">Synopsis</a> + </h5> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">trigamma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">trigamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> +<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">trigamma</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> + +<span class="special">}}</span> <span class="comment">// namespaces</span> +</pre> +<h5> +<a name="math_toolkit.sf_gamma.trigamma.h1"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.trigamma.description"></a></span><a class="link" href="trigamma.html#math_toolkit.sf_gamma.trigamma.description">Description</a> + </h5> +<p> + Returns the trigamma function of <span class="emphasis"><em>x</em></span>. Trigamma is defined + as the derivative of the digamma function: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/trigamma1.svg"></span> + </p> +<p> + <span class="inlinemediaobject"><img src="../../../graphs/trigamma.svg" align="middle"></span> + </p> +<p> + The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> 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 <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy + documentation for more details</a>. + </p> +<p> + The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result + type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type + T otherwise. + </p> +<h5> +<a name="math_toolkit.sf_gamma.trigamma.h2"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.trigamma.accuracy"></a></span><a class="link" href="trigamma.html#math_toolkit.sf_gamma.trigamma.accuracy">Accuracy</a> + </h5> +<p> + 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 <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively zero error</a>. + </p> +<div class="table"> +<a name="math_toolkit.sf_gamma.trigamma.table_trigamma"></a><p class="title"><b>Table 6.5. Error rates for trigamma</b></p> +<div class="table-contents"><table class="table" summary="Error rates for trigamma"> +<colgroup> +<col> +<col> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + </th> +<th> + <p> + Microsoft Visual C++ version 12.0<br> Win32<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> double + </p> + </th> +<th> + <p> + GNU C++ version 5.1.0<br> linux<br> long double + </p> + </th> +<th> + <p> + Sun compiler version 0x5130<br> Sun Solaris<br> long double + </p> + </th> +</tr></thead> +<tbody><tr> +<td> + <p> + Mathematica Data + </p> + </td> +<td> + <p> + <span class="blue">Max = 1ε (Mean = 0.382ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 0.998ε (Mean = 0.105ε)</span><br> <br> + (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 1.34e+04ε (Mean = 1.51e+03ε))<br> + (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.34e+04ε (Mean = 1.49e+03ε)) + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.28ε (Mean = 0.449ε)</span> + </p> + </td> +<td> + <p> + <span class="blue">Max = 1.28ε (Mean = 0.447ε)</span> + </p> + </td> +</tr></tbody> +</table></div> +</div> +<br class="table-break"><p> + 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. + </p> +<h5> +<a name="math_toolkit.sf_gamma.trigamma.h3"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.trigamma.testing"></a></span><a class="link" href="trigamma.html#math_toolkit.sf_gamma.trigamma.testing">Testing</a> + </h5> +<p> + Testing is against Mathematica generated spot values to 35 digit precision. + </p> +<h5> +<a name="math_toolkit.sf_gamma.trigamma.h4"></a> + <span class="phrase"><a name="math_toolkit.sf_gamma.trigamma.implementation"></a></span><a class="link" href="trigamma.html#math_toolkit.sf_gamma.trigamma.implementation">Implementation</a> + </h5> +<p> + The arbitrary precision version of this function simply calls <a class="link" href="polygamma.html" title="Polygamma">polygamma</a>. + </p> +<p> + For built in fixed precision types, negative arguments are first made positive + via: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/trigamma2.svg"></span> + </p> +<p> + Then arguments in the range [0, 1) are shifted to >= 1 via: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/trigamma3.svg"></span> + </p> +<p> + Then evaluation is via one of a number of rational approximations, for small + x these are of the form: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/trigamma4.svg"></span> + </p> +<p> + and for large x of the form: + </p> +<p> + <span class="inlinemediaobject"><img src="../../../equations/trigamma5.svg"></span> + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, + Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert + Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, + Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="digamma.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_gamma.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="polygamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> |
