public static double regularizedUpperIncompleteGamma(double s, double x) {
        if (s < 0.0) {
            throw new IllegalArgumentException("Invalid s: " + s);
        }

        if (x < 0.0) {
            throw new IllegalArgumentException("Invalid x: " + x);
        }

        double igf = 0.0;

        if (x != 0.0) {
            if (x == 1.0 / 0.0) {
                igf = 1.0;
            } else {
                if (x < s + 1.0) {
                    // Series representation
                    igf = 1.0 - regularizedIncompleteGammaSeries(s, x);
                } else {
                    // Continued fraction representation
                    igf = 1.0 - regularizedIncompleteGammaFraction(s, x);
                }
            }
        }
        return igf;
    }
public static double regularizedUpperIncompleteGamma ( double s , double x ) { if ( s < 0.0 ) { throw new IllegalArgumentException ( "Invalid s: " + s ) ; } if ( x < 0.0 ) { throw new IllegalArgumentException ( "Invalid x: " + x ) ; } double igf = 0.0 ; if ( x != 0.0 ) { if ( x == 1.0 / 0.0 ) { igf = 1.0 ; } else { if ( x < s + 1.0 ) { igf = 1.0 - regularizedIncompleteGammaSeries ( s , x ) ; } else { igf = 1.0 - regularizedIncompleteGammaFraction ( s , x ) ; } } } return igf ; }
Regularized Upper/Complementary Incomplete Gamma Function
Q(s,x) = 1 - P(s,x) = 1 - <i><big>&#8747;</big><sub><small>0</small></sub><sup><small>x</small></sup> e<sup>-t</sup> t<sup>(s-1)</sup> dt</i>