Mike's Toolbox

Engineering a New Economy

Learn how we should operate the economy to reverse the trend of continuously increasing debt for the government and American households, and return prosperity to the poor and middle classes. All federal taxes should be eliminated and replaced by a simple low-percentage sales tax which eventually can be reduced to just 2%!

Back to Home Page

Calculator

Logarithms

For an introductory explanation of logarithms, please visit the following page:

The Basics of Logarithms

Topics covered on this page include the following:

Definitions
Adding Logarithms
Exponents
Approximating Logarithms
Doubling Your Money

Mike's Toolbox C++ Code version 1.2

Definitions

logarithm
A logarithm is an exponent. Specifically, the logarithm of a number is the exponent of 10 required to generate that number. As an example, the logarithm of 100 is 2 because if we raise 10 to the 2nd power, we get 100:

100 = 10 × 10 = 102

Therefore:
log 100 = 2
base
The base of a logarithm is the number that gets raised to the power. In the above definition the base was 10, but any number can be used as the base. Typically the base will be 10, 2, or a special base called e which has a value of approximately 2.71828. The base is written as a subscript, so the above equation would ideally be written log10100 to indicate that the base is 10. In words, you would say, "the log base 10 of 100 is 2." The base is often omitted from the notation when it is clear which base is being used.
natural logarithm
The natural logarithm is a logarithm where the base is the number e mentioned above. Instead of writing loge the natural logarithm is usually written as ln.

Adding Logarithms

We saw in the Introductory Page that the logarithm of a product of two numbers is equal to the sum of the logarithms of each of those numbers. An equation that represents this is:

log xy = log x + log y

If, for example, x is 100 and y is 1000, then we know that the logarithm of x is 2 and the logarithm of y is 3 because the logarithms of these numbers are just the number of zeros in the numbers. The product of x and y is 100,000, and we know that the logarithm of 100,000 is 5 since it has 5 zeros. We can see that 2 + 3 is 5. This property of logarithms works for any numbers x and y, not just when they are powers of 10.

This property of logarithms allows us to do something very interesting. Suppose we have the following table of logarithms for the numbers 1 through 10 shown here:

Number   Logarithm
1   0.000
2 0.301
3 0.477
4 0.602
5 0.699
6 0.778
7 0.845
8 0.903
9 0.954
10 1.000

And now imagine you are in need of the value of the logarithm of 7.2 which is not on the list. How would you determine this number?

log10 7.2 = ???

The method to use to solve this dilemma is to write the number 7.2 in terms of the numbers that are in our list. The first step is to get rid of the decimal point by multiplying by 10:

7.2 = 72 ÷ 10

Then we can write 72 as the product of 8 and 9:

7.2 = (8 × 9) ÷ 10

Now we just use the fact that the logarithms of numbers add when you multiply those numbers together (and subtract when dividing):

log 7.2 = log 8 + log 9 − log 10
  = 0.903 + 0.954 − 1
  = 0.857

You can verify that this is the correct answer using a calculator. Press the buttons from left to right to find the log of 7.2:

  

The calculator is more accurate than the three decimal places we had in our table of logarithms, but you'll notice that the first three places in the calculator's display match our result.

Exponents

Logarithms have an interesting property when exponents are involved. Suppose you need to find the logarithm of 29, which is 512:

log 29 = ???

This may seem like a very difficult task indeed, but it is actually quite simple, and I'll prove it to you now. Remember that an exponent tells you how many times to multiply a number together; 29 is just nine twos all multiplied together:

29 = 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2

And just as in the last example, logarithms add when numbers are multiplied together, so all of the × symbols turn into addition:

log 29 = log 2 + log 2 + log 2 + log 2 + log 2 + log 2 + log 2 + log 2 + log 2

But now we have a bunch of the same thing added together, many log 2's. How many are there? The same number that were multiplied together in the prior equation. And how many is that? It's the exponent 9, since the exponent tells you how many of the number to multiply together. So we can simplify our equation and solve for the answer:

log 29 = 9 × log 2
  = 9 × 0.301
  = 2.709

The value of log 2 was read from the table above. Let's check that our answer is correct using a calculator. Press the buttons from left to right to find the logarithm of 29:

              

This works in general: for any two numbers x and y, the following equation holds:

log yx = x · log y

The dot in the above equation means multiplication; it is often used in equations instead of the × symbol since it can be confused with the letter x.

Approximating Logarithms

Let's now think about how you would determine the value of a logarithm of a number if you didn't have access to the above table. All you know is that the logarithm of a power of ten is equal to the number of zeros in the number.

So let's look at how you would determine the value of the logarithm of 2:

log 2 = ???

The way to do this is to take advantage of the property of exponents in the previous section, and to use our knowledge of the values of logarithms for powers of 10. The process you will go through is to calculate the sequence of powers of the number you are trying to find the logarithm of, and to stop when you find a value that is close to a power of 10.

So let's compute a bunch of powers of 2:

x   2x
1   2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024

Here we find that 210 is fairly close to 1000. Now we will use this approximation to determine a reasonably good estimate for the logarithm of 2:

log 210 log 1000
  3

Using the result about exponents above, this equation can be rewritten as:

10 × log 2 3

Dividing both sides by 10 gives us an approximation for the value of log102:

log 2 3 ÷ 10
  0.300

The value for log102 in the above table is 0.301, which is very close to the value we just approximated.

Doubling Your Money

Suppose you have put your money in the bank and it is earning interest every year. You might be curious to find out how many years it will take for you to double your money. This seems like a very difficult question to answer, but it is easy to determine when you know how to use logarithms.

If you need to brush up on how interest accumulates in your bank account, please see the discussion of Compound Interest. The equation for computing your bank account balance after it has earned interest for some time is:

B = P × (1 + r)t

P is your initial deposit (the principal); r is the annual interest rate; and t is the time in years that interest has been compounding. B is your balance after the principal P has earned interest r for t years.

For this example let's again choose an interest rate of 6 percent. We also know that our initial deposit P has doubled, so B is known; it can be replaced by P × 2. The equation becomes:

P × 2 = P × 1.06t
2 = 1.06t

We are now looking to find the number of years, t, which satisfies this equation. Ordinary multiplication, division, addition, and subtraction are of no help in this endeavor. The key is to realize that if two numbers are equal, as in the above equation, then their logarithms will be the same too:

log 2 = log 1.06t

Using our understanding of exponents from above, this is equivalent to the following equation:

log 2 = t × log 1.06

Now just divide both sides by log 1.06 to find t:

log 2 = t

log 1.06

Using a calculator to determine the answer is straightforward:

           

So it will take just shy of 12 years to double your money if it compounds at a rate of 6 percent. Here is a table of the amount of time it takes to double your money at different interest rates.

Interest Rate   Years to Double Your Money
1% 69.66
2% 35.00
3% 23.45
4% 17.67
5% 14.21
6% 11.90
7% 10.24
10% 7.27
20% 3.80
30% 2.64

So while you are currently able to safely earn only a few percentage points, doubling your money in the range of every 20 or 30 years, your credit cards are charging you 30 percent, which is enough interest to double your debt in less than 3 years!

That's kind of a scary realization. Even more frightening, let's see how long it takes for a single dollar of debt to turn into $1,000:

           

So in the same amount of time that it takes your savings to double, the credit card debt you are carrying has been multiplied by 1,000. Better pay off those credit cards, and quick!

Contacting Mike of Mike's Toolbox

Please send comments and suggestions to:  mikestoolbox@pobox.com