Exponential and logarithmic functions

The family of exponential functions is used to model growth and decay. The family of logarithmic functions is defined here as the inverse of the exponential functions, but have reach far outside of that.

Exponential functions

The family of exponential functions is defined by $f(x) = a^x, -\infty< x < \infty$ and $a > 0$. For $0 < a < 1$ these functions decay or decrease, for $a > 1$ the functions grow or increase, and if $a=1$ the function is constantly $1$.

For a given $a$, defining $a^n$ for positive integers is straightforward, as it means multiplying $n$ copies of $a$. From this, the key properties of exponents: $a^x \cdot a^y = a^{x+y}$, and $(a^x)^y = a^{x \cdot y}$ are immediate consequences. For $a \neq 0$, $a^0$ is defined to be $1$. For positive, integer values of $n$, we have $a^{-n} = 1/a^n$. For $n$ a positive integer, we can define $a^{1/n}$ to be the unique positive solution to $x^n=a$. And using the key properties of exponents extend this to a definition of $a^x$ for any rational $x$.

Defining $a^x$ for any real number requires some more sophisticated mathematics. One method is to use a theorem that says a bounded monotonically increasing sequence will converge. Then for $a > 1$ we have if $q_n$ is a sequence of rational numbers increasing to $x$, then $a^{q_n}$ will be a bounded sequence of increasing numbers, so will converge to a number defined to be $a^x$. Something similar is possible for the $0 < a < 1$ case.

This definition can be done to ensure the rules of exponents hold for $a > 0$:

\[ ~ a^{x + y} = a^x \cdot a^y, \quad (a^x)^y = a^{x \cdot y}. ~ \]

In Julia these functions are implemented using ^ or for a base of $e$ through exp(x). Here are some representative graphs:

using CalculusWithJulia
using Plots
f1(x) = (1/2)^x
f2(x) = 1^x
f3(x) = 2^x
f4(x) = exp(x)
a,b = -2, 2
p = plot(f1, a, b, legend=false)
plot!(f2, a, b); plot!(f3, a, b); plot!(f4, a, b)

We see examples of some general properties:

Example

Continuously compounded interest allows an initial amount $P_0$ to grow over time according to $P(t)=P_0e^{rt}$. Investigate the difference between investing $1,000$ dollars in an account which earns $2$% as opposed to an account which earns $8$% over $20$ years.

The $r$ in the formula is the interest rate, so $r=0.02$ or $r=0.08$. To compare the differences we have:

r2, r8 = 0.02, 0.08
P0 = 1000
t = 20
P0 * exp(r2*t), P0 * exp(r8*t)
(1491.8246976412704, 4953.0324243951145)

As can be seen, there is quite a bit of difference.

In 1494, Pacioli gave the "Rule of 72", stating that to find the number of years it takes an investment to double when continuously compounded one should divide the interest rate into $72$.

This formula is not quite precise, but a rule of thumb, the number is closer to $69$, but $72$ has many divisors which makes this an easy to compute approximation. Let's see how accurate it is:

t2, t8 = 72/2, 72/8
exp(r2*t2), exp(r8*t8)
(2.0544332106438876, 2.0544332106438876)

So fairly close - after $72/r$ years the amount is $2.05...$ times more than the initial amount.

Example

Bacterial growth (to Wikipedia) is the asexual reproduction, or cell division, of a bacterium into two daughter cells, in a process called binary fission. During the log phase "the number of new bacteria appearing per unit time is proportional to the present population." The article states that "Under controlled conditions, cyanobacteria can double their population four times a day..."

Suppose an initial population of $P_0$ bacteria, a formula for the number after $n$ hours is $P(n) = P_0 2^{n/6}$ where $6 = 24/4$.

After two days what multiple of the initial amount is present if conditions are appropriate?

n = 2 * 24
2^(n/6)
256.0

That would be an enormous growth. Don't worry: "Exponential growth cannot continue indefinitely, however, because the medium is soon depleted of nutrients and enriched with wastes."

Example

The famous Fibonacci numbers are $1,1,2,3,5,8,13,\dots$, where $F_{n+1}=F_n+F_{n-1}$. These numbers increase. To see how fast, if we guess that the growth is evenually exponential and assume $F_n \approx c \cdot a^n$, then our equation is approximately $a^{n+1} = a^n + a^{n-1}$ which has solutions $a$ satisfying $a^2 - a -1 = 0$. The positve solution is $(1 + \sqrt{5})/2\approx 1.618$

