]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/dbl-64/e_atanh.c
Remove "Contributed by" lines
[thirdparty/glibc.git] / sysdeps / ieee754 / dbl-64 / e_atanh.c
CommitLineData
2b778ceb 1/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
0ac5ae23 2 This file is part of the GNU C Library.
0ac5ae23
UD
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
f7eac6eb 17
f7eac6eb
RM
18
19/* __ieee754_atanh(x)
0ac5ae23
UD
20 Method :
21 1.Reduced x to positive by atanh(-x) = -atanh(x)
22 2.For x>=0.5
23 1 2x x
24 atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
25 2 1 - x 1 - x
26
27 For x<0.5
28 atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
29
30 Special cases:
31 atanh(x) is NaN if |x| > 1 with signal;
32 atanh(NaN) is that NaN with no signal;
33 atanh(+-1) is +-INF with signal.
34
f7eac6eb
RM
35 */
36
8020a808 37#include <float.h>
0ac5ae23 38#include <inttypes.h>
1ed0291c 39#include <math.h>
b4d5b8b0 40#include <math-barriers.h>
1ed0291c 41#include <math_private.h>
8f5b00d3 42#include <math-underflow.h>
220622dd 43#include <libm-alias-finite.h>
f7eac6eb 44
0ac5ae23 45static const double huge = 1e300;
f7eac6eb 46
0ac5ae23
UD
47double
48__ieee754_atanh (double x)
f7eac6eb 49{
0ac5ae23
UD
50 double xa = fabs (x);
51 double t;
92221550 52 if (isless (xa, 0.5))
0ac5ae23 53 {
a1ffb40e 54 if (__glibc_unlikely (xa < 0x1.0p-28))
d7826aa1
UD
55 {
56 math_force_eval (huge + x);
d96164c3 57 math_check_force_underflow (x);
d7826aa1
UD
58 return x;
59 }
0ac5ae23
UD
60
61 t = xa + xa;
62 t = 0.5 * __log1p (t + t * xa / (1.0 - xa));
63 }
a1ffb40e 64 else if (__glibc_likely (isless (xa, 1.0)))
0ac5ae23
UD
65 t = 0.5 * __log1p ((xa + xa) / (1.0 - xa));
66 else
67 {
92221550 68 if (isgreater (xa, 1.0))
0ac5ae23
UD
69 return (x - x) / (x - x);
70
71 return x / 0.0;
72 }
73
81dca813 74 return copysign (t, x);
f7eac6eb 75}
220622dd 76libm_alias_finite (__ieee754_atanh, __atanh)