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

  1. /*                            acoshl.c
  2.  *
  3.  *    Inverse hyperbolic cosine, long double precision
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * long double x, y, acoshl();
  10.  *
  11.  * y = acoshl( x );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Returns inverse hyperbolic cosine of argument.
  18.  *
  19.  * If 1 <= x < 1.5, a rational approximation
  20.  *
  21.  *    sqrt(2z) * P(z)/Q(z)
  22.  *
  23.  * where z = x-1, is used.  Otherwise,
  24.  *
  25.  * acosh(x)  =  log( x + sqrt( (x-1)(x+1) ).
  26.  *
  27.  *
  28.  *
  29.  * ACCURACY:
  30.  *
  31.  *                      Relative error:
  32.  * arithmetic   domain     # trials      peak         rms
  33.  *    IEEE      1,3         30000       2.0e-19     3.9e-20
  34.  *
  35.  *
  36.  * ERROR MESSAGES:
  37.  *
  38.  *   message         condition      value returned
  39.  * acoshl domain      |x| < 1            0.0
  40.  *
  41.  */
  42.  
  43. /*                            acosh.c    */
  44.  
  45. /*
  46. Cephes Math Library Release 2.2:  January, 1991
  47. Copyright 1984, 1991 by Stephen L. Moshier
  48. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  49. */
  50.  
  51.  
  52. /* acosh(1+x) = sqrt(2x) * R(x), interval 0 < x < 0.5 */
  53.  
  54. #include "mconf.h"
  55.  
  56. #ifdef UNK
  57. static long double P[] = {
  58.  2.9071989653343333587238E-5L,
  59.  3.2906030801088967279449E-3L,
  60.  6.3034445964862182128388E-2L,
  61.  4.1587081802731351459504E-1L,
  62.  1.0989714347599256302467E0L,
  63.  9.9999999999999999999715E-1L,
  64. };
  65. static long double Q[] = {
  66.  1.0443462486787584738322E-4L,
  67.  6.0085845375571145826908E-3L,
  68.  8.7750439986662958343370E-2L,
  69.  4.9564621536841869854584E-1L,
  70.  1.1823047680932589605190E0L,
  71.  1.0000000000000000000028E0L,
  72. };
  73. #endif
  74.  
  75.  
  76. #ifdef IBMPC
  77. static short P[] = {
  78. 0x4536,0x4dba,0x9f55,0xf3df,0x3fef,
  79. 0x23a5,0xf9aa,0x289c,0xd7a7,0x3ff6,
  80. 0x7e8b,0x8645,0x341f,0x8118,0x3ffb,
  81. 0x0fd5,0x937f,0x0515,0xd4ed,0x3ffd,
  82. 0x2364,0xc41b,0x1891,0x8cab,0x3fff,
  83. 0x0000,0x0000,0x0000,0x8000,0x3fff,
  84. };
  85. static short Q[] = {
  86. 0x1e7c,0x4f16,0xe98c,0xdb03,0x3ff1,
  87. 0xc319,0xc272,0xa90a,0xc4e3,0x3ff7,
  88. 0x2f83,0x9e5e,0x80af,0xb3b6,0x3ffb,
  89. 0xe1e0,0xc97c,0x573a,0xfdc5,0x3ffd,
  90. 0xcdf2,0x6ec5,0xc33c,0x9755,0x3fff,
  91. 0x0000,0x0000,0x0000,0x8000,0x3fff,
  92. };
  93. #endif
  94.  
  95. #ifdef MIEEE
  96. static long P[] = {
  97. 0x3fef0000,0xf3df9f55,0x4dba4536,
  98. 0x3ff60000,0xd7a7289c,0xf9aa23a5,
  99. 0x3ffb0000,0x8118341f,0x86457e8b,
  100. 0x3ffd0000,0xd4ed0515,0x937f0fd5,
  101. 0x3fff0000,0x8cab1891,0xc41b2364,
  102. 0x3fff0000,0x80000000,0x00000000,
  103. };
  104. static long Q[] = {
  105. 0x3ff10000,0xdb03e98c,0x4f161e7c,
  106. 0x3ff70000,0xc4e3a90a,0xc272c319,
  107. 0x3ffb0000,0xb3b680af,0x9e5e2f83,
  108. 0x3ffd0000,0xfdc5573a,0xc97ce1e0,
  109. 0x3fff0000,0x9755c33c,0x6ec5cdf2,
  110. 0x3fff0000,0x80000000,0x00000000,
  111. };
  112. #endif
  113.  
  114. extern long double LOGE2L;
  115.  
  116. long double acoshl(x)
  117. long double x;
  118. {
  119. long double a, z;
  120. long double logl(), sqrtl(), polevll();
  121.  
  122. if( x < 1.0L )
  123.     {
  124.     mtherr( "acoshl", DOMAIN );
  125.     return(0.0L);
  126.     }
  127.  
  128. if( x > 1.0e10 )
  129.     return( logl(x) + LOGE2L );
  130.  
  131. z = x - 1.0L;
  132.  
  133. if( z < 0.5L )
  134.     {
  135.     a = sqrtl(2.0*z) * (polevll(z, P, 5) / polevll(z, Q, 5) );
  136.     return( a );
  137.     }
  138.  
  139. a = sqrtl( z*(x+1.0L) );
  140. return( logl(x + a) );
  141. }
  142.