# Logarithms

## Table of Contents

Logarithms come up a lot in algorithms. Review how they work and learn the situations where they're…

## What logarithm even means

Here's what a logarithm is asking:

**"What power must we raise this base to, in order to get this answer?"**

So if we say:

log

_{10}100

The 10 is called the base (makes sense – ite's on the bottom). Think of the 100 as the "answer." It's what we're taking the log of. So this expression would be pronounced "log base 10 of 100."

And all it means is, "What power do we need to raise this base (`10`

) to, to get this answer (`100`

)?"

10

^{x}= 100

What `x`

gets us our result of 100? The answer is 2:

10

^{2}= 100

So we can say:

log

_{10}100 = 2

The "answer" part could be surrounded by parentheses, or not. So we can say log

_{10}(100) or log_{10}100. Either one's fine.

## What logarithms are used force

The main thing we use logarithms for is **solving for x when x is in an exponent.**

So if we wanted to solve this:

10

^{x}= 100

We need to bring the `x`

down from the exponent somehow. And logarithms give us a trick for doing that.

We take the log_{10} of both sides (we can do this – the two sides of the equation are still equal):

log

_{10}10^{x}= log_{10}100

Now the left-hand side is asking, "what power must we raise 10 to in order to get 10^{x}?" The answer, of course, is `x`

. So we can simplify that whole left side to just "x":

x = log

_{10}100

We've pulled the `x`

down from the exponent!

Now we just have to evaluate the right side. What power do we have to raise 10 to in order to get 100? The answer is still 2.

x = 2

That's how we use logarithms to pull a variable down from an exponent.

## Logarithm rules

These are helpful if you're trying to do some algebra stuff with logs.

**Simplification:** log_{b}(b^{x}) = x … Useful for bring a variable down from an exponent.

**Multiplication:** log_{b}(x * y) = log_{b}(x) + log_{b}(y)

**Division:** log_{b}(x / y) = log_{b}(x) - log_{b}(y)

**Powers:** log_{b}(x^{y}) = y * log_{b}(x)

**Change of base:** log_{b}(x) = log_{c}(x) / log_{c}(b) … Useful for changing the base of a logarithm from b to c.