# How do pocket calculators calculate exponents?

I'd like to know specifically how a pocket calculator (TI calculators also apply) calculates $e^{0.1}$, and what methods or algorithms pocket calculators use in order to produce their answer.

• They use a power series representation of $e^{x}$ and truncate the series so that there are only finitely many terms. Then evaluate that polynomial at $x$. It is an approximation. The closer $x$ is to $0$ the more accurate the approximation. (This is at least how it is done in standard programming libraries... I cannot say for certainty about calculators, but the same idea certainly applies.) Apr 17, 2015 at 17:38
• Maybe this could be asked on one of the programming sites in Stack Exchange, too, because I feel like they'll probably know more about the specific details of the algorithms used. Apr 17, 2015 at 17:45
• @columbus8myhw, Programmers use libraries. I'd think very little of them will know or understand the actual math algorithm. Jun 22, 2015 at 21:54

I would be surprised if they actually used Taylor series. For example, the basic 80x87 "exponential" instruction is F2XM1 which computes $2^x-1$ for $0 \le x \le 0.5$. I don't think the implementation is documented, but if I were programming this, I might use a minimax polynomial or rational approximation: the following polynomial of degree $9$ approximates $2^x - 1$ on this interval with maximum error approximately $1.57 \times 10^{-17}$:

-0.15639e-16+(.69314718055995154416+(.24022650695869054994+
(0.55504108675285271942e-1+(0.96181289721472527028e-2
+(0.13333568212100120656e-2+(0.15403075872034576440e-3
+(0.15265399313676342402e-4+(0.13003468358428470167e-5
+0.12113766044841794408e-6*x)*x)*x)*x)*x)*x)*x)*x)*x


By contrast, the Maclaurin polynomial of the same degree has maximum error about $7.11 \times 10^{-12}$ on this interval.

A commonly used set of algorithms is known as CORDIC: COordinate Rotation DIgital Computer. Basically, it uses a bunch of bitshifts, adds, subtracts and look up tables. Its good for cases where you don't have hardware multipliers and what not.

You can also truncate series as well.

An interesting thing is that you can often do some math and identify which chip is used in a calculator. I believe datamath.org has some information on this.

The ultimate answer can only be given by the maker of the calculator, but there are several strategies:

• The value can be calculated through the series expansion.
• The value can be interpolated from a stored table.
• The value can be reduced to the value of a smaller/larger argument by basic operations; for example $e^{2x} = (e^x)^2 = e^x\times e^x$.

In practice, a combination will likely be used. For large values (where the convergence of the series is slow), the value will likely be reduced to smaller arguments. Probably the calculator will also have stored the argument values beyond which overflow or underflow occurs, so for those the calculation can be skipped and an error (for overflow) or $0$ (for underflow) can be returned directly. For small values, Probably the series will be used directly, since it converges quickly. There might, however, also be a range of values where a lookup table is more efficient (that lookup table would then also be the "landing zone" for the large argument reduction). The interpolation would then probably again use the series expansion for the difference, using $e^{x+\delta}=e^xe^\delta$, where $x$ is the tabulated value and $\delta$ is the difference.

As a concrete example, the calulator could employ the following strategy:

• Store a table of $e^n$ for $n=1$ to $100$.
• For $\left|x\right| \le \frac12$, use the series directly. For $\frac12<x\le100.5$, use the series to calculate the factor to the nearest integer. For the corresponding negative argument, calculate the inverse.
• For higher values of $x$, but below the overflow limit, use recursion and the mentioned exponential relations to calculate the value by iteration. One relatively efficient method it to go through the bits of the remaining summand, square for every digit, and multiply by $e$ for every $1$. But given the table, probably more efficient iterations could be done (for example, take the 64th power by repeated squaring, and multiply by the value for the argument represented by the corresponding 6 bits, read from the table).

Of course the actual algorithm chosen depends on how fast the processor is (that is, how much inefficiency can you afford), how much memory it has available (that is, a how large table can you afford to store) and how accurate the calculator calculates (more accuracy means both more series terms to calculate, and larger table entries).

Note that $e^{x}=\sum_{n=0}^{\infty} \frac{x^{n}}{n!}$ so if you want an approximation of $e^{x}$ you can just truncate the series.

$$e^{x}\approx \sum_{n=0}^{N} \frac{x^{n}}{n!}.$$

After some quick searching, it looks like series are probably not (usually) the best way to go. See the accepted answer here: https://stackoverflow.com/questions/15350856/which-method-to-implement-exp-function-in-c

• At what term is the series truncated, and how would the calculator determine where the truncation occurs? Apr 17, 2015 at 17:41
• @JaggerPleab, There are error bounds that you can find in any textbook dealing with series. In some libraries, they guarantee a certain degree of accuracy provided that $x\in [a, b]$. Then, they can determine how big $N$ must be to give "good enough" accuracy on that interval. That $N$ would be used every time the computation is made. Depending on where $x$ is in the interval (or outside of it) the result will be more or less accurate. Apr 17, 2015 at 17:59
• @JaggerPleab, if $x<0$ then it is an alternating series, so the error is at most the first term that wasn't included in the sum. You just use enough terms that this value is small enough (depending on how accurate a number you want). Apr 17, 2015 at 18:05