Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / sf_gamma / igamma.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Incomplete Gamma Functions</title>
5 <link rel="stylesheet" href="../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../sf_gamma.html" title="Gamma Functions">
9 <link rel="prev" href="gamma_ratios.html" title="Ratios of Gamma Functions">
10 <link rel="next" href="igamma_inv.html" title="Incomplete Gamma Function Inverses">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <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>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="math_toolkit.sf_gamma.igamma"></a><a class="link" href="igamma.html" title="Incomplete Gamma Functions">Incomplete Gamma Functions</a>
28 </h3></div></div></div>
29 <h5>
30 <a name="math_toolkit.sf_gamma.igamma.h0"></a>
31         <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>
32       </h5>
33 <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>
34 </pre>
35 <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>
36
37 <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>
38 <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>
39
40 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
41 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
42
43 <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>
44 <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>
45
46 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
47 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
48
49 <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>
50 <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>
51
52 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
53 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
54
55 <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>
56 <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>
57
58 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
59 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
60
61 <span class="special">}}</span> <span class="comment">// namespaces</span>
62 </pre>
63 <h5>
64 <a name="math_toolkit.sf_gamma.igamma.h1"></a>
65         <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>
66       </h5>
67 <p>
68         There are four <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html" target="_top">incomplete
69         gamma functions</a>: two are normalised versions (also known as <span class="emphasis"><em>regularized</em></span>
70         incomplete gamma functions) that return values in the range [0, 1], and two
71         are non-normalised and return values in the range [0, &#915;(a)]. Users interested
72         in statistical applications should use the <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html" target="_top">normalised
73         versions (<code class="computeroutput"><span class="identifier">gamma_p</span></code> and <code class="computeroutput"><span class="identifier">gamma_q</span></code>)</a>.
74       </p>
75 <p>
76         All of these functions require <span class="emphasis"><em>a &gt; 0</em></span> and <span class="emphasis"><em>z
77         &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>.
78       </p>
79 <p>
80         The final <a class="link" href="../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
81         be used to control the behaviour of the function: how it handles errors,
82         what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">policy
83         documentation for more details</a>.
84       </p>
85 <p>
86         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
87         type calculation rules</em></span></a> when T1 and T2 are different types,
88         otherwise the return type is simply T1.
89       </p>
90 <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>
91 <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>
92
93 <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>
94 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
95 </pre>
96 <p>
97         Returns the normalised lower incomplete gamma function of a and z:
98       </p>
99 <div class="blockquote"><blockquote class="blockquote"><p>
100           <span class="inlinemediaobject"><img src="../../../equations/igamma4.svg"></span>
101
102         </p></blockquote></div>
103 <p>
104         This function changes rapidly from 0 to 1 around the point z == a:
105       </p>
106 <div class="blockquote"><blockquote class="blockquote"><p>
107           <span class="inlinemediaobject"><img src="../../../graphs/gamma_p.svg" align="middle"></span>
108
109         </p></blockquote></div>
110 <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>
111 <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>
112
113 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
114 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
115 </pre>
116 <p>
117         Returns the normalised upper incomplete gamma function of a and z:
118       </p>
119 <div class="blockquote"><blockquote class="blockquote"><p>
120           <span class="inlinemediaobject"><img src="../../../equations/igamma3.svg"></span>
121
122         </p></blockquote></div>
123 <p>
124         This function changes rapidly from 1 to 0 around the point z == a:
125       </p>
126 <div class="blockquote"><blockquote class="blockquote"><p>
127           <span class="inlinemediaobject"><img src="../../../graphs/gamma_q.svg" align="middle"></span>
128
129         </p></blockquote></div>
130 <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>
131 <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>
132
133 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
134 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
135 </pre>
136 <p>
137         Returns the full (non-normalised) lower incomplete gamma function of a and
138         z:
139       </p>
140 <div class="blockquote"><blockquote class="blockquote"><p>
141           <span class="inlinemediaobject"><img src="../../../equations/igamma2.svg"></span>
142
143         </p></blockquote></div>
144 <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>
145 <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>
146
147 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
148 <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;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
149 </pre>
150 <p>
151         Returns the full (non-normalised) upper incomplete gamma function of a and
152         z:
153       </p>
154 <div class="blockquote"><blockquote class="blockquote"><p>
155           <span class="inlinemediaobject"><img src="../../../equations/igamma1.svg"></span>
156
157         </p></blockquote></div>
158 <h5>
159 <a name="math_toolkit.sf_gamma.igamma.h2"></a>
160         <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>
161       </h5>
162 <p>
163         The following tables give peak and mean relative errors in over various domains
164         of a and z, along with comparisons to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a>
165         and <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries.
166         Note that only results for the widest floating-point type on the system are
167         given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
168         zero error</a>.
169       </p>
170 <p>
171         Note that errors grow as <span class="emphasis"><em>a</em></span> grows larger.
172       </p>
173 <p>
174         Note also that the higher error rates for the 80 and 128 bit long double
175         results are somewhat misleading: expected results that are zero at 64-bit
176         double precision may be non-zero - but exceptionally small - with the larger
177         exponent range of a long double. These results therefore reflect the more
178         extreme nature of the tests conducted for these types.
179       </p>
180 <p>
181         All values are in units of epsilon.
182       </p>
183 <div class="table">
184 <a name="math_toolkit.sf_gamma.igamma.table_gamma_p"></a><p class="title"><b>Table&#160;8.9.&#160;Error rates for gamma_p</b></p>
185 <div class="table-contents"><table class="table" summary="Error rates for gamma_p">
186 <colgroup>
187 <col>
188 <col>
189 <col>
190 <col>
191 <col>
192 </colgroup>
193 <thead><tr>
194 <th>
195               </th>
196 <th>
197                 <p>
198                   GNU C++ version 7.1.0<br> linux<br> double
199                 </p>
200               </th>
201 <th>
202                 <p>
203                   GNU C++ version 7.1.0<br> linux<br> long double
204                 </p>
205               </th>
206 <th>
207                 <p>
208                   Sun compiler version 0x5150<br> Sun Solaris<br> long double
209                 </p>
210               </th>
211 <th>
212                 <p>
213                   Microsoft Visual C++ version 14.1<br> Win32<br> double
214                 </p>
215               </th>
216 </tr></thead>
217 <tbody>
218 <tr>
219 <td>
220                 <p>
221                   tgamma(a, z) medium values
222                 </p>
223               </td>
224 <td>
225                 <p>
226                   <span class="blue">Max = 0.955&#949; (Mean = 0.05&#949;)</span><br> <br>
227                   (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 342&#949; (Mean = 45.8&#949;))<br> (<span class="emphasis"><em>Rmath
228                   3.2.3:</em></span> Max = 389&#949; (Mean = 44&#949;))
229                 </p>
230               </td>
231 <td>
232                 <p>
233                   <span class="blue">Max = 41.6&#949; (Mean = 8.09&#949;)</span>
234                 </p>
235               </td>
236 <td>
237                 <p>
238                   <span class="blue">Max = 239&#949; (Mean = 30.2&#949;)</span>
239                 </p>
240               </td>
241 <td>
242                 <p>
243                   <span class="blue">Max = 35.1&#949; (Mean = 6.98&#949;)</span>
244                 </p>
245               </td>
246 </tr>
247 <tr>
248 <td>
249                 <p>
250                   tgamma(a, z) small values
251                 </p>
252               </td>
253 <td>
254                 <p>
255                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
256                   2.1:</em></span> Max = 4.82&#949; (Mean = 0.758&#949;))<br> (<span class="emphasis"><em>Rmath
257                   3.2.3:</em></span> Max = 1.01&#949; (Mean = 0.306&#949;))
258                 </p>
259               </td>
260 <td>
261                 <p>
262                   <span class="blue">Max = 2&#949; (Mean = 0.464&#949;)</span>
263                 </p>
264               </td>
265 <td>
266                 <p>
267                   <span class="blue">Max = 2&#949; (Mean = 0.461&#949;)</span>
268                 </p>
269               </td>
270 <td>
271                 <p>
272                   <span class="blue">Max = 1.54&#949; (Mean = 0.439&#949;)</span>
273                 </p>
274               </td>
275 </tr>
276 <tr>
277 <td>
278                 <p>
279                   tgamma(a, z) large values
280                 </p>
281               </td>
282 <td>
283                 <p>
284                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
285                   2.1:</em></span> Max = 1.02e+03&#949; (Mean = 105&#949;))<br> (<span class="emphasis"><em>Rmath
286                   3.2.3:</em></span> Max = 1.11e+03&#949; (Mean = 67.5&#949;))
287                 </p>
288               </td>
289 <td>
290                 <p>
291                   <span class="blue">Max = 3.08e+04&#949; (Mean = 1.86e+03&#949;)</span>
292                 </p>
293               </td>
294 <td>
295                 <p>
296                   <span class="blue">Max = 3.02e+04&#949; (Mean = 1.91e+03&#949;)</span>
297                 </p>
298               </td>
299 <td>
300                 <p>
301                   <span class="blue">Max = 243&#949; (Mean = 20.2&#949;)</span>
302                 </p>
303               </td>
304 </tr>
305 <tr>
306 <td>
307                 <p>
308                   tgamma(a, z) integer and half integer values
309                 </p>
310               </td>
311 <td>
312                 <p>
313                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
314                   2.1:</em></span> Max = 128&#949; (Mean = 22.6&#949;))<br> (<span class="emphasis"><em>Rmath
315                   3.2.3:</em></span> Max = 66.2&#949; (Mean = 12.2&#949;))
316                 </p>
317               </td>
318 <td>
319                 <p>
320                   <span class="blue">Max = 11.8&#949; (Mean = 2.66&#949;)</span>
321                 </p>
322               </td>
323 <td>
324                 <p>
325                   <span class="blue">Max = 71.6&#949; (Mean = 9.47&#949;)</span>
326                 </p>
327               </td>
328 <td>
329                 <p>
330                   <span class="blue">Max = 13&#949; (Mean = 2.97&#949;)</span>
331                 </p>
332               </td>
333 </tr>
334 </tbody>
335 </table></div>
336 </div>
337 <br class="table-break"><div class="table">
338 <a name="math_toolkit.sf_gamma.igamma.table_gamma_q"></a><p class="title"><b>Table&#160;8.10.&#160;Error rates for gamma_q</b></p>
339 <div class="table-contents"><table class="table" summary="Error rates for gamma_q">
340 <colgroup>
341 <col>
342 <col>
343 <col>
344 <col>
345 <col>
346 </colgroup>
347 <thead><tr>
348 <th>
349               </th>
350 <th>
351                 <p>
352                   GNU C++ version 7.1.0<br> linux<br> double
353                 </p>
354               </th>
355 <th>
356                 <p>
357                   GNU C++ version 7.1.0<br> linux<br> long double
358                 </p>
359               </th>
360 <th>
361                 <p>
362                   Sun compiler version 0x5150<br> Sun Solaris<br> long double
363                 </p>
364               </th>
365 <th>
366                 <p>
367                   Microsoft Visual C++ version 14.1<br> Win32<br> double
368                 </p>
369               </th>
370 </tr></thead>
371 <tbody>
372 <tr>
373 <td>
374                 <p>
375                   tgamma(a, z) medium values
376                 </p>
377               </td>
378 <td>
379                 <p>
380                   <span class="blue">Max = 0.927&#949; (Mean = 0.035&#949;)</span><br> <br>
381                   (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 201&#949; (Mean = 13.5&#949;))<br> (<span class="emphasis"><em>Rmath
382                   3.2.3:</em></span> Max = 131&#949; (Mean = 12.7&#949;))
383                 </p>
384               </td>
385 <td>
386                 <p>
387                   <span class="blue">Max = 32.3&#949; (Mean = 6.61&#949;)</span>
388                 </p>
389               </td>
390 <td>
391                 <p>
392                   <span class="blue">Max = 199&#949; (Mean = 26.6&#949;)</span>
393                 </p>
394               </td>
395 <td>
396                 <p>
397                   <span class="blue">Max = 23.7&#949; (Mean = 4&#949;)</span>
398                 </p>
399               </td>
400 </tr>
401 <tr>
402 <td>
403                 <p>
404                   tgamma(a, z) small values
405                 </p>
406               </td>
407 <td>
408                 <p>
409                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
410                   2.1:</em></span> <span class="red">Max = 1.38e+10&#949; (Mean = 1.05e+09&#949;))</span><br>
411                   (<span class="emphasis"><em>Rmath 3.2.3:</em></span> Max = 65.6&#949; (Mean = 11&#949;))
412                 </p>
413               </td>
414 <td>
415                 <p>
416                   <span class="blue">Max = 2.45&#949; (Mean = 0.885&#949;)</span>
417                 </p>
418               </td>
419 <td>
420                 <p>
421                   <span class="blue">Max = 2.45&#949; (Mean = 0.819&#949;)</span>
422                 </p>
423               </td>
424 <td>
425                 <p>
426                   <span class="blue">Max = 2.26&#949; (Mean = 0.74&#949;)</span>
427                 </p>
428               </td>
429 </tr>
430 <tr>
431 <td>
432                 <p>
433                   tgamma(a, z) large values
434                 </p>
435               </td>
436 <td>
437                 <p>
438                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
439                   2.1:</em></span> Max = 2.71e+04&#949; (Mean = 2.16e+03&#949;))<br> (<span class="emphasis"><em>Rmath
440                   3.2.3:</em></span> Max = 1.02e+03&#949; (Mean = 62.7&#949;))
441                 </p>
442               </td>
443 <td>
444                 <p>
445                   <span class="blue">Max = 6.82e+03&#949; (Mean = 414&#949;)</span>
446                 </p>
447               </td>
448 <td>
449                 <p>
450                   <span class="blue">Max = 1.15e+04&#949; (Mean = 733&#949;)</span>
451                 </p>
452               </td>
453 <td>
454                 <p>
455                   <span class="blue">Max = 469&#949; (Mean = 31.5&#949;)</span>
456                 </p>
457               </td>
458 </tr>
459 <tr>
460 <td>
461                 <p>
462                   tgamma(a, z) integer and half integer values
463                 </p>
464               </td>
465 <td>
466                 <p>
467                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
468                   2.1:</em></span> Max = 118&#949; (Mean = 12.5&#949;))<br> (<span class="emphasis"><em>Rmath
469                   3.2.3:</em></span> Max = 138&#949; (Mean = 16.9&#949;))
470                 </p>
471               </td>
472 <td>
473                 <p>
474                   <span class="blue">Max = 11.1&#949; (Mean = 2.07&#949;)</span>
475                 </p>
476               </td>
477 <td>
478                 <p>
479                   <span class="blue">Max = 54.7&#949; (Mean = 6.16&#949;)</span>
480                 </p>
481               </td>
482 <td>
483                 <p>
484                   <span class="blue">Max = 8.72&#949; (Mean = 1.48&#949;)</span>
485                 </p>
486               </td>
487 </tr>
488 </tbody>
489 </table></div>
490 </div>
491 <br class="table-break"><div class="table">
492 <a name="math_toolkit.sf_gamma.igamma.table_tgamma_lower"></a><p class="title"><b>Table&#160;8.11.&#160;Error rates for tgamma_lower</b></p>
493 <div class="table-contents"><table class="table" summary="Error rates for tgamma_lower">
494 <colgroup>
495 <col>
496 <col>
497 <col>
498 <col>
499 <col>
500 </colgroup>
501 <thead><tr>
502 <th>
503               </th>
504 <th>
505                 <p>
506                   GNU C++ version 7.1.0<br> linux<br> double
507                 </p>
508               </th>
509 <th>
510                 <p>
511                   GNU C++ version 7.1.0<br> linux<br> long double
512                 </p>
513               </th>
514 <th>
515                 <p>
516                   Sun compiler version 0x5150<br> Sun Solaris<br> long double
517                 </p>
518               </th>
519 <th>
520                 <p>
521                   Microsoft Visual C++ version 14.1<br> Win32<br> double
522                 </p>
523               </th>
524 </tr></thead>
525 <tbody>
526 <tr>
527 <td>
528                 <p>
529                   tgamma(a, z) medium values
530                 </p>
531               </td>
532 <td>
533                 <p>
534                   <span class="blue">Max = 0.833&#949; (Mean = 0.0315&#949;)</span><br>
535                   <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 0.833&#949; (Mean = 0.0315&#949;))
536                 </p>
537               </td>
538 <td>
539                 <p>
540                   <span class="blue">Max = 6.79&#949; (Mean = 1.46&#949;)</span>
541                 </p>
542               </td>
543 <td>
544                 <p>
545                   <span class="blue">Max = 363&#949; (Mean = 63.8&#949;)</span>
546                 </p>
547               </td>
548 <td>
549                 <p>
550                   <span class="blue">Max = 5.62&#949; (Mean = 1.49&#949;)</span>
551                 </p>
552               </td>
553 </tr>
554 <tr>
555 <td>
556                 <p>
557                   tgamma(a, z) small values
558                 </p>
559               </td>
560 <td>
561                 <p>
562                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
563                   2.1:</em></span> Max = 0&#949; (Mean = 0&#949;))
564                 </p>
565               </td>
566 <td>
567                 <p>
568                   <span class="blue">Max = 1.97&#949; (Mean = 0.555&#949;)</span>
569                 </p>
570               </td>
571 <td>
572                 <p>
573                   <span class="blue">Max = 1.97&#949; (Mean = 0.558&#949;)</span>
574                 </p>
575               </td>
576 <td>
577                 <p>
578                   <span class="blue">Max = 1.57&#949; (Mean = 0.525&#949;)</span>
579                 </p>
580               </td>
581 </tr>
582 <tr>
583 <td>
584                 <p>
585                   tgamma(a, z) integer and half integer values
586                 </p>
587               </td>
588 <td>
589                 <p>
590                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
591                   2.1:</em></span> Max = 0&#949; (Mean = 0&#949;))
592                 </p>
593               </td>
594 <td>
595                 <p>
596                   <span class="blue">Max = 4.83&#949; (Mean = 1.15&#949;)</span>
597                 </p>
598               </td>
599 <td>
600                 <p>
601                   <span class="blue">Max = 84.7&#949; (Mean = 17.5&#949;)</span>
602                 </p>
603               </td>
604 <td>
605                 <p>
606                   <span class="blue">Max = 2.69&#949; (Mean = 0.849&#949;)</span>
607                 </p>
608               </td>
609 </tr>
610 </tbody>
611 </table></div>
612 </div>
613 <br class="table-break"><div class="table">
614 <a name="math_toolkit.sf_gamma.igamma.table_tgamma_incomplete_"></a><p class="title"><b>Table&#160;8.12.&#160;Error rates for tgamma (incomplete)</b></p>
615 <div class="table-contents"><table class="table" summary="Error rates for tgamma (incomplete)">
616 <colgroup>
617 <col>
618 <col>
619 <col>
620 <col>
621 <col>
622 </colgroup>
623 <thead><tr>
624 <th>
625               </th>
626 <th>
627                 <p>
628                   GNU C++ version 7.1.0<br> linux<br> double
629                 </p>
630               </th>
631 <th>
632                 <p>
633                   GNU C++ version 7.1.0<br> linux<br> long double
634                 </p>
635               </th>
636 <th>
637                 <p>
638                   Sun compiler version 0x5150<br> Sun Solaris<br> long double
639                 </p>
640               </th>
641 <th>
642                 <p>
643                   Microsoft Visual C++ version 14.1<br> Win32<br> double
644                 </p>
645               </th>
646 </tr></thead>
647 <tbody>
648 <tr>
649 <td>
650                 <p>
651                   tgamma(a, z) medium values
652                 </p>
653               </td>
654 <td>
655                 <p>
656                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
657                   2.1:</em></span> Max = 200&#949; (Mean = 13.3&#949;))
658                 </p>
659               </td>
660 <td>
661                 <p>
662                   <span class="blue">Max = 8.47&#949; (Mean = 1.9&#949;)</span>
663                 </p>
664               </td>
665 <td>
666                 <p>
667                   <span class="blue">Max = 412&#949; (Mean = 95.5&#949;)</span>
668                 </p>
669               </td>
670 <td>
671                 <p>
672                   <span class="blue">Max = 8.14&#949; (Mean = 1.76&#949;)</span>
673                 </p>
674               </td>
675 </tr>
676 <tr>
677 <td>
678                 <p>
679                   tgamma(a, z) small values
680                 </p>
681               </td>
682 <td>
683                 <p>
684                   <span class="blue">Max = 0.753&#949; (Mean = 0.0474&#949;)</span><br>
685                   <br> (<span class="emphasis"><em>GSL 2.1:</em></span> <span class="red">Max =
686                   1.38e+10&#949; (Mean = 1.05e+09&#949;))</span>
687                 </p>
688               </td>
689 <td>
690                 <p>
691                   <span class="blue">Max = 2.31&#949; (Mean = 0.775&#949;)</span>
692                 </p>
693               </td>
694 <td>
695                 <p>
696                   <span class="blue">Max = 2.13&#949; (Mean = 0.717&#949;)</span>
697                 </p>
698               </td>
699 <td>
700                 <p>
701                   <span class="blue">Max = 2.53&#949; (Mean = 0.66&#949;)</span>
702                 </p>
703               </td>
704 </tr>
705 <tr>
706 <td>
707                 <p>
708                   tgamma(a, z) integer and half integer values
709                 </p>
710               </td>
711 <td>
712                 <p>
713                   <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
714                   2.1:</em></span> Max = 117&#949; (Mean = 12.5&#949;))
715                 </p>
716               </td>
717 <td>
718                 <p>
719                   <span class="blue">Max = 5.52&#949; (Mean = 1.48&#949;)</span>
720                 </p>
721               </td>
722 <td>
723                 <p>
724                   <span class="blue">Max = 79.6&#949; (Mean = 20.9&#949;)</span>
725                 </p>
726               </td>
727 <td>
728                 <p>
729                   <span class="blue">Max = 5.16&#949; (Mean = 1.33&#949;)</span>
730                 </p>
731               </td>
732 </tr>
733 </tbody>
734 </table></div>
735 </div>
736 <br class="table-break"><h5>
737 <a name="math_toolkit.sf_gamma.igamma.h3"></a>
738         <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>
739       </h5>
740 <p>
741         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>
742         with this implementation to perform a basic "sanity check". Accuracy
743         tests use data generated at very high precision (using NTL's RR class set
744         at 1000-bit precision) using this implementation with a very high precision
745         60-term <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos approximation</a>,
746         and some but not all of the special case handling disabled. This is less
747         than satisfactory: an independent method should really be used, but apparently
748         a complete lack of such methods are available. We can't even use a deliberately
749         naive implementation without special case handling since Legendre's continued
750         fraction (see below) is unstable for small a and z.
751       </p>
752 <h5>
753 <a name="math_toolkit.sf_gamma.igamma.h4"></a>
754         <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>
755       </h5>
756 <p>
757         These four functions share a common implementation since they are all related
758         via:
759       </p>
760 <p>
761         1)
762       </p>
763 <div class="blockquote"><blockquote class="blockquote"><p>
764           <span class="inlinemediaobject"><img src="../../../equations/igamma5.svg"></span>
765
766         </p></blockquote></div>
767 <p>
768         2)
769       </p>
770 <div class="blockquote"><blockquote class="blockquote"><p>
771           <span class="inlinemediaobject"><img src="../../../equations/igamma6.svg"></span>
772
773         </p></blockquote></div>
774 <p>
775         3)
776       </p>
777 <div class="blockquote"><blockquote class="blockquote"><p>
778           <span class="inlinemediaobject"><img src="../../../equations/igamma7.svg"></span>
779
780         </p></blockquote></div>
781 <p>
782         The lower incomplete gamma is computed from its series representation:
783       </p>
784 <p>
785         4)
786       </p>
787 <div class="blockquote"><blockquote class="blockquote"><p>
788           <span class="inlinemediaobject"><img src="../../../equations/igamma8.svg"></span>
789
790         </p></blockquote></div>
791 <p>
792         Or by subtraction of the upper integral from either &#915;(a) or 1 when <span class="emphasis"><em>x
793         - (1</em></span>(3x)) &gt; a and x &gt; 1.1/.
794       </p>
795 <p>
796         The upper integral is computed from Legendre's continued fraction representation:
797       </p>
798 <p>
799         5)
800       </p>
801 <div class="blockquote"><blockquote class="blockquote"><p>
802           <span class="inlinemediaobject"><img src="../../../equations/igamma9.svg"></span>
803
804         </p></blockquote></div>
805 <p>
806         When <span class="emphasis"><em>(x &gt; 1.1)</em></span> or by subtraction of the lower integral
807         from either &#915;(a) or 1 when <span class="emphasis"><em>x - (1</em></span>(3x)) &lt; a/.
808       </p>
809 <p>
810         For <span class="emphasis"><em>x &lt; 1.1</em></span> computation of the upper integral is
811         more complex as the continued fraction representation is unstable in this
812         area. However there is another series representation for the lower integral:
813       </p>
814 <p>
815         6)
816       </p>
817 <div class="blockquote"><blockquote class="blockquote"><p>
818           <span class="inlinemediaobject"><img src="../../../equations/igamma10.svg"></span>
819
820         </p></blockquote></div>
821 <p>
822         That lends itself to calculation of the upper integral via rearrangement
823         to:
824       </p>
825 <p>
826         7)
827       </p>
828 <div class="blockquote"><blockquote class="blockquote"><p>
829           <span class="inlinemediaobject"><img src="../../../equations/igamma11.svg"></span>
830
831         </p></blockquote></div>
832 <p>
833         Refer to the documentation for <a class="link" href="../powers/powm1.html" title="powm1">powm1</a>
834         and <a class="link" href="tgamma.html" title="Gamma">tgamma1pm1</a> for details
835         of their implementation.
836       </p>
837 <p>
838         For <span class="emphasis"><em>x &lt; 1.1</em></span> the crossover point where the result
839         is ~0.5 no longer occurs for <span class="emphasis"><em>x ~ y</em></span>. Using <span class="emphasis"><em>x
840         * 0.75 &lt; a</em></span> as the crossover criterion for <span class="emphasis"><em>0.5 &lt;
841         x &lt;= 1.1</em></span> keeps the maximum value computed (whether it's the
842         upper or lower interval) to around 0.75. Likewise for <span class="emphasis"><em>x &lt;= 0.5</em></span>
843         then using <span class="emphasis"><em>-0.4 / log(x) &lt; a</em></span> as the crossover criterion
844         keeps the maximum value computed to around 0.7 (whether it's the upper or
845         lower interval).
846       </p>
847 <p>
848         There are two special cases used when a is an integer or half integer, and
849         the crossover conditions listed above indicate that we should compute the
850         upper integral Q. If a is an integer in the range <span class="emphasis"><em>1 &lt;= a &lt;
851         30</em></span> then the following finite sum is used:
852       </p>
853 <p>
854         9)
855       </p>
856 <div class="blockquote"><blockquote class="blockquote"><p>
857           <span class="inlinemediaobject"><img src="../../../equations/igamma1f.svg"></span>
858
859         </p></blockquote></div>
860 <p>
861         While for half-integers in the range <span class="emphasis"><em>0.5 &lt;= a &lt; 30</em></span>
862         then the following finite sum is used:
863       </p>
864 <p>
865         10)
866       </p>
867 <div class="blockquote"><blockquote class="blockquote"><p>
868           <span class="inlinemediaobject"><img src="../../../equations/igamma2f.svg"></span>
869
870         </p></blockquote></div>
871 <p>
872         These are both more stable and more efficient than the continued fraction
873         alternative.
874       </p>
875 <p>
876         When the argument <span class="emphasis"><em>a</em></span> is large, and <span class="emphasis"><em>x ~ a</em></span>
877         then the series (4) and continued fraction (5) above are very slow to converge.
878         In this area an expansion due to Temme is used:
879       </p>
880 <p>
881         11)
882       </p>
883 <div class="blockquote"><blockquote class="blockquote"><p>
884           <span class="inlinemediaobject"><img src="../../../equations/igamma16.svg"></span>
885
886         </p></blockquote></div>
887 <p>
888         12)
889       </p>
890 <div class="blockquote"><blockquote class="blockquote"><p>
891           <span class="inlinemediaobject"><img src="../../../equations/igamma17.svg"></span>
892
893         </p></blockquote></div>
894 <p>
895         13)
896       </p>
897 <div class="blockquote"><blockquote class="blockquote"><p>
898           <span class="inlinemediaobject"><img src="../../../equations/igamma18.svg"></span>
899
900         </p></blockquote></div>
901 <p>
902         14)
903       </p>
904 <div class="blockquote"><blockquote class="blockquote"><p>
905           <span class="inlinemediaobject"><img src="../../../equations/igamma19.svg"></span>
906
907         </p></blockquote></div>
908 <p>
909         The double sum is truncated to a fixed number of terms - to give a specific
910         target precision - and evaluated as a polynomial-of-polynomials. There are
911         versions for up to 128-bit long double precision: types requiring greater
912         precision than that do not use these expansions. The coefficients C<sub>k</sub><sup>n</sup> are
913         computed in advance using the recurrence relations given by Temme. The zone
914         where these expansions are used is
915       </p>
916 <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>
917 </pre>
918 <p>
919         And:
920       </p>
921 <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>
922 </pre>
923 <p>
924         The latter range is valid for all types up to 128-bit long doubles, and is
925         designed to ensure that the result is larger than 10<sup>-6</sup>, the first range is
926         used only for types up to 80-bit long doubles. These domains are narrower
927         than the ones recommended by either Temme or Didonato and Morris. However,
928         using a wider range results in large and inexact (i.e. computed) values being
929         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
930         larger error rates. In other words there is a fine trade off here between
931         efficiency and error. The current limits should keep the number of terms
932         required by (4) and (5) to no more than ~20 at double precision.
933       </p>
934 <p>
935         For the normalised incomplete gamma functions, calculation of the leading
936         power terms is central to the accuracy of the function. For smallish a and
937         x combining the power terms with the <a class="link" href="../lanczos.html" title="The Lanczos Approximation">Lanczos
938         approximation</a> gives the greatest accuracy:
939       </p>
940 <p>
941         15)
942       </p>
943 <div class="blockquote"><blockquote class="blockquote"><p>
944           <span class="inlinemediaobject"><img src="../../../equations/igamma12.svg"></span>
945
946         </p></blockquote></div>
947 <p>
948         In the event that this causes underflow/overflow then the exponent can be
949         reduced by a factor of <span class="emphasis"><em>a</em></span> and brought inside the power
950         term.
951       </p>
952 <p>
953         When a and x are large, we end up with a very large exponent with a base
954         near one: this will not be computed accurately via the pow function, and
955         taking logs simply leads to cancellation errors. The worst of the errors
956         can be avoided by using:
957       </p>
958 <p>
959         16)
960       </p>
961 <div class="blockquote"><blockquote class="blockquote"><p>
962           <span class="inlinemediaobject"><img src="../../../equations/igamma13.svg"></span>
963
964         </p></blockquote></div>
965 <p>
966         when <span class="emphasis"><em>a-x</em></span> is small and a and x are large. There is still
967         a subtraction and therefore some cancellation errors - but the terms are
968         small so the absolute error will be small - and it is absolute rather than
969         relative error that counts in the argument to the <span class="emphasis"><em>exp</em></span>
970         function. Note that for sufficiently large a and x the errors will still
971         get you eventually, although this does delay the inevitable much longer than
972         other methods. Use of <span class="emphasis"><em>log(1+x)-x</em></span> here is inspired by
973         Temme (see references below).
974       </p>
975 <h5>
976 <a name="math_toolkit.sf_gamma.igamma.h5"></a>
977         <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>
978       </h5>
979 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
980 <li class="listitem">
981             N. M. Temme, A Set of Algorithms for the Incomplete Gamma Functions,
982             Probability in the Engineering and Informational Sciences, 8, 1994.
983           </li>
984 <li class="listitem">
985             N. M. Temme, The Asymptotic Expansion of the Incomplete Gamma Functions,
986             Siam J. Math Anal. Vol 10 No 4, July 1979, p757.
987           </li>
988 <li class="listitem">
989             A. R. Didonato and A. H. Morris, Computation of the Incomplete Gamma
990             Function Ratios and their Inverse. ACM TOMS, Vol 12, No 4, Dec 1986,
991             p377.
992           </li>
993 <li class="listitem">
994             W. Gautschi, The Incomplete Gamma Functions Since Tricomi, In Tricomi's
995             Ideas and Contemporary Applied Mathematics, Atti dei Convegni Lincei,
996             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>
997           </li>
998 </ul></div>
999 </div>
1000 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
1001 <td align="left"></td>
1002 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
1003       Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
1004       Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
1005       R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
1006       Daryle Walker and Xiaogang Zhang<p>
1007         Distributed under the Boost Software License, Version 1.0. (See accompanying
1008         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>)
1009       </p>
1010 </div></td>
1011 </tr></table>
1012 <hr>
1013 <div class="spirit-nav">
1014 <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>
1015 </div>
1016 </body>
1017 </html>