1 /* Copyright (C) 2011, 2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 1.Reduced x to positive by atanh(-x) = -atanh(x)
25 atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
29 atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
32 atanh(x) is NaN if |x| > 1 with signal;
33 atanh(NaN) is that NaN with no signal;
34 atanh(+-1) is +-INF with signal.
40 #include "math_private.h"
42 static const float huge
= 1e30
;
45 __ieee754_atanhf (float x
)
49 if (isless (xa
, 0.5f
))
51 if (__builtin_expect (xa
< 0x1.0p
-28f
, 0))
53 math_force_eval (huge
+ x
);
58 t
= 0.5f
* __log1pf (t
+ t
* xa
/ (1.0f
- xa
));
60 else if (__builtin_expect (isless (xa
, 1.0f
), 1))
61 t
= 0.5f
* __log1pf ((xa
+ xa
) / (1.0f
- xa
));
64 if (isgreater (xa
, 1.0f
))
65 return (x
- x
) / (x
- x
);
70 return __copysignf (t
, x
);
72 strong_alias (__ieee754_atanhf
, __atanhf_finite
)