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

  1. /*                            sinhl.c
  2.  *
  3.  *    Hyperbolic sine, long double precision
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * long double x, y, sinhl();
  10.  *
  11.  * y = sinhl( x );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Returns hyperbolic sine of argument in the range MINLOGL to
  18.  * MAXLOGL.
  19.  *
  20.  * The range is partitioned into two segments.  If |x| <= 1, a
  21.  * rational function of the form x + x**3 P(x)/Q(x) is employed.
  22.  * Otherwise the calculation is sinh(x) = ( exp(x) - exp(-x) )/2.
  23.  *
  24.  *
  25.  *
  26.  * ACCURACY:
  27.  *
  28.  *                      Relative error:
  29.  * arithmetic   domain     # trials      peak         rms
  30.  *    IEEE       -2,2       10000       1.5e-19     3.9e-20
  31.  *    IEEE     +-10000      30000       1.1e-19     2.8e-20
  32.  *
  33.  */
  34.  
  35. /*
  36. Cephes Math Library Release 2.2:  January, 1991
  37. Copyright 1984, 1991 by Stephen L. Moshier
  38. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  39. */
  40.  
  41. #include "mconf.h"
  42.  
  43. #ifdef UNK
  44. static long double P[] = {
  45.  1.7550769032975377032681E-6L,
  46.  4.1680702175874268714539E-4L,
  47.  3.0993532520425419002409E-2L,
  48.  9.9999999999999999998002E-1L,
  49. };
  50. static long double Q[] = {
  51.  1.7453965448620151484660E-8L,
  52. -5.9116673682651952419571E-6L,
  53.  1.0599252315677389339530E-3L,
  54. -1.1403880487744749056675E-1L,
  55.  6.0000000000000000000200E0L,
  56. };
  57. #endif
  58.  
  59. #ifdef IBMPC
  60. static short P[] = {
  61. 0xec6a,0xd942,0xfbb3,0xeb8f,0x3feb,
  62. 0x365e,0xb30a,0xe437,0xda86,0x3ff3,
  63. 0x8890,0x01f6,0x2612,0xfde6,0x3ff9,
  64. 0x0000,0x0000,0x0000,0x8000,0x3fff,
  65. };
  66. static short Q[] = {
  67. 0x4edd,0x4c21,0xad09,0x95ed,0x3fe5,
  68. 0x4376,0x9b70,0xd605,0xc65c,0xbfed,
  69. 0xc8ad,0x5d21,0x3069,0x8aed,0x3ff5,
  70. 0x9c32,0x6374,0x2d4b,0xe98d,0xbffb,
  71. 0x0000,0x0000,0x0000,0xc000,0x4001,
  72. };
  73. #endif
  74.  
  75. #ifdef MIEEE
  76. static long P[] = {
  77. 0x3feb0000,0xeb8ffbb3,0xd942ec6a,
  78. 0x3ff30000,0xda86e437,0xb30a365e,
  79. 0x3ff90000,0xfde62612,0x01f68890,
  80. 0x3fff0000,0x80000000,0x00000000,
  81. };
  82. static long Q[] = {
  83. 0x3fe50000,0x95edad09,0x4c214edd,
  84. 0xbfed0000,0xc65cd605,0x9b704376,
  85. 0x3ff50000,0x8aed3069,0x5d21c8ad,
  86. 0xbffb0000,0xe98d2d4b,0x63749c32,
  87. 0x40010000,0xc0000000,0x00000000,
  88. };
  89. #endif
  90.  
  91. extern long double MAXNUML, MAXLOGL;
  92.  
  93. long double sinhl(x)
  94. long double x;
  95. {
  96. long double a;
  97. long double fabsl(), expl(), polevll(), p1evll();
  98.  
  99. a = fabsl(x);
  100. if( a > MAXLOGL )
  101.     {
  102.     mtherr( "sinhl", DOMAIN );
  103.     if( x > 0 )
  104.         return( MAXNUML );
  105.     else
  106.         return( -MAXNUML );
  107.     }
  108. if( a > 1.0L )
  109.     {
  110.     a = expl(a);
  111.     a = 0.5L*a - (0.5L/a);
  112.     if( x < 0 )
  113.         a = -a;
  114.     return(a);
  115.     }
  116.  
  117. a *= a;
  118. return( x + x * a * (polevll(a,P,3)/polevll(a,Q,4)) );
  119. }
  120.