]>
Commit | Line | Data |
---|---|---|
f964490f RM |
1 | /* |
2 | * ==================================================== | |
3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | |
4 | * | |
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 | |
8 | * is preserved. | |
9 | * ==================================================== | |
10 | */ | |
11 | ||
12 | ||
f964490f RM |
13 | /* __ieee754_sinh(x) |
14 | * Method : | |
15 | * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 | |
16 | * 1. Replace x by |x| (sinh(-x) = -sinh(x)). | |
17 | * 2. | |
0ac5ae23 | 18 | * E + E/(E+1) |
f964490f | 19 | * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x) |
0ac5ae23 | 20 | * 2 |
f964490f RM |
21 | * |
22 | * 22 <= 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) | |
25 | * | |
26 | * Special cases: | |
27 | * sinh(x) is |x| if x is +INF, -INF, or NaN. | |
28 | * only sinh(0)=0 is exact for finite x. | |
29 | */ | |
30 | ||
31 | #include "math.h" | |
32 | #include "math_private.h" | |
33 | ||
f964490f | 34 | static const long double one = 1.0, shuge = 1.0e307; |
f964490f | 35 | |
0ac5ae23 UD |
36 | long double |
37 | __ieee754_sinhl(long double x) | |
f964490f RM |
38 | { |
39 | long double t,w,h; | |
40 | int64_t ix,jx; | |
41 | ||
42 | /* High word of |x|. */ | |
43 | GET_LDOUBLE_MSW64(jx,x); | |
44 | ix = jx&0x7fffffffffffffffLL; | |
45 | ||
46 | /* x is INF or NaN */ | |
47 | if(ix>=0x7ff0000000000000LL) return x+x; | |
48 | ||
49 | h = 0.5; | |
50 | if (jx<0) h = -h; | |
51 | /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ | |
52 | if (ix < 0x4036000000000000LL) { /* |x|<22 */ | |
0ac5ae23 | 53 | if (ix<0x3e20000000000000LL) /* |x|<2**-29 */ |
f964490f RM |
54 | if(shuge+x>one) return x;/* sinhl(tiny) = tiny with inexact */ |
55 | t = __expm1l(fabsl(x)); | |
56 | if(ix<0x3ff0000000000000LL) return h*(2.0*t-t*t/(t+one)); | |
57 | return h*(t+t/(t+one)); | |
58 | } | |
59 | ||
60 | /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ | |
61 | if (ix < 0x40862e42fefa39efLL) return h*__ieee754_expl(fabsl(x)); | |
62 | ||
63 | /* |x| in [log(maxdouble), overflowthresold] */ | |
64 | if (ix <= 0x408633ce8fb9f87dLL) { | |
65 | w = __ieee754_expl(0.5*fabsl(x)); | |
66 | t = h*w; | |
67 | return t*w; | |
68 | } | |
69 | ||
70 | /* |x| > overflowthresold, sinh(x) overflow */ | |
71 | return x*shuge; | |
72 | } | |
0ac5ae23 | 73 | strong_alias (__ieee754_sinhl, __sinhl_finite) |