1 /* origin: FreeBSD /usr/src/lib/msun/src/e_sinh.c */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunSoft, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
14 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
15 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
18 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
21 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
22 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
23 * ln2ovft < x : sinh(x) := x*shuge (overflow)
26 * sinh(x) is |x| if x is +INF, -INF, or NaN.
27 * only sinh(0)=0 is exact for finite x.
32 static const double huge = 1.0e307;
39 /* High word of |x|. */
49 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
50 if (ix < 0x40360000) { /* |x|<22 */
51 if (ix < 0x3e300000) /* |x|<2**-28 */
52 /* raise inexact, return x */
57 return h*(2.0*t - t*t/(t+1.0));
58 return h*(t + t/(t+1.0));
61 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
63 return h*exp(fabs(x));
65 /* |x| in [log(maxdouble), overflowthresold] */
67 return h * 2.0 * __expo2(fabs(x)); /* h is for sign only */
69 /* |x| > overflowthresold, sinh(x) overflow */