]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/doc/sf/beta.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / sf / beta.qbk
CommitLineData
7c673cae
FG
1[section:beta_function Beta]
2
3[h4 Synopsis]
4
5``
6#include <boost/math/special_functions/beta.hpp>
7``
8
9 namespace boost{ namespace math{
10
11 template <class T1, class T2>
12 ``__sf_result`` beta(T1 a, T2 b);
13
14 template <class T1, class T2, class ``__Policy``>
15 ``__sf_result`` beta(T1 a, T2 b, const ``__Policy``&);
16
17 }} // namespaces
18
19[h4 Description]
20
21The beta function is defined by:
22
23[equation beta1]
24
25[graph beta]
26
27[optional_policy]
28
29There are effectively two versions of this function internally: a fully
30generic version that is slow, but reasonably accurate, and a much more
31efficient approximation that is used where the number of digits in the significand
32of T correspond to a certain __lanczos. In practice any built-in
33floating-point type you will encounter has an appropriate __lanczos
34defined for it. It is also possible, given enough machine time, to generate
35further __lanczos's using the program libs/math/tools/lanczos_generator.cpp.
36
37The return type of these functions is computed using the __arg_promotion_rules
38when T1 and T2 are different types.
39
40[h4 Accuracy]
41
42The following table shows peak errors for various domains of input arguments,
43along with comparisons to the __gsl and __cephes libraries. Note that
44only results for the widest floating point type on the system are given as
45narrower types have __zero_error.
46
47[table_beta]
48
49Note that the worst errors occur when a or b are large, and that
50when this is the case the result is very close to zero, so absolute
51errors will be very small.
52
53[h4 Testing]
54
55A mixture of spot tests of exact values, and randomly generated test data are
56used: the test data was computed using
57[@http://shoup.net/ntl/doc/RR.txt NTL::RR] at 1000-bit precision.
58
59[h4 Implementation]
60
61Traditional methods of evaluating the beta function either involve evaluating
62the gamma functions directly, or taking logarithms and then
63exponentiating the result. However, the former is prone to overflows
64for even very modest arguments, while the latter is prone to cancellation
65errors. As an alternative, if we regard the gamma function as a white-box
66containing the __lanczos, then we can combine the power terms:
67
68[equation beta2]
69
70which is almost the ideal solution, however almost all of the error occurs
71in evaluating the power terms when /a/ or /b/ are large. If we assume that /a > b/
72then the larger of the two power terms can be reduced by a factor of /b/, which
73immediately cuts the maximum error in half:
74
75[equation beta3]
76
77This may not be the final solution, but it is very competitive compared to
78other implementation methods.
79
80The generic implementation - where no __lanczos approximation is available - is
81implemented in a very similar way to the generic version of the gamma function.
82Again in order to avoid numerical overflow the power terms that prefix the series and
83continued fraction parts are collected together into:
84
85[equation beta8]
86
87where la, lb and lc are the integration limits used for a, b, and a+b.
88
89There are a few special cases worth mentioning:
90
91When /a/ or /b/ are less than one, we can use the recurrence relations:
92
93[equation beta4]
94
95[equation beta5]
96
97to move to a more favorable region where they are both greater than 1.
98
99In addition:
100
101[equation beta7]
102
103[endsect][/section:beta_function The Beta Function]
104[/
105 Copyright 2006 John Maddock and Paul A. Bristow.
106 Distributed under the Boost Software License, Version 1.0.
107 (See accompanying file LICENSE_1_0.txt or copy at
108 http://www.boost.org/LICENSE_1_0.txt).
109]
110