sl@0: /* E_SINH.C
sl@0:  * 
sl@0:  * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
sl@0:  * All rights reserved.
sl@0:  */
sl@0: 
sl@0: 
sl@0: /* @(#)e_sinh.c 5.1 93/09/24 */
sl@0: /*
sl@0:  * ====================================================
sl@0:  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
sl@0:  *
sl@0:  * Developed at SunPro, a Sun Microsystems, Inc. business.
sl@0:  * Permission to use, copy, modify, and distribute this
sl@0:  * software is freely granted, provided that this notice 
sl@0:  * is preserved.
sl@0:  * ====================================================
sl@0:  */
sl@0: 
sl@0: /* __ieee754_sinh(x)
sl@0:  * Method : 
sl@0:  * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
sl@0:  *	1. Replace x by |x| (sinh(-x) = -sinh(x)). 
sl@0:  *	2. 
sl@0:  *		                                    E + E/(E+1)
sl@0:  *	    0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
sl@0:  *			       			        2
sl@0:  *
sl@0:  *	    22       <= x <= lnovft :  sinh(x) := exp(x)/2 
sl@0:  *	    lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
sl@0:  *	    ln2ovft  <  x	    :  sinh(x) := x*shuge (overflow)
sl@0:  *
sl@0:  * Special cases:
sl@0:  *	sinh(x) is |x| if x is +INF, -INF, or NaN.
sl@0:  *	only sinh(0)=0 is exact for finite x.
sl@0:  */
sl@0: 
sl@0: #include "FDLIBM.H"
sl@0: 
sl@0: static const double one = 1.0, shuge = 1.0e307;
sl@0: 	
sl@0: EXPORT_C double __ieee754_sinh(double x) __SOFTFP
sl@0: {	
sl@0: 	double t,w,h;
sl@0: 	__int32_t ix,jx;
sl@0: 	__uint32_t lx;
sl@0: 
sl@0:     /* High word of |x|. */
sl@0: 	GET_HIGH_WORD(jx,x);
sl@0: 	ix = jx&0x7fffffff;
sl@0: 
sl@0:     /* x is INF or NaN */
sl@0: 	if(ix>=0x7ff00000) return x+x;	
sl@0: 
sl@0: 	h = 0.5;
sl@0: 	if (jx<0) h = -h;
sl@0:     /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
sl@0: 	if (ix < 0x40360000) {		/* |x|<22 */
sl@0: 	    if (ix<0x3e300000) 		/* |x|<2**-28 */
sl@0: 		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
sl@0: 	    t = expm1(fabs(x));
sl@0: 	    if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
sl@0: 	    return h*(t+t/(t+one));
sl@0: 	}
sl@0: 
sl@0:     /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
sl@0: 	if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
sl@0: 
sl@0:     /* |x| in [log(maxdouble), overflowthresold] */
sl@0: 	GET_LOW_WORD(lx,x);
sl@0: 	if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(__uint32_t)0x8fb9f87d))) {
sl@0: 	    w = __ieee754_exp(0.5*fabs(x));
sl@0: 	    t = h*w;
sl@0: 	    return t*w;
sl@0: 	}
sl@0: 
sl@0:     /* |x| > overflowthresold, sinh(x) overflow */
sl@0: 	return x*shuge;
sl@0: }