public static double logspaceAdd(double logx,double logy){
  return Math.max(logx,logy) + Math.log1p(Math.exp(-Math.abs(logx - logy)));
}

public static double logspaceAdd ( double logx , double logy ) { return Math . max ( logx , logy ) + Math . log1p ( Math . exp ( - Math . abs ( logx - logy ) ) ) ; }
compute the log of a sum from logs of terms , i . e . , log ( exp ( logx ) + exp ( logy ) ) without causing overflows and without throwing away large handfuls of accuracy .
