/* RCS $Id: q_cth1.c,v 1.1 1997/05/16 13:29:06 ae13 Exp $ */
/*
$Log: q_cth1.c,v $
 * Revision 1.1  1997/05/16  13:29:06  ae13
 * Initial revision
 *
 * Revision 1.1  1997/05/16  13:29:06  ae13
 * Initial revision
 *
 */
/****************************************************************/
/*                                                              */
/*      Entries         : a_real q_cth1(a_real x)               */
/*                        a_real x  ;                           */
/*                                                              */
/*      Arguments       : x = real argument of coth(x)          */
/*                                                              */
/*      Description     : Fast real hyperbolic cotangent        */
/*                        function for double IEEE              */
/*                        Floating-Point Arithmetic             */
/*                                                              */
/*      Date of 1.issue : 1996-03-08                            */
/*                                                              */
/*      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_cth1(double x)
#else
local double q_cth1(x)

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

  if (x<0) { sgn=-1; absx=-x; }
  else     { sgn=1; absx=x;  }

  if (absx>22.875) res=sgn;
  else if (absx>=q_ln2h) res=sgn*(1+2/(q_ep1(2*absx)-1));
  else res=sgn*(1+2/q_epm1(2*absx));

  return(res);
}
