2 /* @(#)e_sinh.c 1.3 95/01/18 */
3 /* $FreeBSD: head/lib/msun/src/e_sinh.c 226598 2011-10-21 06:28:47Z das $ */
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunSoft, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
17 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
18 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
21 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
24 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
25 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
26 * ln2ovft < x : sinh(x) := x*shuge (overflow)
29 * sinh(x) is |x| if x is +INF, -INF, or NaN.
30 * only sinh(0)=0 is exact for finite x.
34 #include "math_private.h"
36 static const double one = 1.0, shuge = 1.0e307;
39 __ieee754_sinh(double x)
44 /* High word of |x|. */
49 if(ix>=0x7ff00000) return x+x;
53 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
54 if (ix < 0x40360000) { /* |x|<22 */
55 if (ix<0x3e300000) /* |x|<2**-28 */
56 if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
58 if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
59 return h*(t+t/(t+one));
62 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
63 if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
65 /* |x| in [log(maxdouble), overflowthresold] */
67 return h*2.0*__ldexp_exp(fabs(x), -1);
69 /* |x| > overflowthresold, sinh(x) overflow */