Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / sf_gamma / gamma_ratios.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Ratios of Gamma Functions</title>
5 <link rel="stylesheet" href="../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../index.html" title="Math Toolkit 2.1.0">
8 <link rel="up" href="../sf_gamma.html" title="Gamma Functions">
9 <link rel="prev" href="digamma.html" title="Digamma">
10 <link rel="next" href="igamma.html" title="Incomplete Gamma Functions">
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="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="igamma.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.gamma_ratios"></a><a class="link" href="gamma_ratios.html" title="Ratios of Gamma Functions">Ratios of Gamma Functions</a>
28 </h3></div></div></div>
29 <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>
30 </pre>
31 <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>
32
33 <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>
34 <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>
35
36 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
37 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
38
39 <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>
40 <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>
41
42 <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>
43 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
44
45 <span class="special">}}</span> <span class="comment">// namespaces</span>
46 </pre>
47 <h5>
48 <a name="math_toolkit.sf_gamma.gamma_ratios.h0"></a>
49         <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>
50       </h5>
51 <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>
52 <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>
53
54 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
55 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
56 </pre>
57 <p>
58         Returns the ratio of gamma functions:
59       </p>
60 <p>
61         <span class="inlinemediaobject"><img src="../../../equations/gamma_ratio0.png"></span>
62       </p>
63 <p>
64         The final <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
65         be used to control the behaviour of the function: how it handles errors,
66         what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">policy
67         documentation for more details</a>.
68       </p>
69 <p>
70         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>
71         <span class="identifier">b</span><span class="special">-</span><span class="identifier">a</span><span class="special">)</span></code>.
72       </p>
73 <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>
74 <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>
75
76 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
77 <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;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
78 </pre>
79 <p>
80         Returns the ratio of gamma functions:
81       </p>
82 <p>
83         <span class="inlinemediaobject"><img src="../../../equations/gamma_ratio1.png"></span>
84       </p>
85 <p>
86         The final <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
87         be used to control the behaviour of the function: how it handles errors,
88         what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">policy
89         documentation for more details</a>.
90       </p>
91 <p>
92         Note that the result is calculated accurately even when <span class="emphasis"><em>delta</em></span>
93         is small compared to <span class="emphasis"><em>a</em></span>: indeed even if <span class="emphasis"><em>a+delta
94         ~ a</em></span>. The function is typically used when <span class="emphasis"><em>a</em></span>
95         is large and <span class="emphasis"><em>delta</em></span> is very small.
96       </p>
97 <p>
98         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
99         type calculation rules</em></span></a> when T1 and T2 are different types,
100         otherwise the result type is simple T1.
101       </p>
102 <p>
103         <span class="inlinemediaobject"><img src="../../../graphs/tgamma_delta_ratio.png" align="middle"></span>
104       </p>
105 <h5>
106 <a name="math_toolkit.sf_gamma.gamma_ratios.h1"></a>
107         <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>
108       </h5>
109 <p>
110         The following table shows the peak errors (in units of epsilon) found on
111         various platforms with various floating point types. Unless otherwise specified
112         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>.
113       </p>
114 <div class="table">
115 <a name="math_toolkit.sf_gamma.gamma_ratios.errors_in_the_function_tgamma_de"></a><p class="title"><b>Table&#160;6.1.&#160;Errors In the Function tgamma_delta_ratio(a, delta)</b></p>
116 <div class="table-contents"><table class="table" summary="Errors In the Function tgamma_delta_ratio(a, delta)">
117 <colgroup>
118 <col>
119 <col>
120 <col>
121 </colgroup>
122 <thead><tr>
123 <th>
124                 <p>
125                   Significand Size
126                 </p>
127               </th>
128 <th>
129                 <p>
130                   Platform and Compiler
131                 </p>
132               </th>
133 <th>
134                 <p>
135                   20 &lt; a &lt; 80
136                 </p>
137                 <p>
138                   and
139                 </p>
140                 <p>
141                   delta &lt; 1
142                 </p>
143               </th>
144 </tr></thead>
145 <tbody>
146 <tr>
147 <td>
148                 <p>
149                   53
150                 </p>
151               </td>
152 <td>
153                 <p>
154                   Win32, Visual C++ 8
155                 </p>
156               </td>
157 <td>
158                 <p>
159                   Peak=16.9 Mean=1.7
160                 </p>
161               </td>
162 </tr>
163 <tr>
164 <td>
165                 <p>
166                   64
167                 </p>
168               </td>
169 <td>
170                 <p>
171                   Redhat Linux IA32, gcc-3.4.4
172                 </p>
173               </td>
174 <td>
175                 <p>
176                   Peak=24 Mean=2.7
177                 </p>
178               </td>
179 </tr>
180 <tr>
181 <td>
182                 <p>
183                   64
184                 </p>
185               </td>
186 <td>
187                 <p>
188                   Redhat Linux IA64, gcc-3.4.4
189                 </p>
190               </td>
191 <td>
192                 <p>
193                   Peak=12.8 Mean=1.8
194                 </p>
195               </td>
196 </tr>
197 <tr>
198 <td>
199                 <p>
200                   113
201                 </p>
202               </td>
203 <td>
204                 <p>
205                   HPUX IA64, aCC A.06.06
206                 </p>
207               </td>
208 <td>
209                 <p>
210                   Peak=21.4 Mean=2.3
211                 </p>
212               </td>
213 </tr>
214 </tbody>
215 </table></div>
216 </div>
217 <br class="table-break"><div class="table">
218 <a name="math_toolkit.sf_gamma.gamma_ratios.errors_in_the_function_tgamma_ra"></a><p class="title"><b>Table&#160;6.2.&#160;Errors In the Function tgamma_ratio(a, b)</b></p>
219 <div class="table-contents"><table class="table" summary="Errors In the Function tgamma_ratio(a, b)">
220 <colgroup>
221 <col>
222 <col>
223 <col>
224 </colgroup>
225 <thead><tr>
226 <th>
227                 <p>
228                   Significand Size
229                 </p>
230               </th>
231 <th>
232                 <p>
233                   Platform and Compiler
234                 </p>
235               </th>
236 <th>
237                 <p>
238                   6 &lt; a,b &lt; 50
239                 </p>
240               </th>
241 </tr></thead>
242 <tbody>
243 <tr>
244 <td>
245                 <p>
246                   53
247                 </p>
248               </td>
249 <td>
250                 <p>
251                   Win32, Visual C++ 8
252                 </p>
253               </td>
254 <td>
255                 <p>
256                   Peak=34 Mean=9
257                 </p>
258               </td>
259 </tr>
260 <tr>
261 <td>
262                 <p>
263                   64
264                 </p>
265               </td>
266 <td>
267                 <p>
268                   Redhat Linux IA32, gcc-3.4.4
269                 </p>
270               </td>
271 <td>
272                 <p>
273                   Peak=91 Mean=23
274                 </p>
275               </td>
276 </tr>
277 <tr>
278 <td>
279                 <p>
280                   64
281                 </p>
282               </td>
283 <td>
284                 <p>
285                   Redhat Linux IA64, gcc-3.4.4
286                 </p>
287               </td>
288 <td>
289                 <p>
290                   Peak=35.6 Mean=9.3
291                 </p>
292               </td>
293 </tr>
294 <tr>
295 <td>
296                 <p>
297                   113
298                 </p>
299               </td>
300 <td>
301                 <p>
302                   HPUX IA64, aCC A.06.06
303                 </p>
304               </td>
305 <td>
306                 <p>
307                   Peak=43.9 Mean=13.2
308                 </p>
309               </td>
310 </tr>
311 </tbody>
312 </table></div>
313 </div>
314 <br class="table-break"><h5>
315 <a name="math_toolkit.sf_gamma.gamma_ratios.h2"></a>
316         <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>
317       </h5>
318 <p>
319         Accuracy tests use data generated at very high precision (with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL
320         RR class</a> set at 1000-bit precision: about 300 decimal digits) and
321         a deliberately naive calculation of &#915;(x)/&#915;(y).
322       </p>
323 <h5>
324 <a name="math_toolkit.sf_gamma.gamma_ratios.h3"></a>
325         <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>
326       </h5>
327 <p>
328         The implementation of these functions is very similar to that of <a class="link" href="../sf_beta/beta_function.html" title="Beta">beta</a>,
329         and is based on combining similar power terms to improve accuracy and avoid
330         spurious overflow/underflow.
331       </p>
332 <p>
333         In addition there are optimisations for the situation where <span class="emphasis"><em>delta</em></span>
334         is a small integer: in which case this function is basically the reciprocal
335         of a rising factorial, or where both arguments are smallish integers: in
336         which case table lookup of factorials can be used to calculate the ratio.
337       </p>
338 </div>
339 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
340 <td align="left"></td>
341 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
342       Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
343       Holin, Bruno Lalande, John Maddock, Johan R&#229;de, Gautam Sewani, Benjamin Sobotta,
344       Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
345         Distributed under the Boost Software License, Version 1.0. (See accompanying
346         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>)
347       </p>
348 </div></td>
349 </tr></table>
350 <hr>
351 <div class="spirit-nav">
352 <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="igamma.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
353 </div>
354 </body>
355 </html>