Logarithms

I stumbled upon a blog post about logarithms, which reminded me of a post I made here: Some finding that deepens one’s undertanding of a particular aspect. Not ground breaking, but nevertheless interesting and maybe even helpful.

The post is great, I’d advice you to skip my summary and read the original post by Malte Skarupke. But since links die without warning, I’ll keep a summary below.

Logarithms correspond to the number of digits. Examples:

Well, as you can see the first digit doesn’t count. But that shouldn’t impede the intuition that can be gained.

It is important that the logarithm base is equivalent to the base of the numeral system. E.g., when the number is written in binary, its number of digits correspond to the binary logarithm.

Logarithm Rules

The intuition transfers nicely to the logarithm rules.

Multiplication

For powers of ten, this is obvious, but the principle holds in general: When multiplying two numbers, the number of digits of the result will correspond to the sum of the digits of the factors.

Division

Inverse behavior here. Makes sense, but (for me) definitely was not obvious before.

Power

Root

Change of Basis

This one means that the number of digits of a number, when written in different bases, will always be related by constant factors – no matter what the number is. For example, the number of digits of a number written in binary will always be \(1 / \text{log}_{10}(2) = 3.32\) times as much as when written in base 10. Example: 1024 = 10000000000b. Don’t forget that the first digit doesn’t count for this intuition ;-).

By the way, if you liked the (original) post, you may also like this one by the same author. At least I did.

Bonus

Note that the correspondence of the logarithm to the number of digits can be used in practice to compute the number of accurate digits of approximations:

exact          = 123.456
approx         = 123.4561
abs_accuracy   = abs(exact - approx)    # -> 0.0001
rel_accuracy   = (abs_accuracy)/exact   # -> 0.00000081
accurate_digts =  -log_10(rel_accuracy) # -> 6.09

At least approximately, as the following example shows :-).

exact          = 123.456
approx         = 123.4567               # higher deviation
abs_accuracy   = abs(exact - approx)    # -> 0.0007
rel_accuracy   = (abs_accuracy)/exact   # -> 0.00000567
accurate_digts =  -log_10(rel_accuracy) # -> 5.25

But it works the same way, e.g., for binary notation, when using \(log_2\).



Home