about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_expm1.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_expm1.c')
-rw-r--r--sysdeps/libm-ieee754/s_expm1.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/sysdeps/libm-ieee754/s_expm1.c b/sysdeps/libm-ieee754/s_expm1.c
index a88ec295d3..c8354b7262 100644
--- a/sysdeps/libm-ieee754/s_expm1.c
+++ b/sysdeps/libm-ieee754/s_expm1.c
@@ -5,7 +5,7 @@
  *
  * Developed at SunPro, a Sun Microsystems, Inc. business.
  * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
+ * software is freely granted, provided that this notice
  * is preserved.
  * ====================================================
  */
@@ -21,9 +21,9 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  *   1. Argument reduction:
  *	Given x, find r and integer k such that
  *
- *               x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658  
+ *               x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658
  *
- *      Here a correction term c will be computed to compensate 
+ *      Here a correction term c will be computed to compensate
  *	the error in r when rounded to a floating-point number.
  *
  *   2. Approximating expm1(r) by a special rational function on
@@ -36,9 +36,9 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  *	    R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
  *		     = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
  *		     = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
- *      We use a special Reme algorithm on [0,0.347] to generate 
- * 	a polynomial of degree 5 in r*r to approximate R1. The 
- *	maximum error of this polynomial approximation is bounded 
+ *      We use a special Reme algorithm on [0,0.347] to generate
+ * 	a polynomial of degree 5 in r*r to approximate R1. The
+ *	maximum error of this polynomial approximation is bounded
  *	by 2**-61. In other words,
  *	    R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
  *	where 	Q1  =  -1.6666666666666567384E-2,
@@ -49,28 +49,28 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  *  	(where z=r*r, and the values of Q1 to Q5 are listed below)
  *	with error bounded by
  *	    |                  5           |     -61
- *	    | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2 
+ *	    | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
  *	    |                              |
- *	
- *	expm1(r) = exp(r)-1 is then computed by the following 
- * 	specific way which minimize the accumulation rounding error: 
+ *
+ *	expm1(r) = exp(r)-1 is then computed by the following
+ * 	specific way which minimize the accumulation rounding error:
  *			       2     3
  *			      r     r    [ 3 - (R1 + R1*r/2)  ]
  *	      expm1(r) = r + --- + --- * [--------------------]
  *		              2     2    [ 6 - r*(3 - R1*r/2) ]
- *	
+ *
  *	To compensate the error in the argument reduction, we use
- *		expm1(r+c) = expm1(r) + c + expm1(r)*c 
- *			   ~ expm1(r) + c + r*c 
+ *		expm1(r+c) = expm1(r) + c + expm1(r)*c
+ *			   ~ expm1(r) + c + r*c
  *	Thus c+r*c will be added in as the correction terms for
- *	expm1(r+c). Now rearrange the term to avoid optimization 
+ *	expm1(r+c). Now rearrange the term to avoid optimization
  * 	screw up:
  *		        (      2                                    2 )
  *		        ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
  *	 expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
  *	                ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
  *                      (                                             )
- *    	
+ *
  *		   = r - E
  *   3. Scale back to obtain expm1(x):
  *	From step 1, we have
@@ -87,7 +87,7 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  *	       	       else	     return  1.0+2.0*(r-E);
  *	  (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
  *	  (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
- *	  (vii) return 2^k(1-((E+2^-k)-r)) 
+ *	  (vii) return 2^k(1-((E+2^-k)-r))
  *
  * Special cases:
  *	expm1(INF) is INF, expm1(NaN) is NaN;
@@ -99,12 +99,12 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
  *	1 ulp (unit in the last place).
  *
  * Misc. info.
- *	For IEEE double 
+ *	For IEEE double
  *	    if x >  7.09782712893383973096e+02 then expm1(x) overflow
  *
  * Constants:
- * The hexadecimal values are the intended ones for the following 
- * constants. The decimal values may be used, provided that the 
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
  * compiler will convert from decimal to binary accurately enough
  * to produce the hexadecimal values shown.
  */
@@ -153,7 +153,7 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
                 if(hx>=0x7ff00000) {
 		    u_int32_t low;
 		    GET_LOW_WORD(low,x);
-		    if(((hx&0xfffff)|low)!=0) 
+		    if(((hx&0xfffff)|low)!=0)
 		         return x+x; 	 /* NaN */
 		    else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */
 	        }
@@ -166,7 +166,7 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
 	}
 
     /* argument reduction */
-	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */ 
+	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */
 	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
 		if(xsb==0)
 		    {hi = x - ln2_hi; lo =  ln2_lo;  k =  1;}
@@ -180,10 +180,10 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
 	    }
 	    x  = hi - lo;
 	    c  = (hi-x)-lo;
-	} 
+	}
 	else if(hx < 0x3c900000) {  	/* when |x|<2**-54, return x */
 	    t = huge+x;	/* return x with inexact flags when x!=0 */
-	    return x - (t-(huge+x));	
+	    return x - (t-(huge+x));
 	}
 	else k = 0;
 
@@ -198,7 +198,7 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
 	    e  = (x*(e-c)-c);
 	    e -= hxs;
 	    if(k== -1) return 0.5*(x-e)-0.5;
-	    if(k==1) 
+	    if(k==1)
 	       	if(x < -0.25) return -2.0*(e-(x+0.5));
 	       	else 	      return  one+2.0*(x-e);
 	    if (k <= -2 || k>56) {   /* suffice to return exp(x)-1 */
@@ -227,3 +227,7 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
 	return y;
 }
 weak_alias (__expm1, expm1)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__expm1, __expm1l)
+weak_alias (__expm1, expm1l)
+#endif