Skip to content

Working with logarithms base 10, 2 and e…

A couple of weeks ago I was talking about logarithms and their use. They may seem to be a bit esoteric and they can cause a bit of head-scratching: a logarithm (base $latex a$) of a number $latex b$ is denoted by $latex log_a b$ and can be better understood in terms of an exponential function since the result is the power to which the base has to be raised to produce the number, i.e. $latex log_a b=x \leftrightarrow a^x=b$.

Nonetheless, using the base $latex e$ for logarithms is far more natural and as a form of abbreviation, it is denoted by $latex ln$. In spite of this, a lot of us still learn about this function with the base 10 (or simply $latex log$). Furthermore, the importance of the binary system makes it very useful to know about $latex log_2$. With that in mind, I ended up mentioning an approximation in which all three logarithms appear:

$latex log_2 (x)\simeq ln (x) + log (x)$

This can be very handy as you can approximate the value of the logarithm base 2 with a pedestrian calculator… of course you can still do this using the functions that some calculators offer you, but that is not the point of this post…

Anyway, note that it is an approximation and as such we could ask what is the relative error obtained when using it. Well, let us have a look: if the above expression holds, we can divide both sides by $latex log_2 (x)$ to obtain:

$latex 1\simeq \frac{ln (x) + log (x)}{log_2 (x)}$.

So the relative error can be expressed as:

$latex \epsilon_r = 1 – \frac{ln (x) + log (x)}{log_2 (x)}$.

That is all fine and good, but what is the value of that error? Well, let us use some of the properties of logarithms. We know that $latex log_a b=x \leftrightarrow a^x=b$. Also, it is true that $latex a^x=e^{x ln(a)}$, and thus we can say that $latex e^{x ln(a)}=b$.  From this it follows that $latex ln(b) = x ln(a)$. Nonetheless, we know that $latex x=log_a b$. Rearranging the terms we end up with the fact that:

$latex log_a b = \frac{ln b}{ln a}$.

Using that expression we can re-write the relative error as follows:

$latex epsilon_r = 1 – \frac{ln (x) + \frac{ln(x)}{ln(10)}}{\frac{ln (x)}{ln (2)}}=1-(ln 2)left(1+\frac{1}{ln 10} right)\simeq 0.00582282…$

Not too big an error! Let us have a look, $latex log_2 (10)=ln 10 +1\simeq 3.30259…$, whereas the actual value is closer to $latex log_2 (10)=3.32193…$

Interesting, don’t you think…