]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/flt-32/e_atanhf.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / ieee754 / flt-32 / e_atanhf.c
CommitLineData
04277e02 1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
0ac5ae23
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
f7eac6eb 4
0ac5ae23
UD
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.
9
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.
14
15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
0ac5ae23
UD
18
19
20/* __ieee754_atanh(x)
21 Method :
22 1.Reduced x to positive by atanh(-x) = -atanh(x)
23 2.For x>=0.5
24 1 2x x
25 atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
26 2 1 - x 1 - x
27
28 For x<0.5
29 atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
f7eac6eb 30
0ac5ae23
UD
31 Special cases:
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.
f7eac6eb 35
0ac5ae23
UD
36 */
37
8020a808 38#include <float.h>
0ac5ae23 39#include <inttypes.h>
1ed0291c 40#include <math.h>
b4d5b8b0 41#include <math-barriers.h>
1ed0291c 42#include <math_private.h>
8f5b00d3 43#include <math-underflow.h>
f7eac6eb 44
0ac5ae23
UD
45static const float huge = 1e30;
46
47float
48__ieee754_atanhf (float x)
f7eac6eb 49{
0ac5ae23
UD
50 float xa = fabsf (x);
51 float t;
92221550 52 if (isless (xa, 0.5f))
0ac5ae23 53 {
a1ffb40e 54 if (__glibc_unlikely (xa < 0x1.0p-28f))
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.5f * __log1pf (t + t * xa / (1.0f - xa));
63 }
a1ffb40e 64 else if (__glibc_likely (isless (xa, 1.0f)))
0ac5ae23
UD
65 t = 0.5f * __log1pf ((xa + xa) / (1.0f - xa));
66 else
67 {
92221550 68 if (isgreater (xa, 1.0f))
0ac5ae23
UD
69 return (x - x) / (x - x);
70
71 return x / 0.0f;
72 }
73
81dca813 74 return copysignf (t, x);
f7eac6eb 75}
0ac5ae23 76strong_alias (__ieee754_atanhf, __atanhf_finite)