New answers tagged

3

Yes, it is very well arguable that $\frac{e^x-1}{x}$ is ``as right as'' expm1. It appears frequently in applications; see for instance Sections 2.1 and 10.7.4 of Higham's Function of Matrices, which mention exponential integrators and matrix functions; this function is called $\psi_1(x)$ there. Your example, integrating exponentials, is another one, and it ...


2

expm1 is a primitive because for small $x$, the Taylor series for $e^x=1+x+x^2+\cdots$ adds small terms to one -- which implies that if $x$ is small enough, you lose almost all digits of accuracy other than the leading one and so the expression $e^x-1$ can not be accurately computed by first evaluating the exponential. The fact that you happen to have an ...


Top 50 recent answers are included