# It's log all the way down

tags: logarithms

I read A Logarithm Too Clever by Half about MATLAB 6’s messed up LOG10 function.

So I was curious how far Perl would be. These things measure themselves in ULP (units in last place). There’s some precision that these functions have based on the number of bits they are able to use, and the path that final number can lose accuracy in each step.

This is one of those things that Computer Scientists can geek out about, but for which most of us don’t really care. Even with the inaccuracy, most of us probably don’t care. Even if you are reading this, you probably don’t care.

The results are ironically disappointing because the numbers from log (natural base) and POSIX’s log10 are exactly the same:

There’s usually a particular reason things are exactly the same: they come from the same thing. After diving down into the source of glibc and deeper into libm, I find that log10 is implemented in terms of log. Here’s the BSD version. That ivln10 is just 1/log(10), usually a literal (such as 4.34294481903251816668e-01):

Most of this still has been figured out decades ago.