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 * ====================================================
13 #if defined(LIBM_SCCS) && !defined(lint)
14 static char rcsid
[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
19 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
20 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
23 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
26 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
27 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
28 * ln2ovft < x : sinh(x) := x*shuge (overflow)
31 * sinh(x) is |x| if x is +INF, -INF, or NaN.
32 * only sinh(0)=0 is exact for finite x.
36 #include "math_private.h"
39 static const long double one
= 1.0, shuge
= 1.0e307
;
41 static long double one
= 1.0, shuge
= 1.0e307
;
45 long double __ieee754_sinhl(long double x
)
47 long double __ieee754_sinhl(x
)
54 /* High word of |x|. */
55 GET_LDOUBLE_MSW64(jx
,x
);
56 ix
= jx
&0x7fffffffffffffffLL
;
59 if(ix
>=0x7ff0000000000000LL
) return x
+x
;
63 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
64 if (ix
< 0x4036000000000000LL
) { /* |x|<22 */
65 if (ix
<0x3e20000000000000LL
) /* |x|<2**-29 */
66 if(shuge
+x
>one
) return x
;/* sinhl(tiny) = tiny with inexact */
67 t
= __expm1l(fabsl(x
));
68 if(ix
<0x3ff0000000000000LL
) return h
*(2.0*t
-t
*t
/(t
+one
));
69 return h
*(t
+t
/(t
+one
));
72 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
73 if (ix
< 0x40862e42fefa39efLL
) return h
*__ieee754_expl(fabsl(x
));
75 /* |x| in [log(maxdouble), overflowthresold] */
76 if (ix
<= 0x408633ce8fb9f87dLL
) {
77 w
= __ieee754_expl(0.5*fabsl(x
));
82 /* |x| > overflowthresold, sinh(x) overflow */