-[section:error_function Error Functions]
+[section:error_function Error Function erf and complement erfc]
[h4 Synopsis]
[h4 Accuracy]
The following table shows the peak errors (in units of epsilon)
-found on various platforms with various floating point types,
+found on various platforms with various floating-point types,
along with comparisons to the __gsl, __glibc, __hpc and __cephes libraries.
-Unless otherwise specified any floating point type that is narrower
+Unless otherwise specified any floating-point type that is narrower
than the one shown will have __zero_error.
[table_erf]
All versions of these functions first use the usual reflection formulas
to make their arguments positive:
- erf(-z) = 1 - erf(z);
+[expression ['erf(-z) = 1 - erf(z);] ]
- erfc(-z) = 2 - erfc(z); // preferred when -z < -0.5
+[expression ['erfc(-z) = 2 - erfc(z);] // preferred when -z < -0.5]
- erfc(-z) = 1 + erf(z); // preferred when -0.5 <= -z < 0
+[expression ['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.
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));
+[expression ['erf(z) = z * (C + R(z*z));]]
-where the rational approximation R(z*z) is optimised for absolute error:
+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:
+For `z > 0.5` we observe that over a small interval \[['a, b)] then:
- erfc(z) * exp(z*z) * z ~ c
+[expression ['erfc(z) * exp(z*z) * z ~ c]]
for some constant c.
-Therefore for `z > 0.5` we calculate erfc using:
+Therefore for `z > 0.5` we calculate `erfc` using:
- erfc(z) = exp(-z*z) * (C + R(z - B)) / z;
+[expression ['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.
For large `z` over a range \[a, +[infin]\] the above approximation is modified to:
- erfc(z) = exp(-z*z) * (C + R(1 / z)) / z;
+[expression ['erfc(z) = exp(-z*z) * (C + R(1 / z)) / z;]]
-[endsect]
-[/ :error_function The Error Functions]
+[endsect] [/section:error_function Error Function erf and complement erfc]
[/
Copyright 2006 John Maddock and Paul A. Bristow.