37 double tgamma(
double x)
39 double s = (2.50662827510730 + 190.9551718930764 / (x + 1)
40 - 216.8366818437280 / (x + 2) + 60.19441764023333
41 / (x + 3) - 3.08751323928546 / (x + 4) + 0.00302963870525
42 / (x + 5) - 0.00001352385959072596 / (x + 6)) / x;
44 return -
exp((x + 0.5) *
log(x + 5.5) - x - 5.5 +
log(-s));
46 return exp((x + 0.5) *
log(x + 5.5) - x - 5.5 +
log(s));
50 #if !defined(HAVE_LGAMMA) || (HAVE_DECL_SIGNGAM != 1)
57 double lgamma(
double x)
59 double gam = tgamma(x);
60 signgam = (gam < 0) ? -1 : 1;
61 return log(fabs(gam));
67 double cbrt(
double x) {
return std::pow(x, 1.0 / 3.0); }
73 #define M_LN2 0.69314718055994530941723212146 // ln(2)
76 double expm1(
double x)
79 if (std::fabs(x) < M_LN2) {
83 double term = x / 1.0;
89 while (std::fabs(term) > (std::fabs(sum)
90 * std::numeric_limits<double>::epsilon()));
102 double erfc(
double Y)
105 double P[4], Q[3], P1[6], Q1[5], P2[4], Q2[3];
106 double XMIN, XLARGE, SQRPI;
107 double X, RES, XSQ, XNUM, XDEN, XI, XBIG, ERFCret;
140 XNUM = (P[1] * XSQ + P[2]) * XSQ + P[3];
141 XDEN = (XSQ + Q[1]) * XSQ + Q[2];
142 RES = X * XNUM / XDEN;
144 else RES = X * P[3] / Q[2];
145 if (ISW == -1) RES = -RES;
150 if (ISW > 0)
goto ulf;
151 if (X < XLARGE)
goto eva;
156 XNUM = P1[5] * X + P1[1];
158 for (I = 2;I <= 4;I++) {
159 XNUM = XNUM * X + P1[I];
160 XDEN = XDEN * X + Q1[I];
165 if (X > XBIG)
goto fred;
169 XNUM = (P2[1] * XI + P2[2]) * XI + P2[3];
170 XDEN = XI + Q2[1] * XI + Q2[2];
171 RES = (SQRPI + XI * XNUM / XDEN) / X;
173 RES = RES *
exp(-XSQ);
174 if (ISW == -1) RES = 2.0 - RES;
187 double asinh(
double x)
196 double acosh(
double x)
198 it_error_if(x < 1,
"acosh(): Argument out of range");
205 double atanh(
double x)
207 it_error_if(std::fabs(x) >= 1,
"atanh(): Argument out of range");
208 return 0.5 *
std::log((x + 1) / (x - 1));
214 double rint(
double x)
217 if ((x == 0.0) || (x != x))
228 int i =
static_cast<int>(y);
229 if ((y - x >= 0.5) && (i & 1))