/* RCS $Id: q_asnh.c,v 1.2 1997/07/15 14:57:04 ae13 Exp $ */
/*
$Log: q_asnh.c,v $
 * Revision 1.2  1997/07/15  14:57:04  ae13
 * *** empty log message ***
 *
 * Revision 1.1  1997/05/16  13:29:06  ae13
 * Initial revision
 *
 */
/****************************************************************/
/*                                                              */
/*      Entries         : a_real q_asnh(a_real x)               */
/*                        a_real x  ;                           */
/*                                                              */
/*      Arguments       : x = real argument of asnh(x)          */
/*                                                              */
/*      Description     : Fast real area sine function          */
/*                        for double IEEE Floating-Point        */
/*                        Arithmetic                            */
/*                                                              */
/*      Date            : 1997-04-18                            */
/*                                                              */
/*      Author          : W. Hofschuster                        */
/*                                                              */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif


#include "q_defs.h"
#include "q_fcth.h"

#ifdef LINT_ARGS
local double q_asnh(double x)
#else
local double q_asnh(x)

double x;
#endif
{
  double h, res;
  int neg;
#ifdef PXSCTRAP
  E_SPUSH("q_asnh");
#endif
  if NANTEST(x)                                       /* Test: x=NaN */
      res=q_abortnan(INV_ARG,&x,22);
  else {
  if ((x>2.5e-8)&&(x<2.5e-8)) res=x;
  else
  {
    if (x<0) { x=-x; neg=1; } else neg=0;
    if (x>1e150) 
      {
        if (neg==1) res=-(q_l2+q_log1(x));
        else        res=  q_l2+q_log1(x);
      }
    else {
      if (x>=1.25)  /* old: x>=0.03125 */
      { 
         if (neg==1) res=-q_log1(x+sqrt(x*x+1));
         else        res= q_log1(x+sqrt(x*x+1)); 
      }
      else
      {
         h=1/x;
         if (neg==1) res=-q_l1p1(x+x/(sqrt(1+h*h)+h));
         else        res= q_l1p1(x+x/(sqrt(1+h*h)+h));
      }
    }  
  }
  }
#ifdef PXSCTRAP
  E_SPOPP("q_asnh");
#endif
  return(res);
}

