Getting Started with Logarithms
Explore the basics of logarithmic functions, their properties, and how they relate to running-time analysis in algorithms. Understand the significance of different log bases and key properties to prepare for deeper study in graph algorithms.
We'll cover the following...
Before we get to the core of the course, there is a bit of a warm up we’d like to do and introduce some ideas which are useful in the long run. We start with a short review of the math that we need. If you’re comfortable with logarithms, the big-O notation, and the proof by contradiction technique, you can attempt the interactive exercises included within the lessons and then jump straight to the next chapter on graphs.
The log functions
A logarithmic function is an inverse of an exponential function. For instance, consider an exponential function — it takes and maps it to power of . Its inverse function , when applied to , recovers the original .
Similarly, the inverse of is the function with the number serving as the base constant.
Note: In general, is the inverse of , for any positive constant , where . This constant is called the base of the function.
The base of a logarithmic function can be any positive number other than 1. Why is that? It has to do with the fact that is always , regardless of the value assigned to . So, this function doesn’t have a well-defined inverse. There are similar reasons for insisting that the base not be a negative number or a zero.
Note: The domain of a logarithmic function is the set of all positive real numbers.
Conventions
Here are the conventions for denoting log functions of base , , and , an irrational number called Euler’s constant.
-
When the base of a log function is not listed, base is implied. For example, means .
-
When the base is , is written .
-
When the base constant is , is written and referred to as the natural log of .
Let’s check out log functions against different bases.
Notice how there’s a dramatic decrease in the values taken by compared to the values taken by .
This behavior is the opposite of what we would observe for the corresponding exponential functions, where changing the base from to would have a dramatic increase in the values taken by .
Properties of log functions
The following four properties hold for a log function, regardless of the choice of base constant . We list these for base for convenience only:
It is also helpful to remember that for any base .
A quick quiz
Take a quick quiz to test your understanding of logarithms.
(True or False) The function evaluates to when equals the base .
True
False