That is evidence that the $F_n \approx 1.618^n$. (See Relation to golden ratio for a related, but more explicit exact formula.

Example

In the previous example, the exponential family of functions is used to describe growth. Polynomial functions also increase. Could these be used instead? If so that would be great, as they are easier to reason about.

The key fact is that exponential growth is much greater than polynomial growth. That is for large enough $x$ and for any fixed $a>1$ and positive integer $n$ it is true that $a^x \gg x^n$.

Later we will see an easy way to certify this statement.

Logarithmic functions: the inverse of exponential functions

As the exponential functions are strictly decreasing when $0 < a < 1$ and strictly increasing when $a>1$, in both cases an inverse function will exist. (When $a=1$ the function is a constant and is not one-to-one.) The domain of an exponential function is all real $x$ and the range is all positive $x$, so these are switched around for the inverse function.

The inverse function will solve for $x$ in the equation $a^x = y$. The answer, formally, is the logarithm base $a$, written $\log_a(x)$.

That is $a^{\log_a(x)} = x$ and $\log_a(a^x) = x$ when defined.

To see how a logarithm is mathematically defined will have to wait, though the family of functions - one for each $a>0$ - are implemented in Julia through the function log(a,x). There are special cases requiring just one argument: log(x) will compute the natural log, base $e$ - the inverse of $f(x) = e^x$; log2(x) will compute the log base $2$ - the inverse of $f(x) = 2^x$; and log10(x) will compute the log base $10$ - the inverse of $f(x)=10^x$.

To see this in an example, we plot for base $2$ the exponential function $f(x)=2^x$, its inverse, and the logarithm function with base $2$:

f(x) = 2^x
xs = range(-2, stop=2, length=100)
ys = f.(xs)
plot(xs, ys,  color=:blue, legend=false)  # plot f
plot!(ys, xs, color=:red)                 # plot f^(-1)
xs = range(1/4, stop=4, length=100)
plot!(xs, log2.(xs), color=:green)        # plot log2

Though we made three graphs, only two are seen, as the graph of log2 matches that of the inverse function.

Note that we needed a bit of care to plot the inverse function directly, as the domain of $f$ is not the domain of $f^{-1}$. Again, in this case the domain of $f$ is all $x$, but the domain of $f^{-1}$ is only all positive $x$ values.

Knowing that log2 implements an inverse function allows us to solve many problems involving doubling.

Example

An old story about doubling is couched in terms of doubling grains of wheat. To simplify the story, suppose each day an amount of grain is doubled. How many days of doubling will it take 1 grain to become 1 million grains?

The number of grains after one day is $2$, two days is $4$, three days is $8$ and so after $n$ days the number of grains is $2^n$. To answer the question, we need to solve $2^x = 1,000,000$. The logarithm function yields 20 days (after rounding up):

log2(1_000_000)
19.931568569324174
Example

The half-life of a radioactive material is the time it takes for half the material to decay. Different materials have quite different half lives with some quite long, and others quite short. See half lives for some details.

The carbon 14 isotope is a naturally occurring isotope on Earth, appearing in trace amounts. Unlike Carbon 12 and 13 it decays, in this case with a half life of 5730 years (plus or minus 40 years). In a technique due to Libby, measuring the amount of Carbon 14 present in an organic item can indicate the time since death. The amount of Carbon 14 at death is essentially that of the atmosphere, and this amount decays over time. If roughly half the carbon 14 remains, then the death occurred about 5730 years ago.

A formula for the amount of carbon 14 remaining $t$ years after death would be $P(t) = P_0 \cdot 2^{-t/5730}$.

If $1/10$ of the original carbon 14 remains, how old is the item? This amounts to solving $2^{-t/5730} = 1/10$. We have: $-t/5730 = \log_2(1/10)$ or:

-5730 * log2(1/10)
19034.647983704584

Properties of logarithms

The basic graphs of logarithms ($a > 1$) are all similar, though as we see larger bases lead to slower growing functions, though all satisfy $\log_a(1) = 0$:

plot(log2, 1/2, 10)           # base 2
plot!(log, 1/2, 10)           # base e
plot!(log10, 1/2, 10)         # base 10

Now, what do the properties of exponents imply about logarithms?

Consider the sum $\log_a(u) + \log_a(v)$. If we raise $a$ to this power, we have using the powers of exponents and the inverse nature of $a^x$ and $\log_a(x)$ that:

\[ ~ a^{\log_a(u) + \log_a(v)} = a^{\log_a(u)} \cdot a^{\log_a(v)} = u \cdot v. ~ \]

Taking $\log_a$ of both sides yields $\log_a(u) + \log_a(v)=\log_a(u\cdot v)$. That is logarithms turn products into sums (of logs).

Similarly, the relation $(a^{x})^y =a^{x \cdot y}, a > 0$s can be used to see that $\log_a(b^x) = x \cdot\log_a(b)$. This follows, as applying $a^x$ to each side yields the same answer.

Due to inverse relationship between $a^x$ and $\log_a(x)$ we have:

\[ ~ a^{\log_a(b^x)} = b^x. ~ \]

Due to the rules of exponents, we have:

\[ ~ a^{x \log_a(b)} = a^{\log_a(b) \cdot x} = (a^{\log_a(b)})^x = b^x. ~ \]

Finally, since $a^x$ is one-to-one (when $a>0$ and $a \neq 1$), if $a^{\log_a(b^x)}=a^{x \log_a(b)}$ it must be that $\log_a(b^x) = x \log_a(b)$. That is, logarithms turn powers into products.

Finally, we use the inverse property of logarithms and powers to show that logarithms can be defined for any base. Say $a, b > 0$. Then $\log_a(x) = \log_b(x)/\log_b(a)$. Again, to verify this we apply $a^x$ to both sides to see we get the same answer:

\[ ~ a^{\log_a(x)} = x, ~ \]

this by the inverse property. Whereas, by expressing $a=b^{\log_b(a)}$ we have:

\[ ~ a^{(\log_b(x)/\log_b(b))} = (b^{\log_b(a)})^{(\log_b(x)/\log_b(a))} = b^{\log_b(a) \cdot \log_b(x)/\log_b(a) } = b^{\log_b(x)} = x. ~ \]

In short we have these three properties of logarithmic functions:

if $a,b$ are positive bases; $u,v$ are positive numbers; and $x$ is any real number then: 1) $\log_a(uv) = \log_a(u) + \log_a(v)$, 2) $\log_a(u^x) = x \log_a(u)$, and 3) $\log_a(u) = \log_b(u)/\log_b(a)$.

