public static double complementaryRegularisedGammaFunction(double a, double x) {
		if (a < 0.0D || x < 0.0D) throw new IllegalArgumentException("\nFunction defined only for a >= 0 and x>=0");

		boolean oldIgSupress = Stat.igSupress;
		Stat.igSupress = true;
		double igf = 1.0D;

		if (x != 0.0D) {
			if (x == 1.0D / 0.0D) {
				igf = 0.0D;
			} else {
				if (x < a + 1.0D) {
					// Series representation
					igf = 1.0 - Stat.incompleteGammaSer(a, x);
				} else {
					// Continued fraction representation
					igf = 1.0 - Stat.incompleteGammaFract(a, x);
				}
			}
		}
		if (igf > 1.0) igf = 1.0;
		Stat.igSupress = oldIgSupress;
		return igf;
	}