What is the point of logarithms?

Bharat Kalluri / 2023-12-21

Before we get into logs, let's wrap our head around exponents.

On exponents

Question: If a lake has a flower, and the flower doubles every day. And the lake is full of flowers on day 10. When did the lake have half the flowers?

...

If you have answered 9, you are right! The number of flowers to exist would be 1024 on the 10th day and 256 on the ninth day. (progression: [1, 2, 4, 8, 16, 32, 64, 128, 256, 1024])

As you can see, exponential scales are massive. With the same scale, the 15th value is 32768 & the 20th value is 1048576.

In nature, a lot of scales are actually exponential.

  • Disease spread (like covid) is exponential in nature, if the curve is not controlled well
  • In a controlled environment & natural conditions, the population of a species is usually exponential.
  • Compound interest follows the exponential scale, hence it is tough to get in control

So when there is a growth rate, the only way to predict or assess the curve is by using an exponential scale. But dealing with ridiculously large numbers is extremely hard.

The log scale

Hence, if we flip the equation. We can effectively communicate data in a compressed format. This is called the log scale. Stay with me, you'll get it once you see an example.

Let's take the same example as above

import math
def get_final_value(initial_value: int, rate_of_change_per_cycle: float, elapsed_cycles: int):
    return initial_value * (math.pow(1+rate_of_change_per_cycle, elapsed_cycles))

exp_scale = [int(get_final_value(1, 1, i)) for i in range(0, 15)]
print(exp_scale)
# [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]

log_scale = [int(math.log(i, 2)) for i in exp_scale]
print(log_scale)
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

Instead of saying 16384 (the state at 15th day with a growth rate of 100% starting with 1), we can instead say 15 on a log scale with a base of two.

That is saying, how many times should we multiply the previous number by two (starting from 1) to get 16384. After 14 multiplications we get this number, that is what a log is.

Apparently humans intuitively think in logarithms! There was a research study in which scientists asked a tribe which does not have numbers what is the mid number from 1 to 9 & they said 3! Because one times three is three & three times three is nine. There is a fascinating episode by Radiolab called numbers which dives into this research. Check it out!

Apart from this neat data compression feature, logs make it extremely easy to perform math with large numbers given its properties. Checkout 3blue1browns video on logs to explore more of its properties.

Usage in the real world

  • Earthquakes are measured in the Richter scale, this is the log scale. On the Richter scale, each whole number increase represents a tenfold increase in amplitude of seismic waves and approximately 31.6 times more energy release!
  • Human hearing does not respond linearly to sound intensity, it is more closely related to the log of physical intensity. So decibel (dB) scale is logarithmic.
  • many more scales like acidity etc.. are also log scales.
Hand crafted by Bharat Kalluri