/* ei.c
*
* Exponential integral
*
*
* SYNOPSIS :
*
* double x , y , ei ( ) ;
*
* y = ei ( x ) ;
*
*
*
* DESCRIPTION :
*
* x
* - t
* | | e
* Ei ( x ) = - | - - - - dt .
* | | t
* -
* - inf
*
* Not defined for x < = 0 .
* See also expn . c .
*
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE 0 , 100 50000 8 . 6 e - 16 1 . 3 e - 16
*
*/
/*
Cephes Math Library Release 2 . 8 : May , 1999
Copyright 1999 by Stephen L . Moshier
*/
#include "mconf.h"
#ifdef ANSIPROT
extern double log(double );
extern double exp(double );
extern double polevl(double , void *, int );
extern double p1evl(double , void *, int );
#else
extern double log(), exp(), polevl(), p1evl();
#endif
#define EUL 5 .772156649015328606065 e-1
/* 0 < x <= 2
Ei ( x ) - EUL - ln ( x ) = x A ( x ) / B ( x )
Theoretical peak relative error 9.73e-18 */
#if UNK
static double A[6 ] = {
-5 .350447357812542947283 E0, 2 .185049168816613393830 E2,
-4 .176572384826693777058 E3, 5 .541176756393557601232 E4,
-3 .313381331178144034309 E5, 1 .592627163384945414220 E6,
};
static double B[6 ] = {
/* 1.000000000000000000000E0, */
-5 .250547959112862969197 E1, 1 .259616186786790571525 E3,
-1 .756549581973534652631 E4, 1 .493062117002725991967 E5,
-7 .294949239640527645655 E5, 1 .592627163384945429726 E6,
};
#endif
#if DEC
static short A[24 ] = {
0140653 , 0033335 , 0060230 , 0144217 , 0042132 , 0100502 , 0035625 , 0167413 ,
0143202 , 0102224 , 0037176 , 0175403 , 0044130 , 0071704 , 0077421 , 0170343 ,
0144641 , 0144504 , 0041200 , 0045154 , 0045302 , 0064631 , 0047234 , 0142052 ,
};
static short B[24 ] = {
/* 0040200,0000000,0000000,0000000, */
0141522 , 0002634 , 0070442 , 0142614 , 0042635 , 0071667 , 0146532 , 0027705 ,
0143611 , 0035375 , 0156025 , 0114015 , 0044421 , 0147215 , 0106177 , 0046330 ,
0145062 , 0014556 , 0144216 , 0103725 , 0045302 , 0064631 , 0047234 , 0142052 ,
};
#endif
#if IBMPC
static short A[24 ] = {
0 x1912, 0 xac13, 0 x66db, 0 xc015, 0 xbde1, 0 x4772, 0 x5028, 0 x406b,
0 xdf60, 0 x87cf, 0 x5092, 0 xc0b0, 0 x3e1c, 0 x8fe2, 0 x0e78, 0 x40eb,
0 x094e, 0 x8850, 0 x3928, 0 xc114, 0 x9885, 0 x29d3, 0 x4d33, 0 x4138,
};
static short B[24 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 x58b1, 0 x8e24, 0 x40b3, 0 xc04a, 0 x45f9, 0 xf9ab, 0 xae76, 0 x4093,
0 xb302, 0 xbb82, 0 x275f, 0 xc0d1, 0 xe99b, 0 xb18f, 0 x39d1, 0 x4102,
0 xd0fb, 0 xd911, 0 x432d, 0 xc126, 0 x9885, 0 x29d3, 0 x4d33, 0 x4138,
};
#endif
#if MIEEE
static short A[24 ] = {
0 xc015, 0 x66db, 0 xac13, 0 x1912, 0 x406b, 0 x5028, 0 x4772, 0 xbde1,
0 xc0b0, 0 x5092, 0 x87cf, 0 xdf60, 0 x40eb, 0 x0e78, 0 x8fe2, 0 x3e1c,
0 xc114, 0 x3928, 0 x8850, 0 x094e, 0 x4138, 0 x4d33, 0 x29d3, 0 x9885,
};
static short B[24 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xc04a, 0 x40b3, 0 x8e24, 0 x58b1, 0 x4093, 0 xae76, 0 xf9ab, 0 x45f9,
0 xc0d1, 0 x275f, 0 xbb82, 0 xb302, 0 x4102, 0 x39d1, 0 xb18f, 0 xe99b,
0 xc126, 0 x432d, 0 xd911, 0 xd0fb, 0 x4138, 0 x4d33, 0 x29d3, 0 x9885,
};
#endif
#if 0
/* 0 < x <= 4
Ei ( x ) - EUL - ln ( x ) = x A ( x ) / B ( x )
Theoretical peak relative error 4.75e-17 */
#if UNK
static double A[7 ] = {
-6 .831869820732773831942 E0,
2 .920190530726774500309 E2,
-1 .195883839286649567993 E4,
1 .761045255472548975666 E5,
-2 .623034438354006526979 E6,
1 .472430336917880803157 E7,
-8 .205359388213261174960 E7,
};
static double B[7 ] = {
/* 1.000000000000000000000E0, */
-7 .731946237840033971071 E1,
2 .751808700543578450827 E3,
-5 .829268609072186897994 E4,
7 .916610857961870631379 E5,
-6 .873926904825733094076 E6,
3 .523770183971164032710 E7,
-8 .205359388213260785363 E7,
};
#endif
#if DEC
static short A[28 ] = {
0140732 ,0117255 ,0072522 ,0071743 ,
0042222 ,0001160 ,0052302 ,0002334 ,
0143472 ,0155532 ,0101650 ,0155462 ,
0044453 ,0175041 ,0121220 ,0172022 ,
0145440 ,0014351 ,0140337 ,0157550 ,
0046140 ,0126317 ,0057202 ,0100233 ,
0146634 ,0100473 ,0036072 ,0067054 ,
};
static short B[28 ] = {
/* 0040200,0000000,0000000,0000000, */
0141632 ,0121620 ,0111247 ,0010115 ,
0043053 ,0176360 ,0067773 ,0027324 ,
0144143 ,0132257 ,0121644 ,0036204 ,
0045101 ,0043321 ,0057553 ,0151231 ,
0145721 ,0143215 ,0147505 ,0050610 ,
0046406 ,0065721 ,0072675 ,0152744 ,
0146634 ,0100473 ,0036072 ,0067052 ,
};
#endif
#if IBMPC
static short A[28 ] = {
0 x4e7c,0 xaeaa,0 x53d5,0 xc01b,
0 x409b,0 x0a98,0 x404e,0 x4072,
0 x1b66,0 x5075,0 x5b6b,0 xc0c7,
0 x1e82,0 x3452,0 x7f44,0 x4105,
0 xfbed,0 x381b,0 x031d,0 xc144,
0 x5013,0 xebd0,0 x1599,0 x416c,
0 x4dc5,0 x6787,0 x9027,0 xc193,
};
static short B[28 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xe20a,0 x1254,0 x5472,0 xc053,
0 x65db,0 x0dff,0 x7f9e,0 x40a5,
0 x8791,0 xf474,0 x7695,0 xc0ec,
0 x7a53,0 x2bed,0 x28da,0 x4128,
0 xaa31,0 xb9e8,0 x38d1,0 xc15a,
0 xbabd,0 x2eb7,0 xcd7a,0 x4180,
0 x4dc5,0 x6787,0 x9027,0 xc193,
};
#endif
#if MIEEE
static short A[28 ] = {
0 xc01b,0 x53d5,0 xaeaa,0 x4e7c,
0 x4072,0 x404e,0 x0a98,0 x409b,
0 xc0c7,0 x5b6b,0 x5075,0 x1b66,
0 x4105,0 x7f44,0 x3452,0 x1e82,
0 xc144,0 x031d,0 x381b,0 xfbed,
0 x416c,0 x1599,0 xebd0,0 x5013,
0 xc193,0 x9027,0 x6787,0 x4dc5,
};
static short B[28 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xc053,0 x5472,0 x1254,0 xe20a,
0 x40a5,0 x7f9e,0 x0dff,0 x65db,
0 xc0ec,0 x7695,0 xf474,0 x8791,
0 x4128,0 x28da,0 x2bed,0 x7a53,
0 xc15a,0 x38d1,0 xb9e8,0 xaa31,
0 x4180,0 xcd7a,0 x2eb7,0 xbabd,
0 xc193,0 x9027,0 x6787,0 x4dc5,
};
#endif
#endif /* 0 */
#if 0
/* 0 < x <= 8
Ei ( x ) - EUL - ln ( x ) = x A ( x ) / B ( x )
Theoretical peak relative error 2.14e-17 */
#if UNK
static double A[9 ] = {
-1 .111230942210860450145 E1,
3 .688203982071386319616 E2,
-4 .924786153494029574350 E4,
1 .050677503345557903241 E6,
-3 .626713709916703688968 E7,
4 .353499908839918635414 E8,
-6 .454613717232006895409 E9,
3 .408243056457762907071 E10,
-1 .995466674647028468613 E11,
};
static double B[9 ] = {
/* 1.000000000000000000000E0, */
-1 .356757648138514017969 E2,
8 .562181317107341736606 E3,
-3 .298257180413775117555 E5,
8 .543534058481435917210 E6,
-1 .542380618535140055068 E8,
1 .939251779195993632028 E9,
-1 .636096210465615015435 E10,
8 .396909743075306970605 E10,
-1 .995466674647028425886 E11,
};
#endif
#if DEC
static short A[36 ] = {
0141061 ,0146004 ,0173357 ,0151553 ,
0042270 ,0064402 ,0147366 ,0126701 ,
0144100 ,0057734 ,0106615 ,0144356 ,
0045200 ,0040654 ,0003332 ,0004456 ,
0146412 ,0054440 ,0043130 ,0140263 ,
0047317 ,0113517 ,0033422 ,0065123 ,
0150300 ,0056313 ,0065235 ,0131147 ,
0050775 ,0167423 ,0146222 ,0075760 ,
0151471 ,0153642 ,0003442 ,0147667 ,
};
static short B[36 ] = {
/* 0040200,0000000,0000000,0000000, */
0142007 ,0126376 ,0166077 ,0043600 ,
0043405 ,0144271 ,0125461 ,0014364 ,
0144641 ,0006066 ,0175061 ,0164463 ,
0046002 ,0056456 ,0007370 ,0121657 ,
0147023 ,0013706 ,0156647 ,0177115 ,
0047747 ,0026504 ,0103144 ,0054507 ,
0150563 ,0146036 ,0007051 ,0177135 ,
0051234 ,0063625 ,0173266 ,0003111 ,
0151471 ,0153642 ,0003442 ,0147666 ,
};
#endif
#if IBMPC
static short A[36 ] = {
0 xfa6d,0 x9edd,0 x3980,0 xc026,
0 xd5b8,0 x59de,0 x0d20,0 x4077,
0 xb91e,0 x91b1,0 x0bfb,0 xc0e8,
0 x4126,0 x80db,0 x0835,0 x4130,
0 x1816,0 x08cb,0 x4b24,0 xc181,
0 x4d4a,0 xe6e2,0 xf2e9,0 x41b9,
0 xb64d,0 x6d53,0 x0b99,0 xc1f8,
0 x4f7e,0 x7992,0 xbde2,0 x421f,
0 x59f7,0 x40e4,0 x3af4,0 xc247,
};
static short B[36 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xe8f0,0 xdd87,0 xf59f,0 xc060,
0 x231e,0 x3566,0 xb917,0 x40c0,
0 x3d26,0 xdf46,0 x2186,0 xc114,
0 x1476,0 xc1df,0 x4ba5,0 x4160,
0 xffca,0 xdbb4,0 x62f8,0 xc1a2,
0 x8b29,0 x90cc,0 xe5a8,0 x41dc,
0 x3fcc,0 xc1c5,0 x7983,0 xc20e,
0 xc0c9,0 xbed6,0 x8cf2,0 x4233,
0 x59f7,0 x40e4,0 x3af4,0 xc247,
};
#endif
#if MIEEE
static short A[36 ] = {
0 xc026,0 x3980,0 x9edd,0 xfa6d,
0 x4077,0 x0d20,0 x59de,0 xd5b8,
0 xc0e8,0 x0bfb,0 x91b1,0 xb91e,
0 x4130,0 x0835,0 x80db,0 x4126,
0 xc181,0 x4b24,0 x08cb,0 x1816,
0 x41b9,0 xf2e9,0 xe6e2,0 x4d4a,
0 xc1f8,0 x0b99,0 x6d53,0 xb64d,
0 x421f,0 xbde2,0 x7992,0 x4f7e,
0 xc247,0 x3af4,0 x40e4,0 x59f7,
};
static short B[36 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xc060,0 xf59f,0 xdd87,0 xe8f0,
0 x40c0,0 xb917,0 x3566,0 x231e,
0 xc114,0 x2186,0 xdf46,0 x3d26,
0 x4160,0 x4ba5,0 xc1df,0 x1476,
0 xc1a2,0 x62f8,0 xdbb4,0 xffca,
0 x41dc,0 xe5a8,0 x90cc,0 x8b29,
0 xc20e,0 x7983,0 xc1c5,0 x3fcc,
0 x4233,0 x8cf2,0 xbed6,0 xc0c9,
0 xc247,0 x3af4,0 x40e4,0 x59f7,
};
#endif
#endif /* 0 */
/* 8 <= x <= 20
x exp ( - x ) Ei ( x ) - 1 = 1 / x R ( 1 / x )
Theoretical peak absolute error = 1.07e-17 */
#if UNK
static double A2[10 ] = {
-2 .106934601691916512584 E0, 1 .732733869664688041885 E0,
-2 .423619178935841904839 E-1 , 2 .322724180937565842585 E-2 ,
2 .372880440493179832059 E-4 , -8 .343219561192552752335 E-5 ,
1 .363408795605250394881 E-5 , -3 .655412321999253963714 E-7 ,
1 .464941733975961318456 E-8 , 6 .176407863710360207074 E-10 ,
};
static double B2[9 ] = {
/* 1.000000000000000000000E0, */
-2 .298062239901678075778 E-1 , 1 .105077041474037862347 E-1 ,
-1 .566542966630792353556 E-2 , 2 .761106850817352773874 E-3 ,
-2 .089148012284048449115 E-4 , 1 .708528938807675304186 E-5 ,
-4 .459311796356686423199 E-7 , 1 .394634930353847498145 E-8 ,
6 .150865933977338354138 E-10 ,
};
#endif
#if DEC
static short A2[40 ] = {
0140406 , 0154004 , 0035104 , 0173336 , 0040335 , 0145071 , 0031560 , 0150165 ,
0137570 , 0026670 , 0176230 , 0055040 , 0036676 , 0043416 , 0077122 , 0054476 ,
0035170 , 0150206 , 0034407 , 0175571 , 0134656 , 0174121 , 0123231 , 0021751 ,
0034144 , 0136766 , 0036746 , 0121115 , 0132704 , 0037632 , 0135077 , 0107300 ,
0031573 , 0126321 , 0117076 , 0004314 , 0030451 , 0143233 , 0041352 , 0172464 ,
};
static short B2[36 ] = {
/* 0040200,0000000,0000000,0000000, */
0137553 , 0051122 , 0120721 , 0170437 , 0037342 , 0050734 , 0175047 , 0032132 ,
0136600 , 0052311 , 0101406 , 0147050 , 0036064 , 0171657 , 0120001 , 0071165 ,
0135133 , 0010043 , 0151244 , 0066340 , 0034217 , 0051141 , 0026115 , 0043305 ,
0132757 , 0064120 , 0106341 , 0051217 , 0031557 , 0114261 , 0060663 , 0135017 ,
0030451 , 0011337 , 0001344 , 0175542 ,
};
#endif
#if IBMPC
static short A2[40 ] = {
0 x9edc, 0 x8748, 0 xdb00, 0 xc000, 0 x1a0f, 0 x266e, 0 xb947, 0 x3ffb,
0 x0b44, 0 x1f93, 0 x05b7, 0 xbfcf, 0 x4b28, 0 xcfca, 0 xc8e1, 0 x3f97,
0 xff6f, 0 xc720, 0 x1a10, 0 x3f2f, 0 x247d, 0 x34d3, 0 xdf0a, 0 xbf15,
0 xd44a, 0 xc7bc, 0 x97be, 0 x3eec, 0 xf1d8, 0 x5747, 0 x87f3, 0 xbe98,
0 xc119, 0 x33c7, 0 x759a, 0 x3e4f, 0 x5ea6, 0 x685d, 0 x38d3, 0 x3e05,
};
static short B2[36 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 x3e24, 0 x543a, 0 x6a4a, 0 xbfcd, 0 xe68b, 0 x9f44, 0 x4a3b, 0 x3fbc, 0 xd9c5,
0 x3060, 0 x0a99, 0 xbf90, 0 x2e4f, 0 xf400, 0 x9e75, 0 x3f66, 0 x8d9c, 0 x7a54,
0 x6204, 0 xbf2b, 0 xa8d9, 0 x2589, 0 xea4c, 0 x3ef1, 0 x2a52, 0 x119c, 0 xed0a,
0 xbe9d, 0 x7742, 0 x2c36, 0 xf316, 0 x3e4d, 0 x9f6c, 0 xe05c, 0 x225b, 0 x3e05,
};
#endif
#if MIEEE
static short A2[40 ] = {
0 xc000, 0 xdb00, 0 x8748, 0 x9edc, 0 x3ffb, 0 xb947, 0 x266e, 0 x1a0f,
0 xbfcf, 0 x05b7, 0 x1f93, 0 x0b44, 0 x3f97, 0 xc8e1, 0 xcfca, 0 x4b28,
0 x3f2f, 0 x1a10, 0 xc720, 0 xff6f, 0 xbf15, 0 xdf0a, 0 x34d3, 0 x247d,
0 x3eec, 0 x97be, 0 xc7bc, 0 xd44a, 0 xbe98, 0 x87f3, 0 x5747, 0 xf1d8,
0 x3e4f, 0 x759a, 0 x33c7, 0 xc119, 0 x3e05, 0 x38d3, 0 x685d, 0 x5ea6,
};
static short B2[36 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xbfcd, 0 x6a4a, 0 x543a, 0 x3e24, 0 x3fbc, 0 x4a3b, 0 x9f44, 0 xe68b, 0 xbf90,
0 x0a99, 0 x3060, 0 xd9c5, 0 x3f66, 0 x9e75, 0 xf400, 0 x2e4f, 0 xbf2b, 0 x6204,
0 x7a54, 0 x8d9c, 0 x3ef1, 0 xea4c, 0 x2589, 0 xa8d9, 0 xbe9d, 0 xed0a, 0 x119c,
0 x2a52, 0 x3e4d, 0 xf316, 0 x2c36, 0 x7742, 0 x3e05, 0 x225b, 0 xe05c, 0 x9f6c,
};
#endif
/* x > 20
x exp ( - x ) Ei ( x ) - 1 = 1 / x A3 ( 1 / x ) / B3 ( 1 / x )
Theoretical absolute error = 6.15e-17 */
#if UNK
static double A3[9 ] = {
-7 .657847078286127362028 E-1 , 6 .886192415566705051750 E-1 ,
-2 .132598113545206124553 E-1 , 3 .346107552384193813594 E-2 ,
-3 .076541477344756050249 E-3 , 1 .747119316454907477380 E-4 ,
-6 .103711682274170530369 E-6 , 1 .218032765428652199087 E-7 ,
-1 .086076102793290233007 E-9 ,
};
static double B3[9 ] = {
/* 1.000000000000000000000E0, */
-1 .888802868662308731041 E0, 1 .066691687211408896850 E0,
-2 .751915982306380647738 E-1 , 3 .930852688233823569726 E-2 ,
-3 .414684558602365085394 E-3 , 1 .866844370703555398195 E-4 ,
-6 .345146083130515357861 E-6 , 1 .239754287483206878024 E-7 ,
-1 .086076102793126632978 E-9 ,
};
#endif
#if DEC
static short A3[36 ] = {
0140104 , 0005167 , 0071746 , 0115510 , 0040060 , 0044531 , 0140741 , 0154556 ,
0137532 , 0060307 , 0126506 , 0071123 , 0037011 , 0007173 , 0010405 , 0127224 ,
0136111 , 0117715 , 0003654 , 0175577 , 0035067 , 0031340 , 0102657 , 0147714 ,
0133714 , 0147173 , 0167473 , 0136640 , 0032402 , 0144407 , 0115547 , 0060114 ,
0130625 , 0042347 , 0156431 , 0113425 ,
};
static short B3[36 ] = {
/* 0040200,0000000,0000000,0000000, */
0140361 , 0142112 , 0155277 , 0067714 , 0040210 , 0104532 , 0065676 , 0074326 ,
0137614 , 0162751 , 0142421 , 0131033 , 0037041 , 0000772 , 0053236 , 0002632 ,
0136137 , 0144346 , 0100536 , 0153136 , 0035103 , 0140270 , 0152211 , 0166215 ,
0133724 , 0164143 , 0145763 , 0021153 , 0032405 , 0017033 , 0035333 , 0025736 ,
0130625 , 0042347 , 0156431 , 0077134 ,
};
#endif
#if IBMPC
static short A3[36 ] = {
0 xd369, 0 xee7c, 0 x814e, 0 xbfe8, 0 x3b2e, 0 x383c, 0 x092b, 0 x3fe6, 0 xce4a,
0 xf5a8, 0 x4c18, 0 xbfcb, 0 xb5d2, 0 x6220, 0 x21cf, 0 x3fa1, 0 x9f70, 0 xa0f5,
0 x33f9, 0 xbf69, 0 xf9f9, 0 x10b5, 0 xe65c, 0 x3f26, 0 x77b4, 0 x7de7, 0 x99cf,
0 xbed9, 0 xec09, 0 xf36c, 0 x5920, 0 x3e80, 0 x32e3, 0 xfba3, 0 xa89c, 0 xbe12,
};
static short B3[36 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xedf9, 0 x5b57, 0 x3889, 0 xbffe, 0 xcf1b, 0 x4d77, 0 x112b, 0 x3ff1, 0 x3643,
0 x38a2, 0 x9cbd, 0 xbfd1, 0 xc0b3, 0 x4ad3, 0 x203f, 0 x3fa4, 0 xdacc, 0 xd02b,
0 xf91c, 0 xbf6b, 0 x3d92, 0 x1a91, 0 x7817, 0 x3f28, 0 x644d, 0 x797e, 0 x9d0c,
0 xbeda, 0 x657c, 0 x675b, 0 xa3c3, 0 x3e80, 0 x2fcb, 0 xfba3, 0 xa89c, 0 xbe12,
};
#endif
#if MIEEE
static short A3[36 ] = {
0 xbfe8, 0 x814e, 0 xee7c, 0 xd369, 0 x3fe6, 0 x092b, 0 x383c, 0 x3b2e, 0 xbfcb,
0 x4c18, 0 xf5a8, 0 xce4a, 0 x3fa1, 0 x21cf, 0 x6220, 0 xb5d2, 0 xbf69, 0 x33f9,
0 xa0f5, 0 x9f70, 0 x3f26, 0 xe65c, 0 x10b5, 0 xf9f9, 0 xbed9, 0 x99cf, 0 x7de7,
0 x77b4, 0 x3e80, 0 x5920, 0 xf36c, 0 xec09, 0 xbe12, 0 xa89c, 0 xfba3, 0 x32e3,
};
static short B3[36 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xbffe, 0 x3889, 0 x5b57, 0 xedf9, 0 x3ff1, 0 x112b, 0 x4d77, 0 xcf1b, 0 xbfd1,
0 x9cbd, 0 x38a2, 0 x3643, 0 x3fa4, 0 x203f, 0 x4ad3, 0 xc0b3, 0 xbf6b, 0 xf91c,
0 xd02b, 0 xdacc, 0 x3f28, 0 x7817, 0 x1a91, 0 x3d92, 0 xbeda, 0 x9d0c, 0 x797e,
0 x644d, 0 x3e80, 0 xa3c3, 0 x675b, 0 x657c, 0 xbe12, 0 xa89c, 0 xfba3, 0 x2fcb,
};
#endif
/* 16 <= x <= 32
x exp ( - x ) Ei ( x ) - 1 = 1 / x A4 ( 1 / x ) / B4 ( 1 / x )
Theoretical absolute error = 1.22e-17 */
#if UNK
static double A4[8 ] = {
-2 .458119367674020323359 E-1 , -1 .483382253322077687183 E-1 ,
7 .248291795735551591813 E-2 , -1 .348315687380940523823 E-2 ,
1 .342775069788636972294 E-3 , -7 .942465637159712264564 E-5 ,
2 .644179518984235952241 E-6 , -4 .239473659313765177195 E-8 ,
};
static double B4[8 ] = {
/* 1.000000000000000000000E0, */
-1 .044225908443871106315 E-1 , -2 .676453128101402655055 E-1 ,
9 .695000254621984627876 E-2 , -1 .601745692712991078208 E-2 ,
1 .496414899205908021882 E-3 , -8 .462452563778485013756 E-5 ,
2 .728938403476726394024 E-6 , -4 .239462431819542051337 E-8 ,
};
#endif
#if DEC
static short A4[32 ] = {
0137573 , 0133037 , 0152607 , 0113356 , 0137427 , 0162771 , 0145061 , 0126345 ,
0037224 , 0070754 , 0110451 , 0174104 , 0136534 , 0164165 , 0072170 , 0063753 ,
0035660 , 0000016 , 0002560 , 0147751 , 0134646 , 0110311 , 0123316 , 0047432 ,
0033461 , 0071250 , 0101031 , 0075202 , 0132066 , 0012601 , 0077305 , 0170177 ,
};
static short B4[32 ] = {
/* 0040200,0000000,0000000,0000000, */
0137325 , 0155602 , 0162437 , 0030710 , 0137611 , 0004316 , 0071344 , 0176361 ,
0037306 , 0106671 , 0011103 , 0155053 , 0136603 , 0033412 , 0132530 , 0175171 ,
0035704 , 0021532 , 0015516 , 0166130 , 0134661 , 0074162 , 0036741 , 0073466 ,
0033467 , 0021316 , 0003100 , 0171325 , 0132066 , 0012541 , 0162202 , 0150160 ,
};
#endif
#if IBMPC
static short A4[] = {
0 xf2de, 0 xfab0, 0 x76c3, 0 xbfcf, 0 x359d, 0 x3946, 0 xfcbf, 0 xbfc2,
0 x3f09, 0 x9225, 0 x8e3d, 0 x3fb2, 0 x0cfd, 0 xae8f, 0 x9d0e, 0 xbf8b,
0 x19fd, 0 xc0ae, 0 x0001, 0 x3f56, 0 xc9e3, 0 x34d9, 0 xd219, 0 xbf14,
0 x2f50, 0 x1043, 0 x2e55, 0 x3ec6, 0 xbe10, 0 x2fd8, 0 xc2b0, 0 xbe66,
};
static short B4[] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xe639, 0 x5ca3, 0 xbb70, 0 xbfba, 0 x9f9e, 0 xce5c, 0 x2119, 0 xbfd1,
0 x7b45, 0 x2248, 0 xd1b7, 0 x3fb8, 0 x1f4f, 0 x56ab, 0 x66e1, 0 xbf90,
0 xdd8b, 0 x4369, 0 x846b, 0 x3f58, 0 x2ee7, 0 x47bc, 0 x2f0e, 0 xbf16,
0 x1e5b, 0 xc0c8, 0 xe459, 0 x3ec6, 0 x5a0e, 0 x3c90, 0 xc2ac, 0 xbe66,
};
#endif
#if MIEEE
static short A4[32 ] = {
0 xbfcf, 0 x76c3, 0 xfab0, 0 xf2de, 0 xbfc2, 0 xfcbf, 0 x3946, 0 x359d,
0 x3fb2, 0 x8e3d, 0 x9225, 0 x3f09, 0 xbf8b, 0 x9d0e, 0 xae8f, 0 x0cfd,
0 x3f56, 0 x0001, 0 xc0ae, 0 x19fd, 0 xbf14, 0 xd219, 0 x34d9, 0 xc9e3,
0 x3ec6, 0 x2e55, 0 x1043, 0 x2f50, 0 xbe66, 0 xc2b0, 0 x2fd8, 0 xbe10,
};
static short B4[32 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xbfba, 0 xbb70, 0 x5ca3, 0 xe639, 0 xbfd1, 0 x2119, 0 xce5c, 0 x9f9e,
0 x3fb8, 0 xd1b7, 0 x2248, 0 x7b45, 0 xbf90, 0 x66e1, 0 x56ab, 0 x1f4f,
0 x3f58, 0 x846b, 0 x4369, 0 xdd8b, 0 xbf16, 0 x2f0e, 0 x47bc, 0 x2ee7,
0 x3ec6, 0 xe459, 0 xc0c8, 0 x1e5b, 0 xbe66, 0 xc2ac, 0 x3c90, 0 x5a0e,
};
#endif
#if 0
/* 20 <= x <= 40
x exp ( - x ) Ei ( x ) - 1 = 1 / x A4 ( 1 / x ) / B4 ( 1 / x )
Theoretical absolute error = 1.78e-17 */
#if UNK
static double A4[8 ] = {
2 .067245813525780707978 E-1 ,
-5 .153749551345223645670 E-1 ,
1 .928289589546695033096 E-1 ,
-3 .124468842857260044075 E-2 ,
2 .740283734277352539912 E-3 ,
-1 .377775664366875175601 E-4 ,
3 .803788980664744242323 E-6 ,
-4 .611038277393688031154 E-8 ,
};
static double B4[8 ] = {
/* 1.000000000000000000000E0, */
-8 .544436025219516861531 E-1 ,
2 .507436807692907385181 E-1 ,
-3 .647688090228423114064 E-2 ,
3 .008576950332041388892 E-3 ,
-1 .452926405348421286334 E-4 ,
3 .896007735260115431965 E-6 ,
-4 .611037642697098234083 E-8 ,
};
#endif
#if DEC
static short A4[32 ] = {
0037523 ,0127633 ,0150301 ,0022031 ,
0140003 ,0167634 ,0170572 ,0170420 ,
0037505 ,0072364 ,0060672 ,0063220 ,
0136777 ,0172334 ,0057456 ,0102640 ,
0036063 ,0113125 ,0002476 ,0047251 ,
0135020 ,0074142 ,0042600 ,0043630 ,
0033577 ,0042230 ,0155372 ,0136105 ,
0132106 ,0005346 ,0165333 ,0114541 ,
};
static short B4[28 ] = {
/* 0040200,0000000,0000000,0000000, */
0140132 ,0136320 ,0160433 ,0131535 ,
0037600 ,0060571 ,0144452 ,0060214 ,
0137025 ,0064310 ,0024220 ,0176472 ,
0036105 ,0025613 ,0115762 ,0166605 ,
0135030 ,0054662 ,0035454 ,0061763 ,
0033602 ,0135163 ,0116430 ,0000066 ,
0132106 ,0005345 ,0020602 ,0137133 ,
};
#endif
#if IBMPC
static short A4[32 ] = {
0 x2483,0 x7a18,0 x75f3,0 x3fca,
0 x5e22,0 x9e2f,0 x7df3,0 xbfe0,
0 x4cd2,0 x8c37,0 xae9e,0 x3fc8,
0 xd0b4,0 x8be5,0 xfe9b,0 xbf9f,
0 xc9d5,0 xa0a7,0 x72ca,0 x3f66,
0 x08f3,0 x48b0,0 x0f0c,0 xbf22,
0 x5789,0 x1b5f,0 xe893,0 x3ecf,
0 x732c,0 xdd5b,0 xc15c,0 xbe68,
};
static short B4[28 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 x766c,0 x1c23,0 x579a,0 xbfeb,
0 x4c11,0 x3925,0 x0c2f,0 x3fd0,
0 x1fa7,0 x0512,0 xad19,0 xbfa2,
0 x5db1,0 x737e,0 xa571,0 x3f68,
0 x8c7e,0 x4765,0 x0b36,0 xbf23,
0 x0007,0 x73a3,0 x574e,0 x3ed0,
0 x57cb,0 xa430,0 xc15c,0 xbe68,
};
#endif
#if MIEEE
static short A4[32 ] = {
0 x3fca,0 x75f3,0 x7a18,0 x2483,
0 xbfe0,0 x7df3,0 x9e2f,0 x5e22,
0 x3fc8,0 xae9e,0 x8c37,0 x4cd2,
0 xbf9f,0 xfe9b,0 x8be5,0 xd0b4,
0 x3f66,0 x72ca,0 xa0a7,0 xc9d5,
0 xbf22,0 x0f0c,0 x48b0,0 x08f3,
0 x3ecf,0 xe893,0 x1b5f,0 x5789,
0 xbe68,0 xc15c,0 xdd5b,0 x732c,
};
static short B4[28 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xbfeb,0 x579a,0 x1c23,0 x766c,
0 x3fd0,0 x0c2f,0 x3925,0 x4c11,
0 xbfa2,0 xad19,0 x0512,0 x1fa7,
0 x3f68,0 xa571,0 x737e,0 x5db1,
0 xbf23,0 x0b36,0 x4765,0 x8c7e,
0 x3ed0,0 x574e,0 x73a3,0 x0007,
0 xbe68,0 xc15c,0 xa430,0 x57cb,
};
#endif
#endif /* 0 */
/* 4 <= x <= 8
x exp ( - x ) Ei ( x ) - 1 = 1 / x A5 ( 1 / x ) / B5 ( 1 / x )
Theoretical absolute error = 2.20e-17 */
#if UNK
static double A5[8 ] = {
-1 .373215375871208729803 E0, -7 .084559133740838761406 E-1 ,
1 .580806855547941010501 E0, -2 .601500427425622944234 E-1 ,
2 .994674694113713763365 E-2 , -1 .038086040188744005513 E-3 ,
4 .371064420753005429514 E-5 , 2 .141783679522602903795 E-6 ,
};
static double B5[8 ] = {
/* 1.000000000000000000000E0, */
8 .585231423622028380768 E-1 , 4 .483285822873995129957 E-1 ,
7 .687932158124475434091 E-2 , 2 .449868241021887685904 E-2 ,
8 .832165941927796567926 E-4 , 4 .590952299511353531215 E-4 ,
-4 .729848351866523044863 E-6 , 2 .665195537390710170105 E-6 ,
};
#endif
#if DEC
static short A5[32 ] = {
0140257 , 0142605 , 0076335 , 0113632 , 0140065 , 0056535 , 0161231 , 0074311 ,
0040312 , 0053741 , 0004357 , 0076405 , 0137605 , 0031142 , 0165503 , 0136705 ,
0036765 , 0051341 , 0053573 , 0007602 , 0135610 , 0010143 , 0027643 , 0110522 ,
0034467 , 0052762 , 0062024 , 0120161 , 0033417 , 0135620 , 0036500 , 0062647 ,
};
static short B[32 ] = {
/* 0040200,0000000,0000000,0000000, */
0040133 , 0144054 , 0031516 , 0004100 , 0037745 , 0105522 , 0166622 , 0123146 ,
0037235 , 0071347 , 0157560 , 0157464 , 0036710 , 0130565 , 0173747 , 0041670 ,
0035547 , 0103651 , 0106243 , 0101240 , 0035360 , 0131267 , 0176263 , 0140257 ,
0133636 , 0132426 , 0102537 , 0102531 , 0033462 , 0155665 , 0167503 , 0176350 ,
};
#endif
#if IBMPC
static short A5[32 ] = {
0 xb2f3, 0 xaf9b, 0 xf8b0, 0 xbff5, 0 x2f19, 0 xbc53, 0 xabab, 0 xbfe6,
0 xefa1, 0 x211d, 0 x4afc, 0 x3ff9, 0 x77b9, 0 x5d68, 0 xa64c, 0 xbfd0,
0 x61f0, 0 x2aef, 0 xaa5c, 0 x3f9e, 0 x722a, 0 x65f4, 0 x020c, 0 xbf51,
0 x940e, 0 x4c82, 0 xeabe, 0 x3f06, 0 x0cb5, 0 x07a8, 0 xf772, 0 x3ec1,
};
static short B5[32 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xc108, 0 x8669, 0 x7905, 0 x3feb, 0 x54cd, 0 x5db2, 0 xb16a, 0 x3fdc,
0 x1be7, 0 xfbee, 0 xae5c, 0 x3fb3, 0 xe877, 0 xbefc, 0 x162e, 0 x3f99,
0 x7054, 0 x3194, 0 xf0f5, 0 x3f4c, 0 x7816, 0 xff96, 0 x1656, 0 x3f3e,
0 xf0ab, 0 xd0ab, 0 xd6a2, 0 xbed3, 0 x7f9d, 0 xbde8, 0 x5b76, 0 x3ec6,
};
#endif
#if MIEEE
static short A5[32 ] = {
0 xbff5, 0 xf8b0, 0 xaf9b, 0 xb2f3, 0 xbfe6, 0 xabab, 0 xbc53, 0 x2f19,
0 x3ff9, 0 x4afc, 0 x211d, 0 xefa1, 0 xbfd0, 0 xa64c, 0 x5d68, 0 x77b9,
0 x3f9e, 0 xaa5c, 0 x2aef, 0 x61f0, 0 xbf51, 0 x020c, 0 x65f4, 0 x722a,
0 x3f06, 0 xeabe, 0 x4c82, 0 x940e, 0 x3ec1, 0 xf772, 0 x07a8, 0 x0cb5,
};
static short B5[32 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 x3feb, 0 x7905, 0 x8669, 0 xc108, 0 x3fdc, 0 xb16a, 0 x5db2, 0 x54cd,
0 x3fb3, 0 xae5c, 0 xfbee, 0 x1be7, 0 x3f99, 0 x162e, 0 xbefc, 0 xe877,
0 x3f4c, 0 xf0f5, 0 x3194, 0 x7054, 0 x3f3e, 0 x1656, 0 xff96, 0 x7816,
0 xbed3, 0 xd6a2, 0 xd0ab, 0 xf0ab, 0 x3ec6, 0 x5b76, 0 xbde8, 0 x7f9d,
};
#endif
/* 2 <= x <= 4
x exp ( - x ) Ei ( x ) - 1 = 1 / x A6 ( 1 / x ) / B6 ( 1 / x )
Theoretical absolute error = 4.89e-17 */
#if UNK
static double A6[8 ] = {
1 .981808503259689673238 E-2 , -1 .271645625984917501326 E0,
-2 .088160335681228318920 E0, 2 .755544509187936721172 E0,
-4 .409507048701600257171 E-1 , 4 .665623805935891391017 E-2 ,
-1 .545042679673485262580 E-3 , 7 .059980605299617478514 E-5 ,
};
static double B6[7 ] = {
/* 1.000000000000000000000E0, */
1 .476498670914921440652 E0, 5 .629177174822436244827 E-1 ,
1 .699017897879307263248 E-1 , 2 .291647179034212017463 E-2 ,
4 .450150439728752875043 E-3 , 1 .727439612206521482874 E-4 ,
3 .953167195549672482304 E-5 ,
};
#endif
#if DEC
static short A6[32 ] = {
0036642 , 0054611 , 0061263 , 0000140 , 0140242 , 0142510 , 0125732 , 0072035 ,
0140405 , 0122153 , 0037643 , 0104527 , 0040460 , 0055327 , 0055550 , 0116240 ,
0137741 , 0142112 , 0070441 , 0103510 , 0037077 , 0015234 , 0104750 , 0146765 ,
0135712 , 0101407 , 0107554 , 0020253 , 0034624 , 0007373 , 0072621 , 0063735 ,
};
static short B6[28 ] = {
/* 0040200,0000000,0000000,0000000, */
0040274 , 0176750 , 0110025 , 0061006 , 0040020 , 0015540 , 0021354 ,
0155050 , 0037455 , 0175274 , 0015257 , 0021112 , 0036673 , 0135523 ,
0016042 , 0117203 , 0036221 , 0151221 , 0046352 , 0144174 , 0035065 ,
0021232 , 0117727 , 0152432 , 0034445 , 0147317 , 0037300 , 0067123 ,
};
#endif
#if IBMPC
static short A6[32 ] = {
0 x600c, 0 x2c56, 0 x4b31, 0 x3f94, 0 x4e84, 0 x157b, 0 x58a9, 0 xbff4,
0 x712b, 0 x67f4, 0 xb48d, 0 xc000, 0 x1394, 0 xeb6d, 0 x0b5a, 0 x4006,
0 x30e9, 0 x4e24, 0 x3889, 0 xbfdc, 0 x19bf, 0 x913d, 0 xe353, 0 x3fa7,
0 x8415, 0 xf1ed, 0 x5060, 0 xbf59, 0 x2cfc, 0 x6eb2, 0 x81df, 0 x3f12,
};
static short B6[28 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xac41, 0 x1202, 0 x9fbd, 0 x3ff7, 0 x9b45, 0 x045d, 0 x036c,
0 x3fe2, 0 xe449, 0 x8355, 0 xbf57, 0 x3fc5, 0 x53d0, 0 x6384,
0 x776a, 0 x3f97, 0 x590f, 0 x299d, 0 x3a52, 0 x3f72, 0 xfaa3,
0 x53fa, 0 xa453, 0 x3f26, 0 x0dca, 0 xe7d8, 0 xb9d9, 0 x3f04,
};
#endif
#if MIEEE
static short A6[32 ] = {
0 x3f94, 0 x4b31, 0 x2c56, 0 x600c, 0 xbff4, 0 x58a9, 0 x157b, 0 x4e84,
0 xc000, 0 xb48d, 0 x67f4, 0 x712b, 0 x4006, 0 x0b5a, 0 xeb6d, 0 x1394,
0 xbfdc, 0 x3889, 0 x4e24, 0 x30e9, 0 x3fa7, 0 xe353, 0 x913d, 0 x19bf,
0 xbf59, 0 x5060, 0 xf1ed, 0 x8415, 0 x3f12, 0 x81df, 0 x6eb2, 0 x2cfc,
};
static short B6[28 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 x3ff7, 0 x9fbd, 0 x1202, 0 xac41, 0 x3fe2, 0 x036c, 0 x045d,
0 x9b45, 0 x3fc5, 0 xbf57, 0 x8355, 0 xe449, 0 x3f97, 0 x776a,
0 x6384, 0 x53d0, 0 x3f72, 0 x3a52, 0 x299d, 0 x590f, 0 x3f26,
0 xa453, 0 x53fa, 0 xfaa3, 0 x3f04, 0 xb9d9, 0 xe7d8, 0 x0dca,
};
#endif
/* 32 <= x <= 64
x exp ( - x ) Ei ( x ) - 1 = 1 / x A7 ( 1 / x ) / B7 ( 1 / x )
Theoretical absolute error = 7.71e-18 */
#if UNK
static double A7[6 ] = {
1 .212561118105456670844 E-1 , -5 .823133179043894485122 E-1 ,
2 .348887314557016779211 E-1 , -3 .040034318113248237280 E-2 ,
1 .510082146865190661777 E-3 , -2 .523137095499571377122 E-5 ,
};
static double B7[5 ] = {
/* 1.000000000000000000000E0, */
-1 .002252150365854016662 E0, 2 .928709694872224144953 E-1 ,
-3 .337004338674007801307 E-2 , 1 .560544881127388842819 E-3 ,
-2 .523137093603234562648 E-5 ,
};
#endif
#if DEC
static short A7[24 ] = {
0037370 , 0052437 , 0152524 , 0150125 , 0140025 , 0011174 , 0050154 , 0131330 ,
0037560 , 0103253 , 0167464 , 0062245 , 0136771 , 0005043 , 0174001 , 0023345 ,
0035705 , 0166762 , 0157300 , 0016451 , 0134323 , 0123764 , 0157767 , 0134477 ,
};
static short B7[20 ] = {
/* 0040200,0000000,0000000,0000000, */
0140200 , 0044714 , 0064025 , 0060324 , 0037625 , 0171457 , 0003712 ,
0073131 , 0137010 , 0127406 , 0150061 , 0141746 , 0035714 , 0105462 ,
0072356 , 0103712 , 0134323 , 0123764 , 0156514 , 0077414 ,
};
#endif
#if IBMPC
static short A7[24 ] = {
0 x9a0b, 0 xfaaa, 0 x0aa3, 0 x3fbf, 0 x965b, 0 x8a0d, 0 xa24f, 0 xbfe2,
0 x8c95, 0 x7de6, 0 x10d5, 0 x3fce, 0 x24dd, 0 x7f00, 0 x2144, 0 xbf9f,
0 x03a5, 0 x5bd8, 0 xbdbe, 0 x3f58, 0 xf728, 0 x9bfe, 0 x74fe, 0 xbefa,
};
static short B7[20 ] = {
/* 0x0000,0x0000,0x0000,0x3ff0, */
0 xac1a, 0 x8d02, 0 x0939, 0 xbff0, 0 x4ecb, 0 xe0f9, 0 xbe65,
0 x3fd2, 0 x387d, 0 xda06, 0 x15e0, 0 xbfa1, 0 xd0f9, 0 x4e9d,
0 x9166, 0 x3f59, 0 x8fe2, 0 x9ba9, 0 x74fe, 0 xbefa,
};
#endif
#if MIEEE
static short A7[24 ] = {
0 x3fbf, 0 x0aa3, 0 xfaaa, 0 x9a0b, 0 xbfe2, 0 xa24f, 0 x8a0d, 0 x965b,
0 x3fce, 0 x10d5, 0 x7de6, 0 x8c95, 0 xbf9f, 0 x2144, 0 x7f00, 0 x24dd,
0 x3f58, 0 xbdbe, 0 x5bd8, 0 x03a5, 0 xbefa, 0 x74fe, 0 x9bfe, 0 xf728,
};
static short B7[20 ] = {
/* 0x3ff0,0x0000,0x0000,0x0000, */
0 xbff0, 0 x0939, 0 x8d02, 0 xac1a, 0 x3fd2, 0 xbe65, 0 xe0f9,
0 x4ecb, 0 xbfa1, 0 x15e0, 0 xda06, 0 x387d, 0 x3f59, 0 x9166,
0 x4e9d, 0 xd0f9, 0 xbefa, 0 x74fe, 0 x9ba9, 0 x8fe2,
};
#endif
double ei(x) double x;
{
double f, w;
if (x <= 0 .0 ) {
mtherr("ei" , DOMAIN);
return 0 .0 ;
} else if (x < 2 .0 ) {
/* Power series.
inf n
- x
Ei ( x ) = EUL + ln x + > - - - -
- n n !
n = 1
*/
f = polevl(x, A, 5 ) / p1evl(x, B, 6 );
/* f = polevl(x,A,6) / p1evl(x,B,7); */
/* f = polevl(x,A,8) / p1evl(x,B,9); */
return (EUL + log(x) + x * f);
} else if (x < 4 .0 ) {
/* Asymptotic expansion.
1 2 6
x exp ( - x ) Ei ( x ) = 1 + - - - + - - - + - - - - + . . .
x 2 3
x x
*/
w = 1 .0 / x;
f = polevl(w, A6, 7 ) / p1evl(w, B6, 7 );
return (exp(x) * w * (1 .0 + w * f));
} else if (x < 8 .0 ) {
w = 1 .0 / x;
f = polevl(w, A5, 7 ) / p1evl(w, B5, 8 );
return (exp(x) * w * (1 .0 + w * f));
} else if (x < 16 .0 ) {
w = 1 .0 / x;
f = polevl(w, A2, 9 ) / p1evl(w, B2, 9 );
return (exp(x) * w * (1 .0 + w * f));
} else if (x < 32 .0 ) {
w = 1 .0 / x;
f = polevl(w, A4, 7 ) / p1evl(w, B4, 8 );
return (exp(x) * w * (1 .0 + w * f));
} else if (x < 64 .0 ) {
w = 1 .0 / x;
f = polevl(w, A7, 5 ) / p1evl(w, B7, 5 );
return (exp(x) * w * (1 .0 + w * f));
} else {
w = 1 .0 / x;
f = polevl(w, A3, 8 ) / p1evl(w, B3, 9 );
return (exp(x) * w * (1 .0 + w * f));
}
}
Messung V0.5 in Prozent C=96 H=95 G=95