[Math] What algorithm do scientific calculators use to calculate Logarithms

applicationscalculatorlogarithmsnumerical methods

I have been introduced to numerical analysis and have been researching quite a bit on its applications recently. One specific application would be the scientific calculator.

From the information that I found, computers typically use the Taylor Series to compute trigonometric problems and calculators would usually take a different approach and use the CORDIC algorithm to compute such problems, including hyperbolic, inverse trigo, square roots etc.

However, how would they calculate logarithmic problems? I couldn't really find any information about this and was hoping someone would point me in the right direction or provide any insights on what kind of algorithms are used is such calculations.

Thanks in advance.

Best Answer

Modern Computer Arithmetic suggests using an arithmetic-geometric mean algorithm. I'm not sure if this approach is meant for the low amount of precision one typically works with or if its meant for calculation in very high precision.


Another approach is to observe that the Taylor series for $\ln(x)$ is efficient if $x$ is very close to $1$. We can use algebraic identities to reduce the general case to this special case.

One method is to use the identity

$$ \ln(x) = 2 \ln(\sqrt{x})$$

to reduce the calculation of $\ln(x)$ to that of an argument closer to 1. We could use a similar identity for more general radicals if we can compute those efficiently.

By iteratively taking roots until we get an argument very close to $1$, we can reduce to

$$ \ln(x) = m \ln(\sqrt[m]{x})$$

which can be computed by the Taylor series.


If you store numbers in mantissa-exponent form in base 10, an easy identity to exploit is

$$ \ln(m \cdot 10^e) = e \ln(10) + \ln(m)$$

so the plan is to precompute the value of $\ln(10)$, and then use another method to obtain $\ln(m)$, where $m$ is not large or small.

A similar identity holds in base 2, which a computer is likely to use.


A way to use lookup tables to accelerate the calculation of $\ln(x)$ when $x$ is not large or small is to observe that

$$ \ln(x) = \ln(k) + \ln(x/k) $$

The idea here is that you store a table of $\ln(k)$ for enough values of $k$ so that you can choose the $k$ nearest $x$ to make $x/k$ very near $1$, and then all that's left is to compute $\ln(x/k)$.