/* RCS $Id: q_sinh.c,v 1.2 1997/07/15 14:57:04 ae13 Exp $ */
/*
$Log: q_sinh.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_sinh(a_real x)               */
/*                        a_real x  ;                           */
/*                                                              */
/*      Arguments       : x = real argument of sinh(x)          */
/*                                                              */
/*      Description     : Fast real hyperbolic sine function    */
/*                        for double IEEE Floating-Point        */
/*                        Arithmetic                            */
/*                                                              */
/*      Date            : 1997-07-07                            */
/*                                                              */
/*      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_sinh(double x)
#else
local double q_sinh(x)

double x;
#endif
{
  double absx, h;
  int sgn;
  double res;

#ifdef PXSCTRAP
  E_SPUSH("q_sinh");
#endif
  if NANTEST(x)                                       /* Test: x=NaN */
      res=q_abortnan(INV_ARG,&x,18);
  else {
  if (x<0) {sgn=-1; absx=-x;}
  else     {sgn=1;  absx=x; }
 
  if (absx>q_ex2a)
      res=q_abortr1(OVER_FLOW,&x,18);                 /* Overflow */

  if (absx<2.5783798e-8) res=x;
  else if (absx>=0.662) 
    {
       h=q_ep1(absx);
       res=sgn*0.5*(h-1.0/h);
    }
  else
    {
       h=q_epm1(absx);
       res=sgn*0.5*(h+h/(h+1.0));
    }
#ifdef PXSCTRAP  
  E_SPOPP("q_sinh");
#endif
  }
  return(res);
}

