|
Packit |
6c4009 |
/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* __ieee754_atanh(x)
|
|
Packit |
6c4009 |
Method :
|
|
Packit |
6c4009 |
1.Reduced x to positive by atanh(-x) = -atanh(x)
|
|
Packit |
6c4009 |
2.For x>=0.5
|
|
Packit |
6c4009 |
1 2x x
|
|
Packit |
6c4009 |
atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
|
|
Packit |
6c4009 |
2 1 - x 1 - x
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
For x<0.5
|
|
Packit |
6c4009 |
atanh(x) = 0.5*log1p(2x+2x*x/(1-x))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Special cases:
|
|
Packit |
6c4009 |
atanh(x) is NaN if |x| > 1 with signal;
|
|
Packit |
6c4009 |
atanh(NaN) is that NaN with no signal;
|
|
Packit |
6c4009 |
atanh(+-1) is +-INF with signal.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <float.h>
|
|
Packit |
6c4009 |
#include <inttypes.h>
|
|
Packit |
6c4009 |
#include <math.h>
|
|
Packit |
6c4009 |
#include <math-barriers.h>
|
|
Packit |
6c4009 |
#include <math_private.h>
|
|
Packit |
6c4009 |
#include <math-underflow.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static const double huge = 1e300;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
double
|
|
Packit |
6c4009 |
__ieee754_atanh (double x)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
double xa = fabs (x);
|
|
Packit |
6c4009 |
double t;
|
|
Packit |
6c4009 |
if (isless (xa, 0.5))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (__glibc_unlikely (xa < 0x1.0p-28))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
math_force_eval (huge + x);
|
|
Packit |
6c4009 |
math_check_force_underflow (x);
|
|
Packit |
6c4009 |
return x;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
t = xa + xa;
|
|
Packit |
6c4009 |
t = 0.5 * __log1p (t + t * xa / (1.0 - xa));
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else if (__glibc_likely (isless (xa, 1.0)))
|
|
Packit |
6c4009 |
t = 0.5 * __log1p ((xa + xa) / (1.0 - xa));
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (isgreater (xa, 1.0))
|
|
Packit |
6c4009 |
return (x - x) / (x - x);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return x / 0.0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return __copysign (t, x);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
strong_alias (__ieee754_atanh, __atanh_finite)
|