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

  1. /*                            sinh.c
  2.  *
  3.  *    Hyperbolic sine
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * double x, y, sinh();
  10.  *
  11.  * y = sinh( x );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Returns hyperbolic sine of argument in the range MINLOG to
  18.  * MAXLOG.
  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.  *    DEC        0,2        10000       4.2e-17     8.3e-18
  31.  *    IEEE     +-MAXLOG     30000       2.6e-16     5.7e-17
  32.  *
  33.  */
  34.  
  35. /*
  36. Cephes Math Library Release 2.1:  February, 1989
  37. Copyright 1984, 1987, 1989 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 double P[] = {
  45. -7.89474443963537015605E-1,
  46. -1.63725857525983828727E2,
  47. -1.15614435765005216044E4,
  48. -3.51754964808151394800E5
  49. };
  50. static double Q[] = {
  51. /* 1.00000000000000000000E0,*/
  52. -2.77711081420602794433E2,
  53.  3.61578279834431989373E4,
  54. -2.11052978884890840399E6
  55. };
  56. #endif
  57.  
  58. #ifdef DEC
  59. static short P[] = {
  60. 0140112,0015377,0042731,0163255,
  61. 0142043,0134721,0146177,0123761,
  62. 0143464,0122706,0034353,0006017,
  63. 0144653,0140536,0157665,0054045
  64. };
  65. static short Q[] = {
  66. /*0040200,0000000,0000000,0000000,*/
  67. 0142212,0155404,0133513,0022040,
  68. 0044015,0036723,0173271,0011053,
  69. 0145400,0150407,0023710,0001034
  70. };
  71. #endif
  72.  
  73. #ifdef IBMPC
  74. static short P[] = {
  75. 0x3cd6,0xe8bb,0x435f,0xbfe9,
  76. 0xf4fe,0x398f,0x773a,0xc064,
  77. 0x6182,0xc71d,0x94b8,0xc0c6,
  78. 0xab05,0xdbf6,0x782b,0xc115
  79. };
  80. static short Q[] = {
  81. /*0x0000,0x0000,0x0000,0x3ff0,*/
  82. 0x6484,0x96e9,0x5b60,0xc071,
  83. 0x2245,0x7ed7,0xa7ba,0x40e1,
  84. 0x0044,0xe4f9,0x1a20,0xc140
  85. };
  86. #endif
  87.  
  88. #ifdef MIEEE
  89. static short P[] = {
  90. 0xbfe9,0x435f,0xe8bb,0x3cd6,
  91. 0xc064,0x773a,0x398f,0xf4fe,
  92. 0xc0c6,0x94b8,0xc71d,0x6182,
  93. 0xc115,0x782b,0xdbf6,0xab05
  94. };
  95. static short Q[] = {
  96. 0xc071,0x5b60,0x96e9,0x6484,
  97. 0x40e1,0xa7ba,0x7ed7,0x2245,
  98. 0xc140,0x1a20,0xe4f9,0x0044
  99. };
  100. #endif
  101.  
  102. extern double MAXNUM, MAXLOG;
  103.  
  104. double sinh(x)
  105. double x;
  106. {
  107. double a;
  108. double fabs(), exp(), polevl(), p1evl();
  109.  
  110. a = fabs(x);
  111. if( a > MAXLOG )
  112.     {
  113.     mtherr( "sinh", DOMAIN );
  114.     if( x > 0 )
  115.         return( MAXNUM );
  116.     else
  117.         return( -MAXNUM );
  118.     }
  119. if( a > 1.0 )
  120.     {
  121.     a = exp(a);
  122.     a = 0.5*a - (0.5/a);
  123.     if( x < 0 )
  124.         a = -a;
  125.     return(a);
  126.     }
  127.  
  128. a *= a;
  129. return( x + x * a * (polevl(a,P,3)/p1evl(a,Q,3)) );
  130. }
  131.