|
Packit Service |
82fcde |
/* @(#)e_acosh.c 5.1 93/09/24 */
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
* ====================================================
|
|
Packit Service |
82fcde |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
Packit Service |
82fcde |
* Permission to use, copy, modify, and distribute this
|
|
Packit Service |
82fcde |
* software is freely granted, provided that this notice
|
|
Packit Service |
82fcde |
* is preserved.
|
|
Packit Service |
82fcde |
* ====================================================
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* __ieee754_acosh(x)
|
|
Packit Service |
82fcde |
* Method :
|
|
Packit Service |
82fcde |
* Based on
|
|
Packit Service |
82fcde |
* acosh(x) = log [ x + sqrt(x*x-1) ]
|
|
Packit Service |
82fcde |
* we have
|
|
Packit Service |
82fcde |
* acosh(x) := log(x)+ln2, if x is large; else
|
|
Packit Service |
82fcde |
* acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
|
|
Packit Service |
82fcde |
* acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
|
|
Packit Service |
82fcde |
*
|
|
Packit Service |
82fcde |
* Special cases:
|
|
Packit Service |
82fcde |
* acosh(x) is NaN with signal if x<1.
|
|
Packit Service |
82fcde |
* acosh(NaN) is NaN without signal.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <math.h>
|
|
Packit Service |
82fcde |
#include <math_private.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static const long double
|
|
Packit Service |
82fcde |
one = 1.0L,
|
|
Packit Service |
82fcde |
ln2 = M_LN2l;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
long double
|
|
Packit Service |
82fcde |
__ieee754_acoshl(long double x)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
long double t;
|
|
Packit Service |
82fcde |
int64_t hx;
|
|
Packit Service |
82fcde |
uint64_t lx;
|
|
Packit Service |
82fcde |
double xhi, xlo;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ldbl_unpack (x, &xhi, &xlo;;
|
|
Packit Service |
82fcde |
EXTRACT_WORDS64 (hx, xhi);
|
|
Packit Service |
82fcde |
EXTRACT_WORDS64 (lx, xlo);
|
|
Packit Service |
82fcde |
if(hx<0x3ff0000000000000LL) { /* x < 1 */
|
|
Packit Service |
82fcde |
return (x-x)/(x-x);
|
|
Packit Service |
82fcde |
} else if(hx >=0x4370000000000000LL) { /* x >= 2**56 */
|
|
Packit Service |
82fcde |
if(hx >=0x7ff0000000000000LL) { /* x is inf of NaN */
|
|
Packit Service |
82fcde |
return x+x;
|
|
Packit Service |
82fcde |
} else
|
|
Packit Service |
82fcde |
return __ieee754_logl(x)+ln2; /* acosh(huge)=log(2x) */
|
|
Packit Service |
82fcde |
} else if (((hx-0x3ff0000000000000LL)|(lx&0x7fffffffffffffffLL))==0) {
|
|
Packit Service |
82fcde |
return 0.0; /* acosh(1) = 0 */
|
|
Packit Service |
82fcde |
} else if (hx > 0x4000000000000000LL) { /* 2**56 > x > 2 */
|
|
Packit Service |
82fcde |
t=x*x;
|
|
Packit Service |
82fcde |
return __ieee754_logl(2.0*x-one/(x+sqrtl(t-one)));
|
|
Packit Service |
82fcde |
} else { /* 1
|
|
Packit Service |
82fcde |
t = x-one;
|
|
Packit Service |
82fcde |
return __log1pl(t+sqrtl(2.0*t+t*t));
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
strong_alias (__ieee754_acoshl, __acoshl_finite)
|