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