TITLE: How to compute $(e^x -1)/x$ when $-10^{-8}<x<10^{-8}$
QUESTION [5 upvotes]: I am trying to graph the function $y=(e^x -1)/x$ for values of $x$ close to zero.
The result should be $y$ close to $1$.
Howevere, both in Excel and WolframAlpha the calculated values become very unpredictable for magnitudes of $x$ of the order $-10^{-8}<x<10^{-8}$.
(1) Why is this?
(2) Is there a more accurate way to calculate this function when $x$ is close to zero?

REPLY [4 votes]: For that very reason, many math libraries (for example the standard POSIX libc) have a expm1 function giving a numerically accurate value for $e^x - 1$ when $x$ is small.
See for example this.