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

  1. /*                            asinhl.c
  2.  *
  3.  *    Inverse hyperbolic sine, long double precision
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * long double x, y, asinhl();
  10.  *
  11.  * y = asinhl( x );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Returns inverse hyperbolic sine of argument.
  18.  *
  19.  * If |x| < 0.5, the function is approximated by a rational
  20.  * form  x + x**3 P(x)/Q(x).  Otherwise,
  21.  *
  22.  *     asinh(x) = log( x + sqrt(1 + x*x) ).
  23.  *
  24.  *
  25.  *
  26.  * ACCURACY:
  27.  *
  28.  *                      Relative error:
  29.  * arithmetic   domain     # trials      peak         rms
  30.  *    IEEE     -3,3         30000       1.7e-19     3.5e-20
  31.  *
  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.  
  42. #include "mconf.h"
  43.  
  44. #ifdef UNK
  45. static long double P[] = {
  46. -7.2157234864927687427374E-1L,
  47. -1.3005588097490352458918E1L,
  48. -5.9112383795679709212744E1L,
  49. -9.5372702442289028811361E1L,
  50. -4.9802880260861844539014E1L,
  51. };
  52. static long double Q[] = {
  53. /* 1.0000000000000000000000E0L,*/
  54.  2.8754968540389640419671E1L,
  55.  2.0990255691901160529390E2L,
  56.  5.9265075560893800052658E2L,
  57.  7.0670399135805956780660E2L,
  58.  2.9881728156517107462943E2L,
  59. };
  60. #endif
  61.  
  62.  
  63. #ifdef IBMPC
  64. static short P[] = {
  65. 0x8f42,0x2584,0xf727,0xb8b8,0xbffe,
  66. 0x9d56,0x7f7c,0xe38b,0xd016,0xc002,
  67. 0xc518,0xdc2d,0x14bc,0xec73,0xc004,
  68. 0x99fe,0xc18a,0xd2da,0xbebe,0xc005,
  69. 0xb46c,0x3c05,0x263e,0xc736,0xc004,
  70. };
  71. static short Q[] = {
  72. /*0x0000,0x0000,0x0000,0x8000,0x3fff,*/
  73. 0xdfed,0x33db,0x2cf2,0xe60a,0x4003,
  74. 0xf109,0x61ee,0x0df8,0xd1e7,0x4006,
  75. 0xf21e,0xda84,0xa5fa,0x9429,0x4008,
  76. 0x13fc,0xc4e2,0x0e31,0xb0ad,0x4008,
  77. 0x485c,0xad04,0x9cae,0x9568,0x4007,
  78. };
  79. #endif
  80.  
  81. #ifdef MIEEE
  82. static long P[] = {
  83. 0xbffe0000,0xb8b8f727,0x25848f42,
  84. 0xc0020000,0xd016e38b,0x7f7c9d56,
  85. 0xc0040000,0xec7314bc,0xdc2dc518,
  86. 0xc0050000,0xbebed2da,0xc18a99fe,
  87. 0xc0040000,0xc736263e,0x3c05b46c,
  88. };
  89. static long Q[] = {
  90. /*0x3fff0000,0x80000000,0x00000000,*/
  91. 0x40030000,0xe60a2cf2,0x33dbdfed,
  92. 0x40060000,0xd1e70df8,0x61eef109,
  93. 0x40080000,0x9429a5fa,0xda84f21e,
  94. 0x40080000,0xb0ad0e31,0xc4e213fc,
  95. 0x40070000,0x95689cae,0xad04485c,
  96. };
  97. #endif
  98.  
  99. extern long double LOGE2L;
  100.  
  101. long double asinhl(x)
  102. long double x;
  103. {
  104. long double a, z;
  105. int sign;
  106. long double logl(), sqrtl(), polevll(), p1evll();
  107.  
  108. if( x < 0 )
  109.     {
  110.     sign = -1;
  111.     x = -x;
  112.     }
  113. else
  114.     sign = 1;
  115.  
  116. if( x > 1.0e10L )
  117.     return( sign * (logl(x) + LOGE2L) );
  118.  
  119. z = x * x;
  120. if( x < 0.5 )
  121.     {
  122.     a = ( polevll(z, P, 4)/p1evll(z, Q, 5) ) * z;
  123.     a = a * x  +  x;
  124.     if( sign < 0 )
  125.         a = -a;
  126.     return(a);
  127.     }    
  128.  
  129. a = sqrtl( z + 1.0L );
  130. return( sign * logl(x + a) );
  131. }
  132.