} else if (x >= (a + 1.0)) {
// use regularizedGammaQ because it should converge faster in this
// case.
ret = 1.0 - regularizedGammaQ(a, x);
} else {
Series s = new Series() {
private double term = 1.0 / x;
protected double getTerm(int n, double x) {
term = x / (a + n) * term;
return term;
}
};
ret = s.evaluate(x)
* Math.exp(-x + (a * Math.log(x)) - logGamma(a));
}
return ret;
}