home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / math / cephes / ldouble / coshl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-17  |  1.0 KB  |  67 lines

  1. /*                            coshl.c
  2.  *
  3.  *    Hyperbolic cosine, long double precision
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * long double x, y, coshl();
  10.  *
  11.  * y = coshl( x );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Returns hyperbolic cosine of argument in the range MINLOGL to
  18.  * MAXLOGL.
  19.  *
  20.  * cosh(x)  =  ( exp(x) + exp(-x) )/2.
  21.  *
  22.  *
  23.  *
  24.  * ACCURACY:
  25.  *
  26.  *                      Relative error:
  27.  * arithmetic   domain     # trials      peak         rms
  28.  *    IEEE     +-10000      30000       1.1e-19     2.8e-20
  29.  *
  30.  *
  31.  * ERROR MESSAGES:
  32.  *
  33.  *   message         condition      value returned
  34.  * cosh overflow    |x| > MAXLOGL       MAXNUML
  35.  *
  36.  *
  37.  */
  38.  
  39.  
  40. /*
  41. Cephes Math Library Release 2.2:  January, 1991
  42. Copyright 1985, 1991 by Stephen L. Moshier
  43. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  44. */
  45.  
  46. #include "mconf.h"
  47. extern long double MAXLOGL, MAXNUML;
  48.  
  49. long double coshl(x)
  50. long double x;
  51. {
  52. long double y;
  53. long double expl(), ldexpl();
  54.  
  55. if( x < 0 )
  56.     x = -x;
  57. if( x > MAXLOGL )
  58.     {
  59.     mtherr( "coshl", OVERFLOW );
  60.     return( MAXNUML );
  61.     }    
  62. y = expl(x);
  63. y = y + 1.0L/y;
  64. y = ldexpl( y, -1 );
  65. return( y );
  66. }
  67.