Release 1.39.0
[boost.git] / Boost_1_39_0 / libs / math / doc / sf_and_dist / gamma_ratios.qbk
blobe7b289ba1cb169d5770140c620c9723cc26be7dc
1 [section:gamma_ratios Ratios of Gamma Functions]
3 ``
4 #include <boost/math/special_functions/gamma.hpp>
5 ``
7    namespace boost{ namespace math{
8    
9    template <class T1, class T2>
10    ``__sf_result`` tgamma_ratio(T1 a, T2 b);
11    
12    template <class T1, class T2, class ``__Policy``>
13    ``__sf_result`` tgamma_ratio(T1 a, T2 b, const ``__Policy``&);
14    
15    template <class T1, class T2>
16    ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta);
17    
18    template <class T1, class T2, class Policy>
19    ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta, const ``__Policy``&);
20    
21    }} // namespaces
22    
23 [h4 Description]
25    template <class T1, class T2> 
26    ``__sf_result`` tgamma_ratio(T1 a, T2 b);
27    
28    template <class T1, class T2, class ``__Policy``> 
29    ``__sf_result`` tgamma_ratio(T1 a, T2 b, const ``__Policy``&);
30    
31 Returns the ratio of gamma functions:
33 [equation gamma_ratio0]
35 [optional_policy]
37 Internally this just calls `tgamma_delta_ratio(a, b-a)`.
38    
39    template <class T1, class T2>
40    ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta);
41    
42    template <class T1, class T2, class ``__Policy``>
43    ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta, const ``__Policy``&);
44    
45 Returns the ratio of gamma functions:
47 [equation gamma_ratio1]
49 [optional_policy]
51 Note that the result is calculated accurately even when /delta/ is
52 small compared to /a/: indeed even if /a+delta ~ a/.  The function is
53 typically used when /a/ is large and /delta/ is very small.
55 The return type of these functions is computed using the __arg_pomotion_rules
56 when T1 and T2 are different types, otherwise the result type is simple T1.
58 [graph tgamma_delta_ratio]
60 [h4 Accuracy]
62 The following table shows the peak errors (in units of epsilon) 
63 found on various platforms with various floating point types.
64 Unless otherwise specified any floating point type that is narrower
65 than the one shown will have __zero_error.
67 [table Errors In the Function tgamma_delta_ratio(a, delta)
68 [[Significand Size] [Platform and Compiler] [20 < a < 80
70 and
72 delta < 1]]
73 [[53] [Win32, Visual C++ 8] [Peak=16.9 Mean=1.7] ]
74 [[64] [Redhat Linux IA32, gcc-3.4.4] [Peak=24 Mean=2.7]]
75 [[64] [Redhat Linux IA64, gcc-3.4.4] [Peak=12.8 Mean=1.8]]
76 [[113] [HPUX IA64, aCC A.06.06] [Peak=21.4 Mean=2.3] ]
79 [table Errors In the Function tgamma_ratio(a, b)
80 [[Significand Size] [Platform and Compiler] [6 < a,b < 50]]
81 [[53] [Win32, Visual C++ 8] [Peak=34 Mean=9] ]
82 [[64] [Redhat Linux IA32, gcc-3.4.4] [Peak=91 Mean=23]]
83 [[64] [Redhat Linux IA64, gcc-3.4.4] [Peak=35.6 Mean=9.3]]
84 [[113] [HPUX IA64, aCC A.06.06] [Peak=43.9 Mean=13.2] ]
87 [h4 Testing]
89 Accuracy tests use data generated at very high precision
90 (with [@http://shoup.net/ntl/doc/RR.txt NTL RR class]
91 set at 1000-bit precision: about 300 decimal digits)
92 and a deliberately naive calculation of [Gamma](x)/[Gamma](y).  
94 [h4 Implementation]
96 The implementation of these functions is very similar to that of 
97 __beta, and is based on combining similar power terms
98 to improve accuracy and avoid spurious overflow/underflow.
100 In addition there are optimisations for the situation where /delta/
101 is a small integer: in which case this function is basically
102 the reciprocal of a rising factorial, or where both arguments
103 are smallish integers: in which case table lookup of factorials
104 can be used to calculate the ratio.
106 [endsect][/section:gamma_ratios Ratios of Gamma Functions]
108 [/ 
109   Copyright 2006 John Maddock and Paul A. Bristow.
110   Distributed under the Boost Software License, Version 1.0.
111   (See accompanying file LICENSE_1_0.txt or copy at
112   http://www.boost.org/LICENSE_1_0.txt).