I'm writing some code to calculate $\int_0^1 e^{ax} \mathrm{d} x$. Annoyingly there does not seem to be a way of doing this without if
statements:
def my_integral(a):
if a == 0:
return 1.
else:
return expm1(a)/a
(I know comparing to zero looks worrying, but this correctly returns 1
for values like 1e-50
)
It got me thinking; expm1
is really standard, but why isn't the right primitive expm1_over(x) = expm1(x)/x
?
expm1_over
can do everything that expm1
can, and more.
Am I missing some drawbacks?