1 /* @(#)e_sinh.c 5.1 93/09/24 */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, 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 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
16 * Permission to use, copy, modify, and distribute this software for any
17 * purpose with or without fee is hereby granted, provided that the above
18 * copyright notice and this permission notice appear in all copies.
20 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
21 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
23 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
32 * 1. Replace x by |x| (sinhl(-x) = -sinhl(x)).
35 * 0 <= x <= 25 : sinhl(x) := --------------, E=expm1l(x)
38 * 25 <= x <= lnovft : sinhl(x) := expl(x)/2
39 * lnovft <= x <= ln2ovft: sinhl(x) := expl(x/2)/2 * expl(x/2)
40 * ln2ovft < x : sinhl(x) := x*shuge (overflow)
43 * sinhl(x) is |x| if x is +INF, -INF, or NaN.
44 * only sinhl(0)=0 is exact for finite x.
47 #include <openlibm_math.h>
49 #include "math_private.h"
51 static const long double one
= 1.0, shuge
= 1.0e4931L
,
52 ovf_thresh
= 1.1357216553474703894801348310092223067821E4L
;
59 ieee_quad_shape_type u
;
74 /* Absolute value of x. */
77 /* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */
80 if (ix
< 0x3fc60000) /* |x| < 2^-57 */
82 return x
; /* sinh(tiny) = tiny with inexact */
85 return h
* (2.0 * t
- t
* t
/ (t
+ one
));
86 return h
* (t
+ t
/ (t
+ one
));
89 /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */
90 if (ix
<= 0x400c62e3) /* 11356.375 */
91 return h
* expl (u
.value
);
93 /* |x| in [log(maxdouble), overflowthreshold]
94 Overflow threshold is log(2 * maxdouble). */
95 if (u
.value
<= ovf_thresh
)
97 w
= expl (0.5 * u
.value
);
102 /* |x| > overflowthreshold, sinhl(x) overflow */