[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

View File

@@ -0,0 +1,468 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.4.&#160;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&#949; (Mean = 0.369&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 1.84&#949; (Mean = 0.71&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.18&#949; (Mean = 0.331&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 0.919&#949; (Mean = 0.394&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.39&#949; (Mean = 0.413&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.39&#949; (Mean = 0.413&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Near the Positive Root
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.997&#949; (Mean = 0.527&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.891&#949; (Mean = 0.0995&#949;)</span><br>
<br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 135&#949; (Mean = 11.9&#949;))<br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 2.02e+03&#949; (Mean = 256&#949;))<br>
(<span class="emphasis"><em>Cephes:</em></span> Max = 1.42e+04&#949; (Mean = 1.14e+03&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.37&#949; (Mean = 0.477&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.31&#949; (Mean = 0.451&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Near Zero
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.953&#949; (Mean = 0.337&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 0.953&#949; (Mean = 0.348&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.17&#949; (Mean = 0.564&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 3.5&#949; (Mean = 1.04&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.984&#949; (Mean = 0.361&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.984&#949; (Mean = 0.361&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Negative Values
</p>
</td>
<td>
<p>
<span class="blue">Max = 214&#949; (Mean = 16.1&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 4.56e+04&#949; (Mean = 3.91e+03&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 4.6e+04&#949; (Mean = 3.94e+03&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 214&#949; (Mean = 16.4&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 180&#949; (Mean = 13&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 180&#949; (Mean = 13&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Values near 0
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 0.866&#949; (Mean = 0.387&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 3.58e+05&#949; (Mean = 1.6e+05&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 0.5&#949; (Mean = 0.224&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1&#949; (Mean = 0.592&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1&#949; (Mean = 0.592&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Integer arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.992&#949; (Mean = 0.452&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.992&#949; (Mean = 0.215&#949;)</span><br> <br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.18&#949; (Mean = 0.607&#949;))<br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.33&#949; (Mean = 0.982&#949;))<br>
(<span class="emphasis"><em>Cephes:</em></span> Max = 0.992&#949; (Mean = 0.383&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.888&#949; (Mean = 0.403&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.888&#949; (Mean = 0.403&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Digamma Function: Half integer arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.78&#949; (Mean = 0.314&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 1.09&#949; (Mean = 0.531&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 46.2&#949; (Mean = 7.24&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 8.56&#949; (Mean = 1.44&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.906&#949; (Mean = 0.409&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.906&#949; (Mean = 0.409&#949;)</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 &gt; 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 &gt; 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 &gt;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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,108 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,419 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.7.&#160;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&#949; (Mean = 1.25&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.56&#949; (Mean = 0.969&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 15.4&#949; (Mean = 2.09&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma + small delta ratios (negative delta)
</p>
</td>
<td>
<p>
<span class="blue">Max = 8.04&#949; (Mean = 1.31&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 8.67&#949; (Mean = 1.29&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 18.3&#949; (Mean = 2.03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma + small integer ratios
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.74&#949; (Mean = 0.736&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.96&#949; (Mean = 0.677&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.96&#949; (Mean = 0.677&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma + small integer ratios (negative delta)
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.15&#949; (Mean = 0.685&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.62&#949; (Mean = 0.451&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.62&#949; (Mean = 0.451&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
integer tgamma ratios
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.968&#949; (Mean = 0.386&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.997&#949; (Mean = 0.4&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.997&#949; (Mean = 0.4&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
integer tgamma ratios (negative delta)
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.974&#949; (Mean = 0.184&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.853&#949; (Mean = 0.176&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.853&#949; (Mean = 0.176&#949;)</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&#160;6.8.&#160;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&#949; (Mean = 1.27&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.09&#949; (Mean = 1.15&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 174&#949; (Mean = 61.2&#949;)</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 &#915;(x)/&#915;(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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,964 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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, &#915;(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 &gt; 0</em></span> and <span class="emphasis"><em>z
&gt;= 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&#160;18.&#160;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&#160;18.&#160;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">&lt;</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">&gt;</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">&lt;</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">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;6.9.&#160;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&#949; (Mean = 6.97&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.955&#949; (Mean = 0.05&#949;)</span><br> <br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 342&#949; (Mean = 45.8&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 389&#949; (Mean = 44&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 492&#949; (Mean = 101&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 41&#949; (Mean = 8.09&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 239&#949; (Mean = 30.2&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) small values
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.54&#949; (Mean = 0.439&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 4.82&#949; (Mean = 0.758&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.01&#949; (Mean = 0.306&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 21&#949; (Mean = 5.65&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.461&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.472&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) large values
</p>
</td>
<td>
<p>
<span class="blue">Max = 244&#949; (Mean = 20.2&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 1.02e+03&#949; (Mean = 105&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.11e+03&#949; (Mean = 67.5&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 8.18e+06&#949; (Mean = 7.69e+05&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.08e+04&#949; (Mean = 1.86e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.02e+04&#949; (Mean = 1.91e+03&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) integer and half integer values
</p>
</td>
<td>
<p>
<span class="blue">Max = 13&#949; (Mean = 2.93&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 128&#949; (Mean = 22.6&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 66.2&#949; (Mean = 12.2&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 83.6&#949; (Mean = 22.2&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 11.8&#949; (Mean = 2.65&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 71.6&#949; (Mean = 9.47&#949;)</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&#160;6.10.&#160;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&#949; (Mean = 4.03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.927&#949; (Mean = 0.035&#949;)</span><br> <br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 201&#949; (Mean = 13.5&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 131&#949; (Mean = 12.7&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 388&#949; (Mean = 93.8&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 31.3&#949; (Mean = 6.56&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 199&#949; (Mean = 26.6&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) small values
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.26&#949; (Mean = 0.732&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> <span class="red">Max = 1.38e+10&#949; (Mean = 1.05e+09&#949;))</span><br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 65.6&#949; (Mean = 11&#949;))<br>
(<span class="emphasis"><em>Cephes:</em></span> <span class="red">Max = 3.42e+11&#949; (Mean
= 4.1e+10&#949;))</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.45&#949; (Mean = 0.832&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.25&#949; (Mean = 0.81&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) large values
</p>
</td>
<td>
<p>
<span class="blue">Max = 470&#949; (Mean = 31.5&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 2.71e+04&#949; (Mean = 2.16e+03&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.02e+03&#949; (Mean = 62.7&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 8.17e+06&#949; (Mean = 7.7e+05&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.82e+03&#949; (Mean = 414&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.15e+04&#949; (Mean = 733&#949;)</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&#949; (Mean = 1.42&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 118&#949; (Mean = 12.5&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 138&#949; (Mean = 16.9&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 129&#949; (Mean = 26.5&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 11.1&#949; (Mean = 2.09&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 54.7&#949; (Mean = 6.16&#949;)</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&#160;6.11.&#160;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&#949; (Mean = 1.43&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.833&#949; (Mean = 0.0315&#949;)</span><br>
<br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 0.833&#949; (Mean = 0.0315&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.79&#949; (Mean = 1.38&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 363&#949; (Mean = 63.8&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) small values
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.57&#949; (Mean = 0.527&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.97&#949; (Mean = 0.552&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.97&#949; (Mean = 0.567&#949;)</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&#949; (Mean = 0.866&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.83&#949; (Mean = 1.12&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 84.7&#949; (Mean = 17.5&#949;)</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&#160;6.12.&#160;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&#949; (Mean = 1.71&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 200&#949; (Mean = 13.3&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 7.35&#949; (Mean = 1.69&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 412&#949; (Mean = 95.5&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
tgamma(a, z) small values
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.53&#949; (Mean = 0.66&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.753&#949; (Mean = 0.0474&#949;)</span><br>
<br> (<span class="emphasis"><em>GSL 1.16:</em></span> <span class="red">Max =
1.38e+10&#949; (Mean = 1.05e+09&#949;))</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.13&#949; (Mean = 0.717&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.13&#949; (Mean = 0.712&#949;)</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&#949; (Mean = 1.44&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 117&#949; (Mean = 12.5&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.52&#949; (Mean = 1.52&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 79.6&#949; (Mean = 20.9&#949;)</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 &#915;(a) or 1 when <span class="emphasis"><em>x
- (1</em></span>(3x)) &gt; a and x &gt; 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 &gt; 1.1)</em></span> or by subtraction of the lower integral
from either &#915;(a) or 1 when <span class="emphasis"><em>x - (1</em></span>(3x)) &lt; a/.
</p>
<p>
For <span class="emphasis"><em>x &lt; 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 &lt; 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 &lt; a</em></span> as the crossover criterion for <span class="emphasis"><em>0.5 &lt;
x &lt;= 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 &lt;= 0.5</em></span>
then using <span class="emphasis"><em>-0.4 / log(x) &lt; 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 &lt;= a &lt;
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 &lt;= a &lt; 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">&gt;</span> <span class="number">20</span><span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">&lt;</span> <span class="number">200</span><span class="special">)</span> <span class="special">&amp;&amp;</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">&lt;</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">&gt;</span> <span class="number">200</span><span class="special">)</span> <span class="special">&amp;&amp;</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">&lt;</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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,623 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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 &gt; 0</em></span> and <span class="emphasis"><em>1 &gt;= p,q &gt;= 0</em></span>.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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 &gt; 0</em></span> and <span class="emphasis"><em>1 &gt;= p,q &gt;= 0</em></span>.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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 &gt; 0</em></span> and <span class="emphasis"><em>1 &gt;= p,q &gt;= 0</em></span>.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</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">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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 &gt; 0</em></span> and <span class="emphasis"><em>1 &gt;= p,q &gt;= 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&#160;6.13.&#160;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&#949; (Mean = 0.307&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.993&#949; (Mean = 0.15&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.88&#949; (Mean = 0.868&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.62&#949; (Mean = 0.365&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.86&#949; (Mean = 0.405&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
incomplete gamma inverse(a, z) large values
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.924&#949; (Mean = 0.118&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 0.816&#949; (Mean = 0.0874&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.509&#949; (Mean = 0.0447&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.509&#949; (Mean = 0.0447&#949;)</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&#949; (Mean = 108&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 441&#949; (Mean = 53.9&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 547&#949; (Mean = 61.6&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 9.17e+03&#949; (Mean = 1.32e+03&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.09e+04&#949; (Mean = 1.46e+03&#949;)</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&#160;6.14.&#160;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&#949; (Mean = 0.475&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.912&#949; (Mean = 0.154&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 4.66&#949; (Mean = 0.792&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.2&#949; (Mean = 0.659&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.2&#949; (Mean = 0.661&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
incomplete gamma inverse(a, z) large values
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.814&#949; (Mean = 0.0856&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.894&#949; (Mean = 0.0915&#949;)</span><br>
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 0.894&#949; (Mean = 0.106&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
incomplete gamma inverse(a, z) small values
</p>
</td>
<td>
<p>
<span class="blue">Max = 451&#949; (Mean = 65&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 292&#949; (Mean = 36.4&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 415&#949; (Mean = 48.7&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 8.28e+03&#949; (Mean = 963&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 8.98e+03&#949; (Mean = 877&#949;)</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&#160;6.15.&#160;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&#949; (Mean = 0.997&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.44&#949; (Mean = 1.1&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.08&#949; (Mean = 1.12&#949;)</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&#160;6.16.&#160;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&#949; (Mean = 1.09&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 6.91&#949; (Mean = 1.17&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 7.86&#949; (Mean = 1.25&#949;)</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&amp;coll=portal&amp;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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,488 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.3.&#160;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&#949; (Mean = 0.167&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.958&#949; (Mean = 0.38&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 33.6&#949; (Mean = 2.78&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1.55&#949; (Mean = 0.592&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.55&#949; (Mean = 0.512&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.991&#949; (Mean = 0.311&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.67&#949; (Mean = 0.487&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.67&#949; (Mean = 0.487&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.991&#949; (Mean = 0.383&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.36&#949; (Mean = 0.476&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 0
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.964&#949; (Mean = 0.462&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.962&#949; (Mean = 0.372&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 5.21&#949; (Mean = 1.57&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 0&#949; (Mean = 0&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.16&#949; (Mean = 0.341&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.42&#949; (Mean = 0.566&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 0.964&#949; (Mean = 0.543&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.964&#949; (Mean = 0.543&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.42&#949; (Mean = 0.566&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.964&#949; (Mean = 0.543&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 1
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.867&#949; (Mean = 0.468&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.906&#949; (Mean = 0.565&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 442&#949; (Mean = 88.8&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 7.99e+04&#949; (Mean = 1.68e+04&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.14e+05&#949; (Mean = 2.64e+04&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.948&#949; (Mean = 0.36&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 0.615&#949; (Mean = 0.096&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.615&#949; (Mean = 0.096&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.866&#949; (Mean = 0.355&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.71&#949; (Mean = 0.581&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 2
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.591&#949; (Mean = 0.159&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.741&#949; (Mean = 0.473&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 1.17e+03&#949; (Mean = 274&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 2.63e+05&#949; (Mean = 5.84e+04&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 5.08e+05&#949; (Mean = 9.04e+04&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.878&#949; (Mean = 0.242&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 0.741&#949; (Mean = 0.263&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.741&#949; (Mean = 0.263&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.878&#949; (Mean = 0.241&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.598&#949; (Mean = 0.235&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near -10
</p>
</td>
<td>
<p>
<span class="blue">Max = 4.22&#949; (Mean = 1.33&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.997&#949; (Mean = 0.444&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 24.9&#949; (Mean = 4.6&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 2.41e+05&#949; (Mean = 4.29e+04&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 0.997&#949; (Mean = 0.429&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.81&#949; (Mean = 1.01&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 3.01&#949; (Mean = 0.86&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 3.01&#949; (Mean = 0.86&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.81&#949; (Mean = 1.01&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 3.04&#949; (Mean = 1.01&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near -55
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.821&#949; (Mean = 0.419&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 249&#949; (Mean = 43.1&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 7.02&#949; (Mean = 1.47&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 4.08e+04&#949; (Mean = 7.26e+03&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.64&#949; (Mean = 0.693&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.821&#949; (Mean = 0.513&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.58&#949; (Mean = 0.672&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.58&#949; (Mean = 0.672&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.59&#949; (Mean = 0.587&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.821&#949; (Mean = 0.674&#949;))
</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> &#160; 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 &lt; 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 &gt; 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 &lt; 1 the recurrence relation can be used to move to z &gt;
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
-&gt; 1</em></span>:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/lgamm5.svg"></span>
</p>
<p>
The C<sub>k</sub> &#160; 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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,410 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.6.&#160;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&#949; (Mean = 1.53&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.824&#949; (Mean = 0.0574&#949;)</span><br>
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 108&#949; (Mean = 15.2&#949;))<br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 62.9&#949; (Mean = 12.8&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 7.38&#949; (Mean = 1.84&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 18.3&#949; (Mean = 4.16&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Mathematica Data - large arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 150&#949; (Mean = 15.1&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.998&#949; (Mean = 0.0592&#949;)</span><br>
<br> (<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max
= 1.71e+56&#949; (Mean = 1.01e+55&#949;) <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&#949; (Mean = 32.8&#949;) <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&#949; (Mean = 0.323&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.35&#949; (Mean = 0.34&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Mathematica Data - negative arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 497&#949; (Mean = 129&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.516&#949; (Mean = 0.022&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> <span class="red">Max = +INF&#949; (Mean
= +INF&#949;) <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&#949; (Mean = 3.04&#949;) <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&#949; (Mean = 87.7&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 269&#949; (Mean = 87.9&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Mathematica Data - large negative arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 162&#949; (Mean = 101&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> <span class="red">Max = +INF&#949; (Mean = +INF&#949;) <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&#949; (Mean = 0.197&#949;) <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&#949; (Mean = 96.4&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 155&#949; (Mean = 96.4&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Mathematica Data - small arguments
</p>
</td>
<td>
<p>
<span class="blue">Max = 3&#949; (Mean = 0.496&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 106&#949; (Mean = 20&#949;))<br> (<span class="emphasis"><em>GSL 1.16:</em></span>
Max = 15.2&#949; (Mean = 5.03&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.33&#949; (Mean = 0.75&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.33&#949; (Mean = 0.75&#949;)</span>
</p>
</td>
</tr>
<tr>
<td>
<p>
Mathematica Data - Large orders and other bug cases
</p>
</td>
<td>
<p>
<span class="blue">Max = 200&#949; (Mean = 57.2&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> <span class="red">Max = +INF&#949; (Mean = +INF&#949;) <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&#949; (Mean = 39.3&#949;) <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&#949; (Mean = 13.3&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 90.1&#949; (Mean = 30.6&#949;)</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 -&#8734; to +&#8734; 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 &lt; 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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,532 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.1.&#160;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&#949; (Mean = 0.491&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 3.17&#949; (Mean = 0.928&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 3.95&#949; (Mean = 0.783&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 314&#949; (Mean = 93.4&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 3.19&#949; (Mean = 0.884&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.96&#949; (Mean = 0.483&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.66&#949; (Mean = 0.584&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.66&#949; (Mean = 0.584&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 172&#949; (Mean = 41&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 0
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.96&#949; (Mean = 0.684&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1&#949; (Mean = 0.405&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 4.51&#949; (Mean = 1.92&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1&#949; (Mean = 0.335&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1&#949; (Mean = 0.548&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.73&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1&#949; (Mean = 0.376&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1&#949; (Mean = 0.376&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.647&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.5&#949; (Mean = 0.0791&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 1
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.865&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1&#949; (Mean = 0.4&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 4.41&#949; (Mean = 1.81&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1&#949; (Mean = 0.32&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1&#949; (Mean = 0.518&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.85&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 0.918&#949; (Mean = 0.203&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.918&#949; (Mean = 0.203&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.01&#949; (Mean = 1.06&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1&#949; (Mean = 0.175&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near 2
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.995&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 7.95&#949; (Mean = 3.12&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 1&#949; (Mean = 0.191&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 1.09&#949; (Mean = 0.502&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2&#949; (Mean = 0.913&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 0.558&#949; (Mean = 0.298&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.558&#949; (Mean = 0.298&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 5.01&#949; (Mean = 1.89&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near -10
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.73&#949; (Mean = 0.729&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0.866&#949; (Mean = 0.445&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 2.6&#949; (Mean = 1.05&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 6.34e+05&#949; (Mean = 1.2e+05&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 2.6&#949; (Mean = 0.956&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 2.6&#949; (Mean = 0.985&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 2.26&#949; (Mean = 1.08&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 2.26&#949; (Mean = 1.08&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.75&#949; (Mean = 0.819&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0&#949; (Mean = 0&#949;))
</p>
</td>
</tr>
<tr>
<td>
<p>
near -55
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.8&#949; (Mean = 0.817&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 3.87e+004&#949; (Mean = 6.71e+003&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
1.16:</em></span> Max = 1.8&#949; (Mean = 0.782&#949;))<br> (<span class="emphasis"><em>Rmath
3.0.2:</em></span> Max = 6.36e+06&#949; (Mean = 1.13e+06&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
Max = 2.7&#949; (Mean = 0.988&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.8&#949; (Mean = 0.847&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.79&#949; (Mean = 0.75&#949;))<br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 1.79&#949; (Mean = 0.75&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 98.5&#949; (Mean = 53.4&#949;)</span><br> <br>
(<span class="emphasis"><em>&lt;math.h&gt;:</em></span> Max = 0&#949; (Mean = 0&#949;))
</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&#160;6.2.&#160;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&#949; (Mean = 0.399&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.12&#949; (Mean = 0.49&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 3.97&#949; (Mean = 0.713&#949;)</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 &lt; z &lt; 1 then recursion is used to shift to z
&gt; 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 &lt; -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(&#960; &#160; *
z)</code> part: a special routine is used to reduce z prior to multiplying
by &#960; &#160; to ensure that the result in is the range [0, &#960;/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">&lt;</span> <span class="identifier">dz</span>
<span class="special">&lt;</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">&lt;</span> <span class="identifier">dz</span>
<span class="special">&lt;</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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>

View File

@@ -0,0 +1,206 @@
<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.6.0">
<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">&lt;</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">&gt;</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">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</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">&lt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</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&#160;18.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</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&#160;18.&#160;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&#160;18.&#160;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&#160;6.5.&#160;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&#949; (Mean = 0.382&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 0.998&#949; (Mean = 0.105&#949;)</span><br> <br>
(<span class="emphasis"><em>Rmath 3.0.2:</em></span> Max = 1.34e+04&#949; (Mean = 1.51e+03&#949;))<br>
(<span class="emphasis"><em>GSL 1.16:</em></span> Max = 1.34e+04&#949; (Mean = 1.49e+03&#949;))
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.28&#949; (Mean = 0.449&#949;)</span>
</p>
</td>
<td>
<p>
<span class="blue">Max = 1.28&#949; (Mean = 0.447&#949;)</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 &gt;= 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 &#169; 2006-2010, 2012-2014, 2017 Nikhar
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam
Sewani, Benjamin Sobotta, Nicholas Thompson, 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>