2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
15 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
16 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
19 * 0 <= x <= 40 : sinh(x) := --------------, E=expm1(x)
22 * 40 <= x <= lnovft : sinh(x) := exp(x)/2
23 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
24 * ln2ovft < x : sinh(x) := x*shuge (overflow)
27 * sinh(x) is |x| if x is +INF, -INF, or NaN.
28 * only sinh(0)=0 is exact for finite x.
32 #include <math_private.h>
34 static const long double one
= 1.0, shuge
= 1.0e307
;
37 __ieee754_sinhl(long double x
)
43 /* High word of |x|. */
45 EXTRACT_WORDS64 (jx
, xhi
);
46 ix
= jx
&0x7fffffffffffffffLL
;
49 if(ix
>=0x7ff0000000000000LL
) return x
+x
;
53 /* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */
54 if (ix
< 0x4044000000000000LL
) { /* |x|<40 */
55 if (ix
<0x3e20000000000000LL
) /* |x|<2**-29 */
56 if(shuge
+x
>one
) return x
;/* sinhl(tiny) = tiny with inexact */
57 t
= __expm1l(fabsl(x
));
58 if(ix
<0x3ff0000000000000LL
) return h
*(2.0*t
-t
*t
/(t
+one
));
63 /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */
64 if (ix
< 0x40862e42fefa39efLL
) return h
*__ieee754_expl(fabsl(x
));
66 /* |x| in [log(maxdouble), overflowthresold] */
67 if (ix
<= 0x408633ce8fb9f87dLL
) {
68 w
= __ieee754_expl(0.5*fabsl(x
));
73 /* |x| > overflowthresold, sinh(x) overflow */
76 strong_alias (__ieee754_sinhl
, __sinhl_finite
)