``exp(x)`` can get overflow even when ``x`` is moderately large.

Here is a version that avoids this problem:
``log1pexp(x) = x > 0 ? x + log1p(exp(-x)) : log1p(exp(x))``