Example

Before the ubiquity of electonic calculating devices, the need to compute was still present. Ancient civilizations had abacuses to make addition easier. For multiplication and powers a slide rule rule could be used. It is easy to represent addition physically with two straight pieces of wood - just represent a number with a distance and align the two pieces so that the distances are sequentially arranged. To multiply then was as easy: represent the logarithm of a number with a distance then add the logarithms. The sum of the logarithms is the logarithm of the product of the original two values. Converting back to a number answers the question. The conversion back and forth is done by simply labeling the wood using a logartithmic scale. The slide rule was invented soon after Napier's initial publication on the logarithm in 1614.

Example

Returning to the Rule of 72, what should the exact number be?

The amount of time to double an investment that grows according to $P_0 e^{rt}$ solves $P_0 e^{rt} = 2P_0$ or $rt = \log_2(2)$. So we get $t=\log_2(2)/r$. As $\log_2(2)$ is

log(2, 2)
1.0

We get the actual rule should be the "Rule of $69.314...$".

Questions

Question

Suppose ever $4$ days, a population doubles. If the population starts with $2$ individuals, what is its size after $4$ weeks?

Question

A bouncing ball rebounds to a height of $5/6$ of the previous peak height. If the ball is droppet at a height of $3$ feet, how high will it bounce after $5$ bounces?

Question

Which is bigger $e^2$ or $2^e$?

Question

Which is bigger $\log_8(9)$ or $\log_9(10)$?

Question

If $x$, $y$, and $z$ satisfy $2^x = 3^y$ and $4^y = 5^z$, what is the ratio $x/z$?

Question

Does $12$ satisfy $\log_2(x) + \log_3(x) = \log_4(x)$?

Question

The Richter magnitude is determined from the logarithm of the amplitude of waves recorded by seismographs (Wikipedia). The formula is $M=\log(A) - \log(A_0)$ where $A_0$ depends on the epicenter distance. Suppose an event has $A=100$ and $A_0=1/100$. What is $M$?

If the magnitude of one earthquake is $9$ and the magnitude of another earthquake is $7$, how many times stronger is $A$ if $A_0$ is the same for each?

Question

The Loudest band can possibly be measured in decibels. In 1976 the Who recorded $126$ db and in 1986 Motorhead recorded $130$ db. Suppose both measurements record power through the formula $db = 10 \log_10(P)$. What is the ratio of the Motorhead $P$ to the $P$ for the Who?

Question

Based on this graph:

plot(log, 1/4, 4)
f(x) = x - 1
plot!(f, 1/4, 4)

Which statement appears to be true?

Question

Consider this graph:

f(x) = log(1-x)
g(x) = -x - x^2/2
plot(f, -3, 3/4)
plot!(g, -3, 3/4)

What statement appears to be true?

Question

Suppose $a > 1$. If $\log_a(x) = y$ what is $\log_{1/a}(x)$? (The reciprocal property of exponents, $a^{-x} = (1/a)^x$, is at play here.)

Based on this, the graph of $\log_{1/a}(x)$ is the graph of $\log_a(x)$ under which transformation?

Question

Suppose $x < y$. Then for $a > 0$, $a^y - a^x$ is equal to:

Using $a > 1$ we have:

If $a < 1$ then: