[Math] logarithm and exponent computation performance

computational mathematicslogarithmsnumerical methods

Using glibc on a x86 processor, which takes more CPU time? $a\ log\ b$ or $b^a$? For which values of $a$ is one faster than the other? Optional: Does the base used matter?

See also: What algorithm is used by computers to calculate logarithms?

Because I know someone will mention it, I know that $a\ log\ b$ does not equal $b^a$.

Best Answer

Look through the code used by the FreeBSD operating system:

http://svnweb.freebsd.org/base/head/lib/msun/src/

http://svnweb.freebsd.org/base/head/lib/msun/src/e_pow.c?view=markup

http://svnweb.freebsd.org/base/head/lib/msun/src/e_log.c?view=markup

It is claimed that these are rather high quality algorithms, better than cephes, and probably better than glibc.

http://lists.freebsd.org/pipermail/freebsd-numerics/

http://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000285.html

In one of these emails, someone describes an algorithm where they start with Taylor's series, and then run it through an optimization procedure to fine tune the coefficients. But there are so many emails that it would take a while to find where they describe it. These guys are really wanting to get every last digit accurate.

Update: I think the algorithm is called Remez algorithm. You can read about it on wikipedia.