code: public static double log1mexp(double a) {
          if (a <= 0) {
              throw new IllegalArgumentException("a must be > 0: " + a);
          } else if (a <= 0.693) {
              return Math.log(-Math.expm1(-a));
          } else {
              return Math.log1p(-Math.exp(-a));
          }
      }
docs: f(a) = log(1 - exp(-a))