We try to exponentiate with numpy.exp() and, if that fails, with
python’s math.exp(). numpy.exp() is about 10 times faster but throws
an OverflowError exception for numerical underflow (e.g. exp(-800),
whereas python’s math.exp() just returns zero, which is much more
helpful.