home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / cephes22 / ellf / ellpe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-17  |  4.1 KB  |  191 lines

  1. /*                            ellpe.c
  2.  *
  3.  *    Complete elliptic integral of the second kind
  4.  *
  5.  *
  6.  *
  7.  * SYNOPSIS:
  8.  *
  9.  * double m1, y, ellpe();
  10.  *
  11.  * y = ellpe( m1 );
  12.  *
  13.  *
  14.  *
  15.  * DESCRIPTION:
  16.  *
  17.  * Approximates the integral
  18.  *
  19.  *
  20.  *            pi/2
  21.  *             -
  22.  *            | |                 2
  23.  * E(m)  =    |    sqrt( 1 - m sin t ) dt
  24.  *          | |    
  25.  *           -
  26.  *            0
  27.  *
  28.  * Where m = 1 - m1, using the approximation
  29.  *
  30.  *      P(x)  -  x log x Q(x).
  31.  *
  32.  * Though there are no singularities, the argument m1 is used
  33.  * rather than m for compatibility with ellpk().
  34.  *
  35.  * E(1) = 1; E(0) = pi/2.
  36.  *
  37.  *
  38.  * ACCURACY:
  39.  *
  40.  *                      Relative error:
  41.  * arithmetic   domain     # trials      peak         rms
  42.  *    DEC        0, 1       13000       3.1e-17     9.4e-18
  43.  *    IEEE       0, 1       10000       2.1e-16     7.3e-17
  44.  *
  45.  *
  46.  * ERROR MESSAGES:
  47.  *
  48.  *   message         condition      value returned
  49.  * ellpe domain      x<0, x>1            0.0
  50.  *
  51.  */
  52.  
  53. /*                            ellpe.c        */
  54.  
  55. /* Elliptic integral of second kind */
  56.  
  57. /*
  58. Cephes Math Library, Release 2.1:  February, 1989
  59. Copyright 1984, 1987, 1989 by Stephen L. Moshier
  60. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  61. */
  62.  
  63. #include "mconf.h"
  64.  
  65. #ifdef UNK
  66. static double P[] = {
  67.   1.53552577301013293365E-4,
  68.   2.50888492163602060990E-3,
  69.   8.68786816565889628429E-3,
  70.   1.07350949056076193403E-2,
  71.   7.77395492516787092951E-3,
  72.   7.58395289413514708519E-3,
  73.   1.15688436810574127319E-2,
  74.   2.18317996015557253103E-2,
  75.   5.68051945617860553470E-2,
  76.   4.43147180560990850618E-1,
  77.   1.00000000000000000299E0
  78. };
  79. static double Q[] = {
  80.   3.27954898576485872656E-5,
  81.   1.00962792679356715133E-3,
  82.   6.50609489976927491433E-3,
  83.   1.68862163993311317300E-2,
  84.   2.61769742454493659583E-2,
  85.   3.34833904888224918614E-2,
  86.   4.27180926518931511717E-2,
  87.   5.85936634471101055642E-2,
  88.   9.37499997197644278445E-2,
  89.   2.49999999999888314361E-1
  90. };
  91. #endif
  92.  
  93. #ifdef DEC
  94. static short P[] = {
  95. 0035041,0001364,0141572,0117555,
  96. 0036044,0066032,0130027,0033404,
  97. 0036416,0053617,0064456,0102632,
  98. 0036457,0161100,0061177,0122612,
  99. 0036376,0136251,0012403,0124162,
  100. 0036370,0101316,0151715,0131613,
  101. 0036475,0105477,0050317,0133272,
  102. 0036662,0154232,0024645,0171552,
  103. 0037150,0126220,0047054,0030064,
  104. 0037742,0162057,0167645,0165612,
  105. 0040200,0000000,0000000,0000000
  106. };
  107. static short Q[] = {
  108. 0034411,0106743,0115771,0055462,
  109. 0035604,0052575,0155171,0045540,
  110. 0036325,0030424,0064332,0167756,
  111. 0036612,0052366,0063006,0115175,
  112. 0036726,0070430,0004533,0124654,
  113. 0037011,0022741,0030675,0030711,
  114. 0037056,0174452,0127062,0132122,
  115. 0037157,0177750,0142041,0072523,
  116. 0037277,0177777,0173137,0002627,
  117. 0037577,0177777,0177777,0101101
  118. };
  119. #endif
  120.  
  121. #ifdef IBMPC
  122. static short P[] = {
  123. 0x53ee,0x986f,0x205e,0x3f24,
  124. 0xe6e0,0x5602,0x8d83,0x3f64,
  125. 0xd0b3,0xed25,0xcaf1,0x3f81,
  126. 0xf4b1,0x0c4f,0xfc48,0x3f85,
  127. 0x750e,0x22a0,0xd795,0x3f7f,
  128. 0xb671,0xda79,0x1059,0x3f7f,
  129. 0xf6d7,0xea19,0xb167,0x3f87,
  130. 0xbe6d,0x4534,0x5b13,0x3f96,
  131. 0x8607,0x09c5,0x1592,0x3fad,
  132. 0xbd71,0xfdf4,0x5c85,0x3fdc,
  133. 0x0000,0x0000,0x0000,0x3ff0
  134. };
  135. static short Q[] = {
  136. 0x2b66,0x737f,0x31bc,0x3f01,
  137. 0x296c,0xbb4f,0x8aaf,0x3f50,
  138. 0x5dfe,0x8d1b,0xa622,0x3f7a,
  139. 0xd350,0xccc0,0x4a9e,0x3f91,
  140. 0x7535,0x012b,0xce23,0x3f9a,
  141. 0xa639,0x2637,0x24bc,0x3fa1,
  142. 0x568a,0x55c6,0xdf25,0x3fa5,
  143. 0x2eaa,0x1884,0xfffd,0x3fad,
  144. 0xe0b3,0xfecb,0xffff,0x3fb7,
  145. 0xf048,0xffff,0xffff,0x3fcf
  146. };
  147. #endif
  148.  
  149. #ifdef MIEEE
  150. static short P[] = {
  151. 0x3f24,0x205e,0x986f,0x53ee,
  152. 0x3f64,0x8d83,0x5602,0xe6e0,
  153. 0x3f81,0xcaf1,0xed25,0xd0b3,
  154. 0x3f85,0xfc48,0x0c4f,0xf4b1,
  155. 0x3f7f,0xd795,0x22a0,0x750e,
  156. 0x3f7f,0x1059,0xda79,0xb671,
  157. 0x3f87,0xb167,0xea19,0xf6d7,
  158. 0x3f96,0x5b13,0x4534,0xbe6d,
  159. 0x3fad,0x1592,0x09c5,0x8607,
  160. 0x3fdc,0x5c85,0xfdf4,0xbd71,
  161. 0x3ff0,0x0000,0x0000,0x0000
  162. };
  163. static short Q[] = {
  164. 0x3f01,0x31bc,0x737f,0x2b66,
  165. 0x3f50,0x8aaf,0xbb4f,0x296c,
  166. 0x3f7a,0xa622,0x8d1b,0x5dfe,
  167. 0x3f91,0x4a9e,0xccc0,0xd350,
  168. 0x3f9a,0xce23,0x012b,0x7535,
  169. 0x3fa1,0x24bc,0x2637,0xa639,
  170. 0x3fa5,0xdf25,0x55c6,0x568a,
  171. 0x3fad,0xfffd,0x1884,0x2eaa,
  172. 0x3fb7,0xffff,0xfecb,0xe0b3,
  173. 0x3fcf,0xffff,0xffff,0xf048
  174. };
  175. #endif
  176.  
  177. double ellpe(x)
  178. double x;
  179. {
  180. double polevl(), log();
  181.  
  182. if( (x <= 0.0) || (x > 1.0) )
  183.     {
  184.     if( x == 0.0 )
  185.         return( 1.0 );
  186.     mtherr( "ellpe", DOMAIN );
  187.     return( 0.0 );
  188.     }
  189. return( polevl(x,P,10) - log(x) * (x * polevl(x,Q,9)) );
  190. }
  191.