summaryrefslogtreecommitdiff
path: root/lib/libm/noieee_src/n_erf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libm/noieee_src/n_erf.c')
-rw-r--r--lib/libm/noieee_src/n_erf.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/libm/noieee_src/n_erf.c b/lib/libm/noieee_src/n_erf.c
index 38d301793a1..3281985a8d9 100644
--- a/lib/libm/noieee_src/n_erf.c
+++ b/lib/libm/noieee_src/n_erf.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: n_erf.c,v 1.5 2008/06/12 22:43:36 martynas Exp $ */
/* $NetBSD: n_erf.c,v 1.1 1995/10/10 23:36:43 ragge Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -68,13 +69,13 @@ static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93";
* erfc(x) = 1 - erf(x) if x<=0.25
* = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375]
* where
- * 2 2 4 20
+ * 2 2 4 20
* P = P(x ) = (p0 + p1 * x + p2 * x + ... + p10 * x )
* is an approximation to (erf(x)-x)/x with precision
*
* -56.45
* | P - (erf(x)-x)/x | <= 2
- *
+ *
*
* Remark. The formula is derived by noting
* erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
@@ -96,7 +97,7 @@ static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93";
* That is, we use rational approximation to approximate
* erf(1+s) - (c = (single)0.84506291151)
* Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
- * where
+ * where
* P1(s) = degree 6 poly in s
* Q1(s) = degree 6 poly in s
*
@@ -105,7 +106,7 @@ static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93";
* erfc(x) = (1/x)exp(-x*x-(.5*log(pi) -.5z + R(z)/S(z))
*
* Where z = 1/(x*x), R is degree 9, and S is degree 3;
- *
+ *
* 5. For x in [4,28]
* erf(x) = 1.0 - tiny
* erfc(x) = (1/x)exp(-x*x-(.5*log(pi)+eps + zP(z))
@@ -139,7 +140,7 @@ static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93";
*
* 7. Special cases:
* erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
- * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
+ * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
* erfc/erf(NaN) is NaN
*/
@@ -181,7 +182,7 @@ p8 = 1.640186161764254363152286358441771740838e-0006,
p9 = -1.571599331700515057841960987689515895479e-0007,
p10= 1.073087585213621540635426191486561494058e-0008;
/*
- * Coefficients for approximation to erf in [0.84375,1.25]
+ * Coefficients for approximation to erf in [0.84375,1.25]
*/
static double
pa0 = -2.362118560752659485957248365514511540287e-0003,
@@ -319,7 +320,7 @@ double erf(x)
return (z-one);
}
-double erfc(x)
+double erfc(x)
double x;
{
double R, S, P, Q, s, ax, y, z, r;
@@ -352,7 +353,7 @@ double erfc(x)
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
if (x>=0) {
- z = one-c; return z - P/Q;
+ z = one-c; return z - P/Q;
} else {
z = c+P/Q; return one+z;
}