How to calculate $e^x$ with a standard calculator

Is there a simple method for calculating the $e^x$ ($x\in\mathbb{R}$) with a basic add/subtract/multiply/divide calculator that converges in reasonable time, preferably without having to memorize coefficients as in the case of the power series?

I've found one for nth roots with Newton iteration that's pretty much dead simple and I'd really like to know what else can be done.

EDIT: I'm not really that excited about approximation unless the end result is completely accurate. There are some good ideas here, but this answer is the simplest option for a full-accuracy result using only a +/-/×/÷ calculator.

I also have a strong preference for algorithms which can be directly evaluated step-by-step on such a calculator. Otherwise pencil and paper or an excellent memory must be exercised.


Solution 1:

This is what I would do to calculate $e^x$ with perfect 8-digit accuracy.

  1. Take $\lfloor x\rfloor$ and $b = x - \lfloor x\rfloor$, the whole and fractional parts respectively. ($e^x = e^{\lfloor x \rfloor + (x - \lfloor x\rfloor)} = e^{\lfloor x \rfloor} e^{x - \lfloor x \rfloor}$)

  2. Use the $(((b/4 + 1)b/3 + 1)b/2 + 1)b + 1$ pattern to calculate $e^{x - \lfloor x\rfloor}$. (If the fractional part of the exponent is .4 or less, only terms up to $b/7$ are needed for 8-digit accuracy. Worst-case scenario ($b \rightarrow 1$) terms up to $b/10$ are needed.) This method is easy to implement on a simple calculator, especially ones with a memory slot to quickly reinsert $b$.

  3. When that is finished, multiply by $e$ ($\approx 2.71828183$ by memorization) and press the equals button $\lfloor x\rfloor$ times to repeat multiply. The result is $e^x$.


I've analyzed the number of terms required for full accuracy. Here is the chart (click to view full image):

chart

Basically, if terms up to $b/t$ are needed to fully calculate $e^x$ up to 8-digit precision (7 digits after the decimal point), accounting for rounding (the $\frac{1}{2}$ term), the relation between $x$ and $t$ is given by $\sqrt[t]{\frac{1}{2}10^{-7}t!} = x$.

Solution 2:

To echo Robert's and lhf's comments, Padé works nicely for approximation purposes. The $[2,2]$ approximant is easily remembered, in particular:

$$\exp(z)\approx\frac{(z+3)^2+3}{(z-3)^2+3}$$

but of course it is trivial to generate higher-order approximants (yet the coefficients aren't as easy to remember).

Here then is how to make this approximation slightly more practical: this hinges on the usual identity

$$\exp(2z)=\exp(z)^2$$

The "repeated squaring" idea is as follows, for the case of $z > 0$:

  1. Keep halving the argument $z$ until $|z| < 0.1$. Note how many times you halved the argument. Call it $n$.

  2. Evaluate the $[2,2]$ approximant at this reduced argument.

  3. Square the result of the previous step $n$ times.

The result of this should be good to eight or so digits. For negative argument, negate the argument first, apply the repeated squaring method, and reciprocate the result afterwards. ($\exp(-z)=\frac1{\exp(z)}$)

Solution 3:

If $x$ is not too big, you could try approximating $e^x$ as $(1 + x/n)^n$ for some large $n$ (not too huge, or you run into roundoff error). Somewhat better is $(1 + x/n + x^2/(2 n^2))^n$. For example, with $x = 1$ and $n = 1000$, $(1 + 1/1000 + 1/(2\cdot 1000^2))^{1000} \approx 2.718281376$; the correct value is $e = 2.717281828$.

[EDIT: ] If you don't want powers, you might try the continued fraction $$ e^x = 1 + \cfrac{x}{1 - \cfrac{x}{2 + \cfrac{x}{3 - \cfrac{x}{2 + \cfrac{x}{5 - \cfrac{x}{2 + \cdots}}}}}}$$

Solution 4:

You may want to try a Padé approximant. See also https://mathoverflow.net/questions/41226/pade-approximant-to-exponential-function/41228#41228.