private static double logAdd(double x,double y){
  if (y <= x) {
    return x + Math.log1p(Math.exp(y - x));
  }
 else {
    return y + Math.log1p(Math.exp(x - y));
  }
}

private static double logAdd ( double x , double y ) { if ( y <= x ) { return x + Math . log1p ( Math . exp ( y - x ) ) ; } else { return y + Math . log1p ( Math . exp ( x - y ) ) ; } }
adds two numbers that are in the log domain , avoiding underflow .
