/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss of reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#include <math.h>

/****************************************************************************/
/*					Public API functions									*/
/****************************************************************************/

/** @addtogroup func */
/** @{ */

/**
*	Inverse hyperbolic cosine function.
*
*	@param	x			The function argument
*
*	@retval	NaN			The argument was NaN or less than +1.0
*	@retval	+INF		The argument was infinite
*	@retval	acosh(x)	Otherwise, always the positive x is returned.
*/

float	acoshf( float x )
{
	if ( isnan( x ) || isinf( x ) > 0 ) return( x );
	if ( x < 1.0f ) return( nan( 0 ) );

	if ( x > 4915 )

		return( logf( ldexpf( x, 1 ) ) );
	else
		return( logf( x + sqrtf( x * x - 1 ) ) );
}

/** @} */

