# What algorithm is used by computers to calculate logarithms?

I would like to know how are logarithms calculated by computers. The GNU C library, for example, uses a call to the fyl2x() assembler instruction, which means that logarithms are calculated directly from the hardware.

So the question is: what algorithm is used by computers to calculate logarithms?

-
Implementation dependent. –  Quixotic Sep 1 '11 at 16:25
For the uninitiated: fyl2x() computes a binary (base-2) logarithm. –  Ｊ. Ｍ. Sep 1 '11 at 16:27
This is almost identical to the question I asked some time ago: math.stackexchange.com/questions/14066/calculator-algorithms –  John Smith Sep 1 '11 at 23:40
It’s easy. To get the algorithm, just let let a dyslexic write “logarithm”. –  Konrad Rudolph Sep 2 '11 at 12:49

It really depends on the CPU.

For intel IA64, apparently they use Taylor series combined with a table.

and here: http://www.computer.org/portal/web/csdl/doi/10.1109/ARITH.1999.762822 (this pdf you can find by a google search of the title)

-
This book should also be of interest. –  Ｊ. Ｍ. Sep 1 '11 at 16:26
Thank you. I searched on Knuth's Art of computer programming, where he suggested another method. –  zar Sep 1 '11 at 16:36
...and I might as well: Matters Computational has a nice section on elementary function computations, including the logarithm. –  Ｊ. Ｍ. Sep 1 '11 at 18:09

Read the docs and the source of the cephes library for instance. Try also these books:

-
Hastings's book is an oldie-but-goodie. If the OP doesn't need that much accuracy, the approximations given there might be adequate. –  Ｊ. Ｍ. Sep 1 '11 at 18:32
All methods I have seen reduce first by dividing by the power of $2$ in the exponent and adding that exponent times $\ln(2)$ to the result. From there, the two most common methods I have seen are Taylor series for $\ln(1+x)$ and a variant of the CORDIC algorithm.
I've seen at least one system use a Padé approximant instead of a Maclaurin series, but yes, I believe almost all implementations exploit $\log(ab)=\log\,a+\log\,b$ for range reduction... –  Ｊ. Ｍ. Sep 1 '11 at 18:08