Blame sysdeps/ieee754/ldbl-128/e_acoshl.c

Packit 6c4009
/* e_acoshl.c -- long double version of e_acosh.c.
Packit 6c4009
 * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * ====================================================
Packit 6c4009
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Developed at SunPro, a Sun Microsystems, Inc. business.
Packit 6c4009
 * Permission to use, copy, modify, and distribute this
Packit 6c4009
 * software is freely granted, provided that this notice
Packit 6c4009
 * is preserved.
Packit 6c4009
 * ====================================================
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/* __ieee754_acoshl(x)
Packit 6c4009
 * Method :
Packit 6c4009
 *	Based on
Packit 6c4009
 *		acoshl(x) = logl [ x + sqrtl(x*x-1) ]
Packit 6c4009
 *	we have
Packit 6c4009
 *		acoshl(x) := logl(x)+ln2,	if x is large; else
Packit 6c4009
 *		acoshl(x) := logl(2x-1/(sqrtl(x*x-1)+x)) if x>2; else
Packit 6c4009
 *		acoshl(x) := log1pl(t+sqrtl(2.0*t+t*t)); where t=x-1.
Packit 6c4009
 *
Packit 6c4009
 * Special cases:
Packit 6c4009
 *	acoshl(x) is NaN with signal if x<1.
Packit 6c4009
 *	acoshl(NaN) is NaN without signal.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
Packit 6c4009
static const _Float128
Packit 6c4009
one	= 1.0,
Packit 6c4009
ln2	= L(0.6931471805599453094172321214581766);
Packit 6c4009
Packit 6c4009
_Float128
Packit 6c4009
__ieee754_acoshl(_Float128 x)
Packit 6c4009
{
Packit 6c4009
	_Float128 t;
Packit 6c4009
	uint64_t lx;
Packit 6c4009
	int64_t hx;
Packit 6c4009
	GET_LDOUBLE_WORDS64(hx,lx,x);
Packit 6c4009
	if(hx<0x3fff000000000000LL) {		/* x < 1 */
Packit 6c4009
	    return (x-x)/(x-x);
Packit 6c4009
	} else if(hx >=0x4035000000000000LL) {	/* x > 2**54 */
Packit 6c4009
	    if(hx >=0x7fff000000000000LL) {	/* x is inf of NaN */
Packit 6c4009
		return x+x;
Packit 6c4009
	    } else
Packit 6c4009
		return __ieee754_logl(x)+ln2;	/* acoshl(huge)=logl(2x) */
Packit 6c4009
	} else if(((hx-0x3fff000000000000LL)|lx)==0) {
Packit 6c4009
	    return 0;			/* acosh(1) = 0 */
Packit 6c4009
	} else if (hx > 0x4000000000000000LL) {	/* 2**28 > x > 2 */
Packit 6c4009
	    t=x*x;
Packit 6c4009
	    return __ieee754_logl(2*x-one/(x+sqrtl(t-one)));
Packit 6c4009
	} else {			/* 1
Packit 6c4009
	    t = x-one;
Packit 6c4009
	    return __log1pl(t+sqrtl(2*t+t*t));
Packit 6c4009
	}
Packit 6c4009
}
Packit 6c4009
strong_alias (__ieee754_acoshl, __acoshl_finite)