Back to index

glibc  2.9
Functions | Variables
e_cosh.c File Reference
#include "math.h"
#include "math_private.h"

Go to the source code of this file.

Functions

double __ieee754_cosh (double x)

Variables

static double one = 1.0
static double half = 0.5
static double huge = 1.0e300

Function Documentation

double __ieee754_cosh ( double  x)

Definition at line 50 of file e_cosh.c.

{      
       double t,w;
       int32_t ix;
       u_int32_t lx;

    /* High word of |x|. */
       GET_HIGH_WORD(ix,x);
       ix &= 0x7fffffff;

    /* x is INF or NaN */
       if(ix>=0x7ff00000) return x*x;     

    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
       if(ix<0x3fd62e43) {
           t = __expm1(fabs(x));
           w = one+t;
           if (ix<0x3c800000) return w;   /* cosh(tiny) = 1 */
           return one+(t*t)/(w+w);
       }

    /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
       if (ix < 0x40360000) {
              t = __ieee754_exp(fabs(x));
              return half*t+half/t;
       }

    /* |x| in [22, log(maxdouble)] return half*exp(|x|) */
       if (ix < 0x40862e42)  return half*__ieee754_exp(fabs(x));

    /* |x| in [log(maxdouble), overflowthresold] */
       GET_LOW_WORD(lx,x);
       if (ix<0x408633ce || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
           w = __ieee754_exp(half*fabs(x));
           t = half*w;
           return t*w;
       }

    /* |x| > overflowthresold, cosh(x) overflow */
       return huge*huge;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double half = 0.5 [static]

Definition at line 44 of file e_cosh.c.

double huge = 1.0e300 [static]

Definition at line 44 of file e_cosh.c.

double one = 1.0 [static]

Definition at line 44 of file e_cosh.c.