Some Stuff About Logarithms

Author

Andy Grogan-Kaylor

Published

November 26, 2023

1 Introduction (The Exponential Function)

We begin with the exponential function:

\[y = \text{base}^{\text{exponent}}\]

The exponent tells us how many times to multiply the base by itself to get the result.

For example: \(2^3 = 8\) because \(2 \times 2 \times 2 = 8\)

Show the code
twoway function y = 2^x, lwidth(thick) ///
title("Exponential Function") subtitle("With Base 2") ///
range(-10 10) 

graph export exponential0.png, replace

Graph of exponential function with base 2

2 A Definition of the Logarithm

We then consider the logarithm.

If \[y = b^x\] then \[\log_b(y) = x\].

In words: If \(\text{number} = \text{base}^{\text{exponent}}\) then \(\log_{\text{base}}(\text{number}) = \text{exponent}\).

For example, \(2^3 = 8\), therefore \(log_2 8 = 3\).

The logarithm answers the question: What is the power to which we have to raise the number to get the result?

The logarithm may thus be thought of as the inverse of the exponential function.

Show the code
twoway function y = ln(x)/ln(2), lwidth(thick) ///
title("Logarithmic Function") subtitle("Base 2") ///
range(-10 10)

graph export logarithmic0.png, replace

Graph of logarithmic function with base 2

3 A Definition of the Natural Logarithm

For deep mathematical reasons, it is often useful to use logarithms with base \(e\) which is often termed the natural logarithm, written \(\ln\)

\(e\) is a kind of fundamental mathematical constant, like \(\pi\), but without the easy geometric definition that \(\pi\) has. (For any \(\bigcirc\), \(\pi = \frac{\text{circumference}}{\text{diameter}}\).)

\(e\) is approximately equal to 2.71828….

If \[y = e^x\] then \[\ln(y) = x\].

Show the code
twoway function y = exp(x), lwidth(thick) ///
title("Exponential Function") subtitle("Base e") ///
range(-10 10) 

graph export exponential.png, replace

Graph of exponential function with base e
Show the code
twoway function y = ln(x), lwidth(thick) ///
title("Logarithmic Function") subtitle("Base e") ///
range(-10 10)

graph export logarithmic.png, replace

Graph of logarithmic function with base e

4 Exponential Regression

In categorical data analysis–especially later in the course–we are often thinking about some equation like \(\ln(y) = \beta x\). This is equivalent to \(y = e^{\beta x}\) so many models–particularly later in the course–will have us thinking about exponential relationships.

5 Logistic Regression

Early on in this course, we will think about logistic regression. In logistic regression, we start by thinking about the on the odds of our outcome:

\[\frac{p(y)}{1-p(y)}\]

We will be working with the log odds:

\[\ln(\frac{p(y)}{1-p(y)}) = x\]

To graph these log odds, we need to solve for \(p(y)\):

\[p(y) = \frac{e^x}{1 + e^x}\]

Show the code
twoway function y = exp(x)/(1 + exp(x)), lwidth(thick) /// 
title("Logistic Function") ///
range(-10 10)

graph export logistic.png, replace

Logistic curve

6 Logarithmic Spiral

An interesting sidenote is that the logarithm forms the basis of the logarithmic spiral. The equation for a logarithmic spiral in polar coordinates is: \(r = ae^{b \theta}\), where \(\theta\) is the angle, \(r\) is the radius, and \(a\) and \(b\) are constants.

Desmos Graph Logarithmic Spiral

Logarithmic spirals can be found in nature in the nautilus shell, and in sunflowers.

Nautilus Shell, Courtesy Wikipedia

Sunflower, Courtesy Wikipedia