source: http://calculuswithjulia.github.io/precalc/exp_log_functions.html
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.
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^{xy}\) 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\).
using CalculusWithJulia # to load the `Plots` package
f1(x) = (1/2)^x
## f1 (generic function with 1 method)
f2(x) = 1^x
## f2 (generic function with 1 method)
f3(x) = 2^x
## f3 (generic function with 1 method)
f4(x) = exp(x)
## f4 (generic function with 1 method)
plot([f1,f2,f3,f4], -2, 2, legend=false)
We see exples of some general properties:
r2, r8 = 0.02, 0.08
## (0.02, 0.08)
P0 = 1000
## 1000
t = 20
## 20
P0 * exp(r2*t), P0 * exp(r8*t)
## (1491.8246976412704, 4953.0324243951145)
t2, t8 = 72/2, 72/8
## (36.0, 9.0)
exp(r2*t2), exp(r8*t8)
## (2.0544332106438876, 2.0544332106438876)
n = 2 * 24
## 48
2^(n/6)
## 256.0
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 case \(a\), written \(\log_a(x)\)
That is \(a^{\log_a(x)} = x\) and \(a^{\log_a(x)} = x\) when defined.
f(x) = 2^x
## f (generic function with 1 method)
xs = range(-2, stop=2, length=10)
## -2.0:0.4444444444444444:2.0
ys=f.(xs)
## 10-element Array{Float64,1}:
## 0.25
## 0.3401975000435942
## 0.4629373561436452
## 0.6299605249474366
## 0.8572439828530728
## 1.1665290395761165
## 1.5874010519681994
## 2.160119477784612
## 2.9394689845511977
## 4.0
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)
## 0.25:0.03787878787878788:4.0
plot!(xs, log2.(xs), color=:green) # plot log2
log2(1_100_000)
## 20.06907209307411
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).
Similaryly, the relation \((a^{x})^y =a^{x \cdot y}, a > 0\) 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)}\)
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=\ln^{(2)}\). So we get \(t=\ln^{(2)}/r\). As \(\ln^{(2)}\) is
log(2)
## 0.6931471805599453
We get the actual rule should be the “Rule of 69.314…”.