00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #if defined(LIBM_SCCS) && !defined(lint)
00014 static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $";
00015 #endif
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "math.h"
00039 #include "mathP.h"
00040
00041 #ifdef __STDC__
00042 static const double one = 1.0, half=0.5, huge = 1.0e300;
00043 #else
00044 static double one = 1.0, half=0.5, huge = 1.0e300;
00045 #endif
00046
00047 #ifdef __STDC__
00048 double __ieee754_cosh(double x)
00049 #else
00050 double __ieee754_cosh(x)
00051 double x;
00052 #endif
00053 {
00054 double t,w;
00055 int32_t ix;
00056 u_int32_t lx;
00057
00058
00059 GET_HIGH_WORD(ix,x);
00060 ix &= 0x7fffffff;
00061
00062
00063 if(ix>=0x7ff00000) return x*x;
00064
00065
00066 if(ix<0x3fd62e43) {
00067 t = expm1(fabs(x));
00068 w = one+t;
00069 if (ix<0x3c800000) return w;
00070 return one+(t*t)/(w+w);
00071 }
00072
00073
00074 if (ix < 0x40360000) {
00075 t = __ieee754_exp(fabs(x));
00076 return half*t+half/t;
00077 }
00078
00079
00080 if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
00081
00082
00083 GET_LOW_WORD(lx,x);
00084 if (ix<0x408633CE ||
00085 ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
00086 w = __ieee754_exp(half*fabs(x));
00087 t = half*w;
00088 return t*w;
00089 }
00090
00091
00092 return huge*huge;
00093 }