summaryrefslogtreecommitdiff
path: root/ext/POSIX/POSIX.xs
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-09-02 22:17:50 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-09-02 22:31:19 -0400
commitaed13ba6ad26e9b0202672c78a56fd2d9cc4f40a (patch)
tree86896d96efc534c7b50d871b7da9112888142290 /ext/POSIX/POSIX.xs
parentd6dc3af93837d7218933cafbcfed04c1e6ed4e7e (diff)
downloadperl-aed13ba6ad26e9b0202672c78a56fd2d9cc4f40a.tar.gz
POSIX math: Use 1.0 - erf(x) for erfc().
The newer method was only for x > 0.
Diffstat (limited to 'ext/POSIX/POSIX.xs')
-rw-r--r--ext/POSIX/POSIX.xs6
1 files changed, 2 insertions, 4 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 24bd07e8d2..38fdc623e0 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -502,12 +502,10 @@ static NV my_erf(NV x)
# define c99_erf my_erf
#endif
-/* While in theory erfc(x) is just 1-erf(x), thanks to numerical stability
- * things are not so easy. */
#ifndef c99_erfc
static NV my_erfc(NV x) {
- /* Chiani, Dardari & Simon (2003), via Wikipedia */
- return Perl_exp(-x*x) / 6.0 + Perl_exp(-4.0/3.0 * x*x) / 2.0;
+ /* This is not necessarily numerically stable, but better than nothing. */
+ return 1.0 - c99_erf(x);
}
# define c99_erfc my_erfc
#endif