From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- .../html/math_toolkit/sf_erf/error_function.html | 492 +++++++++++++++++++++ .../doc/html/math_toolkit/sf_erf/error_inv.html | 351 +++++++++++++++ 2 files changed, 843 insertions(+) create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_erf/error_function.html create mode 100644 boost/libs/math/doc/html/math_toolkit/sf_erf/error_inv.html (limited to 'boost/libs/math/doc/html/math_toolkit/sf_erf') diff --git a/boost/libs/math/doc/html/math_toolkit/sf_erf/error_function.html b/boost/libs/math/doc/html/math_toolkit/sf_erf/error_function.html new file mode 100644 index 00000000..70aba98c --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_erf/error_function.html @@ -0,0 +1,492 @@ + + + +Error Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/erf.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type erf(T z);
+
+template <class T, class Policy>
+calculated-result-type erf(T z, const Policy&);
+
+template <class T>
+calculated-result-type erfc(T z);
+
+template <class T, class Policy>
+calculated-result-type erfc(T z, const Policy&);
+
+}} // namespaces
+
+

+ The return type of these functions is computed using the result + type calculation rules: the return type is double if T is an integer type, and T otherwise. +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+
+ + Description +
+
template <class T>
+calculated-result-type erf(T z);
+
+template <class T, class Policy>
+calculated-result-type erf(T z, const Policy&);
+
+

+ Returns the error + function erf + of z: +

+

+ +

+

+ +

+
template <class T>
+calculated-result-type erfc(T z);
+
+template <class T, class Policy>
+calculated-result-type erfc(T z, const Policy&);
+
+

+ Returns the complement of the error + function of z: +

+

+ +

+

+ +

+
+ + Accuracy +
+

+ The following table shows the peak errors (in units of epsilon) found on + various platforms with various floating point types, along with comparisons + to the GSL-1.9, GNU C Lib, HP-UX + C Library and Cephes + libraries. Unless otherwise specified any floating point type that is narrower + than the one shown will have effectively + zero error. +

+
+

Table 6.28. Error rates for erf

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Erf Function: Small Values +

+
+

+ Max = 0.996ε (Mean = 0.182ε)

+ (<math.h>: Max = 1.57ε (Mean = 0.317ε)) +

+
+

+ Max = 0.925ε (Mean = 0.193ε)

+ (<tr1/cmath>: Max = 0.944ε (Mean = 0.191ε))
+ (<math.h>: Max = 0.944ε (Mean = 0.191ε)) +

+
+

+ Max = 0.841ε (Mean = 0.0687ε)
+
(GSL 1.16: Max = 2.06ε (Mean = 0.319ε))
+ (Cephes: Max = 1.13ε (Mean = 0.442ε)) +

+
+

+ Max = 0.925ε (Mean = 0.193ε)

+ (<math.h>: Max = 0.944ε (Mean = 0.194ε)) +

+
+

+ Erf Function: Medium Values +

+
+

+ Max = 1ε (Mean = 0.169ε)

+ (<math.h>: Max = 1.19ε (Mean = 0.244ε)) +

+
+

+ Max = 1.5ε (Mean = 0.193ε)

+ (<tr1/cmath>: Max = 0.921ε (Mean = 0.0723ε))
+ (<math.h>: Max = 0.921ε (Mean = 0.0723ε)) +

+
+

+ Max = 1ε (Mean = 0.119ε)

+ (GSL 1.16: Max = 2.31ε (Mean = 0.368ε))
+ (Cephes: Max = 1.34ε (Mean = 0.279ε)) +

+
+

+ Max = 1.5ε (Mean = 0.202ε)

+ (<math.h>: Max = 0.921ε (Mean = 0.071ε)) +

+
+

+ Erf Function: Large Values +

+
+

+ Max = 0ε (Mean = 0ε)

