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.


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)$.

| cite | improve this answer | |

The Handbook of Mathematical Functions by Abramowitz and Stegun, National Bureau of Standards Applied Mathematics Series 55 (which is available for free on-line), lists several polynomial approximations to the natural logarithm function in formulas 4.1.41 through 4.1.44. The Handbook says these approximations are from C. Hastings Jr., Approximations for digital computers. The most accurate of the formulas, 4.1.44, reads

$$\ln(1+x)=a_1 x + a_2 x^2 + a_3 x^3 + a_4 x^4 + a_5 x^5 + a_6 x^6 + a_7 x^7 + a_8 x^8 + \epsilon(x)$$ for $0 \le x \le 1$ with $| \epsilon(x) | \le 3 \times 10 ^{-8}$, where $$\begin{align} a_1 &= .99999 \;64239 \\ a_2 &= -.49987 \;41238 \\ a_3 &= .33179 \;90258 \\ a_4 &= -.24073 \;38084 \\ a_5 &= .16765 \;40711 \\ a_6 &= -.09532 \;93897 \\ a_7 &= .03608 \;84937 \\ a_8 &= -.00645 \;35422 \end{align}$$

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.