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:

- \(\text{log}_{10}(100) = 2\)
- \(\text{log}_{10}(1000) = 3\)
- \(\text{log}_{10}(10000) = 4\)

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.

- \(\text{log}_2(10b) = 1\)
- \(\text{log}_2(100b) = 2\)
- \(\text{log}_2(1000b) = 3\)

The intuition transfers nicely to the logarithm rules.

- \(\text{log}_b(xy) = \text{log}_b(x) + \text{log}_b(y)\)
- Example: 1,000 * 100 = 100,000

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.

- \(\text{log}_b(x/y) = \text{log}_b(x) - \text{log}_b(y)\)
- Example: 1000 / 100 = 10

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

- \(\text{log}_b(x^y) = \text{log}_b(x) * \text{log}_b(y)\)
- Example: \(1000^3 = 1000 * 1000 * 1000 = 1,000,000,000\)

- \(\text{log}_b(\sqrt[y]{x}) = \text{log}_b(x) / y\)
- Example: \(\sqrt[3]{1,000,000,000} = 1,000\)

- \(\text{log}_b(x) = \text{log}_k(x) / \text{log}_k(b)\)

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.

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