(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(<tr1/cmath>: + Max = 0ε (Mean = 0ε))
(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(GSL + 1.16: Max = 0ε (Mean = 0ε))
(Cephes: + Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+
+
+

Table 6.29. Error rates for erfc

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Erf Function: Small Values +

+
+

+ Max = 0ε (Mean = 0ε)

(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(<tr1/cmath>: + Max = 0ε (Mean = 0ε))
(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+

+ Max = 0.658ε (Mean = 0.0537ε)
+
(GSL 1.16: Max = 1.01ε (Mean = 0.485ε))
+ (Cephes: Max = 0.786ε (Mean = 0.0642ε)) +

+
+

+ Max = 0ε (Mean = 0ε)

(<math.h>: + Max = 0ε (Mean = 0ε)) +

+
+

+ Erf Function: Medium Values +

+
+

+ Max = 1.65ε (Mean = 0.373ε)

+ (<math.h>: Max = 2.36ε (Mean = 0.539ε)) +

+
+

+ Max = 1.76ε (Mean = 0.365ε)

+ (<tr1/cmath>: Max = 1.35ε (Mean = 0.307ε))
+ (<math.h>: Max = 1.35ε (Mean = 0.307ε)) +

+
+

+ Max = 0.983ε (Mean = 0.213ε)

+ (GSL 1.16: Max = 2.64ε (Mean = 0.662ε))
+ (Cephes: Max = 3.59ε (Mean = 0.779ε)) +

+
+

+ Max = 1.76ε (Mean = 0.383ε)

+ (<math.h>: Max = 2.81ε (Mean = 0.739ε)) +

+
+

+ Erf Function: Large Values +

+
+

+ Max = 1.14ε (Mean = 0.248ε)

+ (<math.h>: Max = 1.84ε (Mean = 0.331ε)) +

+
+

+ Max = 1.57ε (Mean = 0.542ε)

+ (<tr1/cmath>: Max = 1.26ε (Mean = 0.441ε))
+ (<math.h>: Max = 1.26ε (Mean = 0.441ε)) +

+
+

+ Max = 0.868ε (Mean = 0.147ε)

+ (GSL 1.16: Max = 3.9ε (Mean = 0.472ε))
+ (Cephes: Max = 2.74ε (Mean = 0.413ε)) +

+
+

+ Max = 1.57ε (Mean = 0.564ε)

+ (<math.h>: Max = 4.91ε (Mean = 1.54ε)) +

+
+
+
+ + Testing +
+

+ The tests for these functions come in two parts: basic sanity checks use + spot values calculated using Mathworld's + online evaluator, while accuracy checks use high-precision test values + calculated at 1000-bit precision with NTL::RR + and this implementation. Note that the generic and type-specific versions + of these functions use differing implementations internally, so this gives + us reasonably independent test data. Using our test data to test other "known + good" implementations also provides an additional sanity check. +

+
+ + Implementation +
+

+ All versions of these functions first use the usual reflection formulas to + make their arguments positive: +

+
erf(-z) = 1 - erf(z);
+
+erfc(-z) = 2 - erfc(z);  // preferred when -z < -0.5
+
+erfc(-z) = 1 + erf(z);   // preferred when -0.5 <= -z < 0
+
+

+ The generic versions of these functions are implemented in terms of the incomplete + gamma function. +

+

+ When the significand (mantissa) size is recognised (currently for 53, 64 + and 113-bit reals, plus single-precision 24-bit handled via promotion to + double) then a series of rational approximations devised + by JM are used. +

+

+ For z <= + 0.5 then a rational approximation to + erf is used, based on the observation that erf is an odd function and therefore + erf is calculated using: +

+
erf(z) = z * (C + R(z*z));
+
+

+ where the rational approximation R(z*z) is optimised for absolute error: + as long as its absolute error is small enough compared to the constant C, + then any round-off error incurred during the computation of R(z*z) will effectively + disappear from the result. As a result the error for erf and erfc in this + region is very low: the last bit is incorrect in only a very small number + of cases. +

+

+ For z > + 0.5 we observe that over a small interval + [a, b) then: +

+
erfc(z) * exp(z*z) * z ~ c
+
+

+ for some constant c. +

+

+ Therefore for z > + 0.5 we calculate erfc using: +

+
erfc(z) = exp(-z*z) * (C + R(z - B)) / z;
+
+

+ Again R(z - B) is optimised for absolute error, and the constant C is the average of erfc(z) + * exp(z*z) * + z taken at the endpoints of the + range. Once again, as long as the absolute error in R(z - B) is small compared + to c then c + + R(z - + B) + will be correctly rounded, and the error in the result will depend only on + the accuracy of the exp function. In practice, in all but a very small number + of cases, the error is confined to the last bit of the result. The constant + B is chosen so that the left + hand end of the range of the rational approximation is 0. +

+

+ For large z over a range + [a, +∞] the above approximation is modified to: +

+
erfc(z) = exp(-z*z) * (C + R(1 / z)) / z;
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost/libs/math/doc/html/math_toolkit/sf_erf/error_inv.html b/boost/libs/math/doc/html/math_toolkit/sf_erf/error_inv.html new file mode 100644 index 00000000..3d805824 --- /dev/null +++ b/boost/libs/math/doc/html/math_toolkit/sf_erf/error_inv.html @@ -0,0 +1,351 @@ + + + +Error Function Inverses + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Synopsis +
+
#include <boost/math/special_functions/erf.hpp>
+
+
namespace boost{ namespace math{
+
+template <class T>
+calculated-result-type erf_inv(T p);
+
+template <class T, class Policy>
+calculated-result-type erf_inv(T p, const Policy&);
+
+template <class T>
+calculated-result-type erfc_inv(T p);
+
+template <class T, class Policy>
+calculated-result-type erfc_inv(T p, const Policy&);
+
+}} // namespaces
+
+

+ The return type of these functions is computed using the result + type calculation rules: the return type is double if T is an integer type, and T otherwise. +

+

+ The final Policy argument is optional and can + be used to control the behaviour of the function: how it handles errors, + what level of precision to use etc. Refer to the policy + documentation for more details. +

+
+ + Description +
+
template <class T>
+calculated-result-type erf_inv(T z);
+
+template <class T, class Policy>
+calculated-result-type erf_inv(T z, const Policy&);
+
+

+ Returns the inverse + error function of z, that is a value x such that: +

+
p = erf(x);
+
+

+ +

+
template <class T>
+calculated-result-type erfc_inv(T z);
+
+template <class T, class Policy>
+calculated-result-type erfc_inv(T z, const Policy&);
+
+

+ Returns the inverse of the complement of the error function of z, that is + a value x such that: +

+
p = erfc(x);
+
+

+ +

+
+ + Accuracy +
+

+ For types up to and including 80-bit long doubles the approximations used + are accurate to less than ~ 2 epsilon. For higher precision types these functions + have the same accuracy as the forward + error functions. +

+
+

Table 6.30. Error rates for erf_inv

+
+++++++ + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Inverse Erf Function +

+
+

+ Max = 1.09ε (Mean = 0.502ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0.996ε (Mean = 0.389ε) +

+
+

+ Max = 0.996ε (Mean = 0.385ε) +

+
+
+
+

Table 6.31. Error rates for erfc_inv

+
+++++++ + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ Microsoft Visual C++ version 12.0
Win32
double +

+
+

+ GNU C++ version 5.1.0
linux
double +

+
+

+ GNU C++ version 5.1.0
linux
long double +

+
+

+ Sun compiler version 0x5130
Sun Solaris
long double +

+
+

+ Inverse Erfc Function +

+
+

+ Max = 1ε (Mean = 0.491ε) +

+
+

+ Max = 0ε (Mean = 0ε) +

+
+

+ Max = 0.996ε (Mean = 0.397ε) +

+
+

+ Max = 0.996ε (Mean = 0.397ε) +

+
+

+ Inverse Erfc Function: extreme values +

+
+ + +

+ Max = 1.62ε (Mean = 0.383ε) +

+
+

+ Max = 1.62ε (Mean = 0.385ε) +

+
+
+
+ + Testing +
+

+ There are two sets of tests: +

+
    +
  • + Basic sanity checks attempt to "round-trip" from x + to p and back again. These tests have quite generous + tolerances: in general both the error functions and their inverses change + so rapidly in some places that round tripping to more than a couple of + significant digits isn't possible. This is especially true when p + is very near one: in this case there isn't enough "information content" + in the input to the inverse function to get back where you started. +
  • +
  • + Accuracy checks using high-precision test values. These measure the accuracy + of the result, given exact input values. +
  • +
+
+ + Implementation +
+

+ These functions use a rational approximation devised + by JM to calculate an initial approximation to the result that is + accurate to ~10-19, then only if that has insufficient accuracy compared + to the epsilon for T, do we clean up the result using Halley + iteration. +

+

+ Constructing rational approximations to the erf/erfc functions is actually + surprisingly hard, especially at high precision. For this reason no attempt + has been made to achieve 10-34 accuracy suitable for use with 128-bit reals. +

+

+ In the following discussion, p is the value passed to + erf_inv, and q is the value passed to erfc_inv, so that + p = 1 - q and q = 1 - p and in + both cases we want to solve for the same result x. +

+

+ For p < 0.5 the inverse erf function is reasonably + smooth and the approximation: +

+
x = p(p + 10)(Y + R(p))
+
+

+ Gives a good result for a constant Y, and R(p) optimised for low absolute + error compared to |Y|. +

+

+ For q < 0.5 things get trickier, over the interval 0.5 > + q > 0.25 the following approximation works well: +

+
x = sqrt(-2log(q)) / (Y + R(q))
+
+

+ While for q < 0.25, let +

+
z = sqrt(-log(q))
+
+

+ Then the result is given by: +

+
x = z(Y + R(z - B))
+
+

+ As before Y is a constant and the rational function R is optimised for low + absolute error compared to |Y|. B is also a constant: it is the smallest + value of z for which each approximation is valid. There + are several approximations of this form each of which reaches a little further + into the tail of the erfc function (at long + double precision the extended exponent + range compared to double means + that the tail goes on for a very long way indeed). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + -- cgit v1.2.3