public static double igamma(double a,double x){
  double coef=(Math.exp(-x) * Math.pow(x,a)) / gamma(a);
  double sum=0.0;
  for (int i=0; i < 100; i++) {
    sum+=(gamma(a) / gamma(a + 1.0 + (double)i)) * Math.pow(x,(double)i);
  }
  return (coef * sum);
}

public static double igamma ( double a , double x ) { double coef = ( Math . exp ( - x ) * Math . pow ( x , a ) ) / gamma ( a ) ; double sum = 0.0 ; for ( int i = 0 ; i < 100 ; i ++ ) { sum += ( gamma ( a ) / gamma ( a + 1.0 + ( double ) i ) ) * Math . pow ( x , ( double ) i ) ; } return ( coef * sum ) ; }
calculates the incomplete gamma function for two doubles
