Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

What algorithm is used by computers to calculate logarithms?

Writer Emily Wong
$\begingroup$

I would like to know how logarithms are 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?

$\endgroup$ 7

3 Answers

$\begingroup$

It really depends on the CPU.

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

More info can be found here:

and here:

$\endgroup$ 5 $\begingroup$

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.

J. M. also brings up Padé approximants which I have seen used in some calculator implementations.

$\endgroup$ 8 $\begingroup$

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

See also .

$\endgroup$ 2