/* ellpk.c
*
* Complete elliptic integral of the first kind
*
*
*
* SYNOPSIS :
*
* double m1 , y , ellpk ( ) ;
*
* y = ellpk ( m1 ) ;
*
*
*
* DESCRIPTION :
*
* Approximates the integral
*
*
*
* pi / 2
* -
* | |
* | dt
* K ( m ) = | - - - - - - - - - - - - - - - - - -
* | 2
* | | sqrt ( 1 - m sin t )
* -
* 0
*
* where m = 1 - m1 , using the approximation
*
* P ( x ) - log x Q ( x ) .
*
* The argument m1 is used rather than m so that the logarithmic
* singularity at m = 1 will be shifted to the origin ; this
* preserves maximum accuracy .
*
* K ( 0 ) = pi / 2 .
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* DEC 0 , 1 16000 3 . 5 e - 17 1 . 1 e - 17
* IEEE 0 , 1 30000 2 . 5 e - 16 6 . 8 e - 17
*
* ERROR MESSAGES :
*
* message condition value returned
* ellpk domain x < 0 , x > 1 0 . 0
*
*/
/* ellpk.c */
/*
Cephes Math Library , Release 2 . 8 : June , 2000
Copyright 1984 , 1987 , 2000 by Stephen L . Moshier
*/
#include "mconf.h"
#ifdef DEC
static unsigned short P[] = {
0035020 , 0127576 , 0040430 , 0051544 , 0036025 , 0070136 , 0042703 , 0153716 ,
0036402 , 0122614 , 0062555 , 0077777 , 0036441 , 0102130 , 0072334 , 0025172 ,
0036341 , 0043320 , 0117242 , 0172076 , 0036312 , 0146456 , 0077242 , 0154141 ,
0036420 , 0003467 , 0013727 , 0035407 , 0036564 , 0137263 , 0110651 , 0020237 ,
0036775 , 0001330 , 0144056 , 0020305 , 0037305 , 0144137 , 0157521 , 0141734 ,
0040261 , 0071027 , 0173721 , 0147572 };
static unsigned short Q[] = {
0034366 , 0130371 , 0103453 , 0077633 , 0035557 , 0122745 , 0173515 , 0113016 ,
0036302 , 0124470 , 0167304 , 0074473 , 0036575 , 0132403 , 0117226 , 0117576 ,
0036703 , 0156271 , 0047124 , 0147733 , 0036766 , 0137465 , 0002053 , 0157312 ,
0037031 , 0014423 , 0154274 , 0176515 , 0037107 , 0177747 , 0143216 , 0016145 ,
0037217 , 0177777 , 0172621 , 0074000 , 0037377 , 0177777 , 0177776 , 0156435 ,
0040000 , 0000000 , 0000000 , 0000000 };
static unsigned short ac1[] = {0040261 , 0071027 , 0173721 , 0147572 };
#define C1 (*(double *)ac1)
#endif
#ifdef IBMPC
static unsigned short P[] = {
0 x0a6d, 0 xc823, 0 x15ef, 0 x3f22, 0 x7afa, 0 xc8b8, 0 xae0b, 0 x3f62, 0 xb000,
0 x8cad, 0 x54b1, 0 x3f80, 0 x854f, 0 x0e9b, 0 x308b, 0 x3f84, 0 x5e88, 0 x13d4,
0 x28da, 0 x3f7c, 0 x5b0c, 0 xcfd4, 0 x59a5, 0 x3f79, 0 xe761, 0 xe2fa, 0 x00e6,
0 x3f82, 0 x2414, 0 x7235, 0 x97d6, 0 x3f8e, 0 xc419, 0 x1905, 0 xa05b, 0 x3f9f,
0 x387c, 0 xfbea, 0 xb90b, 0 x3fb8, 0 x39ef, 0 xfefa, 0 x2e42, 0 x3ff6};
static unsigned short Q[] = {
0 x6ff3, 0 x30e5, 0 xd61f, 0 x3efe, 0 xb2c2, 0 xbee9, 0 xf4bc, 0 x3f4d, 0 x8f27,
0 x1dd8, 0 x5527, 0 x3f78, 0 xd3f0, 0 x73d2, 0 xb6a0, 0 x3f8f, 0 x99fb, 0 x29ca,
0 x7b97, 0 x3f98, 0 x7bd9, 0 xa085, 0 xd7e6, 0 x3f9e, 0 x9faa, 0 x7b17, 0 x2322,
0 x3fa3, 0 xc38d, 0 xf8d1, 0 xfffc, 0 x3fa8, 0 x2f00, 0 xfeb2, 0 xffff, 0 x3fb1,
0 xdba4, 0 xffff, 0 xffff, 0 x3fbf, 0 x0000, 0 x0000, 0 x0000, 0 x3fe0};
static unsigned short ac1[] = {0 x39ef, 0 xfefa, 0 x2e42, 0 x3ff6};
#define C1 (*(double *)ac1)
#endif
#ifdef MIEEE
static unsigned short P[] = {
0 x3f22, 0 x15ef, 0 xc823, 0 x0a6d, 0 x3f62, 0 xae0b, 0 xc8b8, 0 x7afa, 0 x3f80,
0 x54b1, 0 x8cad, 0 xb000, 0 x3f84, 0 x308b, 0 x0e9b, 0 x854f, 0 x3f7c, 0 x28da,
0 x13d4, 0 x5e88, 0 x3f79, 0 x59a5, 0 xcfd4, 0 x5b0c, 0 x3f82, 0 x00e6, 0 xe2fa,
0 xe761, 0 x3f8e, 0 x97d6, 0 x7235, 0 x2414, 0 x3f9f, 0 xa05b, 0 x1905, 0 xc419,
0 x3fb8, 0 xb90b, 0 xfbea, 0 x387c, 0 x3ff6, 0 x2e42, 0 xfefa, 0 x39ef};
static unsigned short Q[] = {
0 x3efe, 0 xd61f, 0 x30e5, 0 x6ff3, 0 x3f4d, 0 xf4bc, 0 xbee9, 0 xb2c2, 0 x3f78,
0 x5527, 0 x1dd8, 0 x8f27, 0 x3f8f, 0 xb6a0, 0 x73d2, 0 xd3f0, 0 x3f98, 0 x7b97,
0 x29ca, 0 x99fb, 0 x3f9e, 0 xd7e6, 0 xa085, 0 x7bd9, 0 x3fa3, 0 x2322, 0 x7b17,
0 x9faa, 0 x3fa8, 0 xfffc, 0 xf8d1, 0 xc38d, 0 x3fb1, 0 xffff, 0 xfeb2, 0 x2f00,
0 x3fbf, 0 xffff, 0 xffff, 0 xdba4, 0 x3fe0, 0 x0000, 0 x0000, 0 x0000};
static unsigned short ac1[] = {0 x3ff6, 0 x2e42, 0 xfefa, 0 x39ef};
#define C1 (*(double *)ac1)
#endif
#ifdef UNK
static double P[] = {1 .37982864606273237150 E-4 , 2 .28025724005875567385 E-3 ,
7 .97404013220415179367 E-3 , 9 .85821379021226008714 E-3 ,
6 .87489687449949877925 E-3 , 6 .18901033637687613229 E-3 ,
8 .79078273952743772254 E-3 , 1 .49380448916805252718 E-2 ,
3 .08851465246711995998 E-2 , 9 .65735902811690126535 E-2 ,
1 .38629436111989062502 E0};
static double Q[] = {2 .94078955048598507511 E-5 , 9 .14184723865917226571 E-4 ,
5 .94058303753167793257 E-3 , 1 .54850516649762399335 E-2 ,
2 .39089602715924892727 E-2 , 3 .01204715227604046988 E-2 ,
3 .73774314173823228969 E-2 , 4 .88280347570998239232 E-2 ,
7 .03124996963957469739 E-2 , 1 .24999999999870820058 E-1 ,
4 .99999999999999999821 E-1 };
static double C1 = 1 .3862943611198906188 E0; /* log(4) */
#endif
#ifdef ANSIPROT
extern double polevl(double , void *, int );
extern double p1evl(double , void *, int );
extern double log(double );
#else
double polevl(), p1evl(), log();
#endif
extern double MACHEP, MAXNUM;
double ellpk(x) double x;
{
if ((x < 0 .0 ) || (x > 1 .0 )) {
mtherr("ellpk" , DOMAIN);
return (0 .0 );
}
if (x > MACHEP) {
return (polevl(x, P, 10 ) - log(x) * polevl(x, Q, 10 ));
} else {
if (x == 0 .0 ) {
mtherr("ellpk" , SING);
return (MAXNUM);
} else {
return (C1 - 0 .5 * log(x));
}
}
}
Messung V0.5 in Prozent C=94 H=94 G=93
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-10)
¤
*© Formatika GbR, Deutschland