9 #include "nf_specialFunctions.h"
11 #if defined __cplusplus
20 #define EULER 0.57721566490153286
22 #define FPMIN 1.0e-300
31 double a, b, c, d, del,
fact, h, psi;
34 *status = nfu_badInput;
39 if( ( n < 0 ) || ( x < 0.0 ) || ( ( x == 0.0 ) && ( ( n == 0 ) || ( n == 1 ) ) ) ) {
40 *status = nfu_badInput; }
51 for( i = 1; i <=
MAXIT; i++ ) {
54 d = 1.0 / ( a * d + b );
58 if( fabs( del - 1.0 ) <
EPS )
return( h *
G4Exp( -x ) );
60 *status = nfu_failedToConverge; }
62 ans = ( nm1 != 0 ) ? 1.0 / nm1 : -
G4Log(x) -
EULER;
64 for( i = 1; i <=
MAXIT; i++ ) {
67 del = -fact / ( i - nm1 ); }
70 for( ii = 1; ii <= nm1; ii++ ) psi += 1.0 / ii;
71 del = fact * ( -
G4Log( x ) + psi );
74 if( fabs( del ) < fabs( ans ) *
EPS )
return( ans );
76 *status = nfu_failedToConverge;
82 #if defined __cplusplus
G4double G4Log(G4double x)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
const G4double x[NPOINTSGL]
double nf_exponentialIntegral(int n, double x, nfu_status *status)