Basics of Logarithms and the Decibel
This page has a lot of math. Even if math isn’t your strongest subject, I encourage you to read on.
I’ve purposefully chosen my examples to be as easy as possible
Let’s start with the basics of a logarithm. To define a logarithm, you first define what base you want to use. There are three primary bases that you will come across, depending on the application. For programmers and computer scientists, a base of 2 is useful, as they often work with binary numbers. The natural logarithm, which uses e as its base, is useful for calculations involving continuous compounding, and how long it takes to grow by X% given a specified rate. For most applications I’ll be talking about on this site tho, we will use a base of 10, as it is the easiest to convert to and from the decimal system that most of us our familiar with.
So what is the base? This is better understood by giving an example. Starting with a base of 2, let’s use this example: log2(8) = X
In English, this equation can be stated as the log, base 2, of 8 equals X. To actually solve for X tho, think of the equation as really asking the question, ‘2 (the base), raised to what power, equals 8?’ The answer is 3, since 23 = 8. Hence log2(8) = 3. A couple more examples to drive this concept home. Log2(16) = 4, log2(64) = 5, etc. Got it so far? Good.
A little more challenging now. What is log2(1/16)? In case you forgot, using a negative exponent is the same is taking the inverse. So 2-1 = 1/2, 2-2 = 1/4 and so on. So, 2 raised to what power equals 1/16? Hopefully you see now that the answer is -4. log2(1/16) = -4.
Now let’s apply the same concepts using a base of 10. Remember, in your mind, whenever you see a logarithm, ask yourself ‘the base, raised to what power, equals the number in the logarithm. So, log10(1,000) is asking, ’10, raised to what power, is 1,000?’. The answer is 3, hence log10(1,000) = 3. Similarly, log10(.01) = -2.
So why do I prefer using a base of 10? Well, since our linear system of numbers uses the decimal system, it becomes very quick and easy to convert numbers between the decimal system and base10 logarithms. Simply convert the most significant digit, then count the number of decimal places to get a good approximation. So if I told you log10(2) = .3, then you can quickly convert 2, 20, 200, 2000 and so on, by simply converting the most significant digit (2 in this case), and counting the decimal places. Hence 2 = .3, 20 = 1.3, 200 = 2.3 and 2000 = 3.3. See my other article, ‘Common dB conversions’ for a list of more base10 logarithm conversions
Now that you know the base 10 logarithm, it’s easy to define the decibel, which is what I will primarily be using going forward. Simply defined, Y in decibels (dBs) is 10 times the base 10 logarithm of that number. To reverse and go from dB back to decimal, you compute 10 raised to the number in dB, divided by 10.
Convert from decimal to dB: y_dB = 10*log10(y_dec)
Convert from dB to decimal: y_dec = 10^(y_dB/10)
So in our above examples, 2 = 3 dB, 20 = 13 dB and 2000 = 33 dB. As you can see, using dB means values tend to be whole numbers, making the representation cleaner.
Usefulness of Logarithms
Before I can explain the full usefulness of logarithms, we need to define a couple properties of logarithms first.
The Identity functions:
logX(1) = 0. To solve this, ask yourself, X (the base) raised to the power of 0, equals 1. Hopefully you remember that any number raised to the power of 0 equal 1. Hence, this identity function is true for all bases X
logX(X) = 1. Again, this is saying X (the base) raised to the power of 1, equals X. Again, this is true for any value of X, and hence any base.
Now, lets prove the product and power rules of logarithms using using what we already know. I showed you earlier that log10(1000) = 3 and log10(.01) = -2. What happens when I multiply the two numbers inside the logarithms together? I get log10(1000*.01) = log10(10) = 1 = 3 + (-2). Hence the product rule states that logX(Y*Z) = logX(Y) + logX(Z). Similar logic shows that logX(Y/Z) = logX(Y) – logX(Z).
Let’s rewrite that first equation one more way. log10(1000) = log10(10^3) = 3. Since we also know that log10(10) = 1 from the identity functions, we can see that 3*log10(10) = log10(10^3). Hence the product rule states that logX(Y^Z) = Z*logX(Y). Similar logic shows that logX(Zth_root(Y)) = logX(Y) / Z
Note that since the decibel is simply 10 times the base 10 logarithm, all of the above rules hold for it as well. The product and power rules are part of what make logarithms so useful for financial purposes. They take a product and turn it into a sum, or take an exponential and turn it into a product. In both cases, the math becomes simpler, allowing for quick estimation in ones head, without needing to pull out a calculator or excel sheet.
The other reason logarithms are useful, is it allows compact way of representing numbers that cover many orders of magnitude. Examples include measuring the pressure level of sound, or reporting an earthquake’s magnitude on the Richter scale. By applying the base10 logarithm, you can represent 100 as 2 or 2,000,000 as 6.3. This not only makes reporting the numbers easier, but plots are able to capture the details at every order of magnitude. If I use a linear scale that goes up to 2,000,000 and plot a point at 100, you have no way of telling if that point is at 100, 1 or 1000. By plotting on a log scale, you can easily separate points at 100 from 1 and 1000, even while showing numbers as large as 2,000,000. (Note:, the points would lie at 20, 0, 30 and 63 dB respectively as shown in the plots below).
Perhaps the greatest use-case for logarithms tho, is that it transforms exponentials from a hard to understand concept into a simple linear equation. For example, let’s take a typical investment scenario where each year the investment grows by 8%. This is a simple exponential, X1.08, yet I doubt anybody reading this could sit down with a piece of paper and graph by hand what this return would look like using a linear scale. We don’t have an intuitive understanding of what an exponential graph rlly looks like in detail. You might know it has a hockey-stick type of shape, but actually drawing something by hand that is reasonably accurate at each point is nearly impossible.
But what if we instead try to draw that same example using decibels? Luckily, the task is now simplistic once you know that 1.08 = 1/3 dB (see hint below for proof). At year 0, start at whatever the starting principle is in dB. Then, draw a line with a slope of 1/3, such that every 3 years, the principle grows by 1 dB. Simple. Below are the actual plots for both linear and log scale for reference.