lots of cleanup
This commit is contained in:
@@ -15,7 +15,6 @@ plotly()
|
||||
|
||||
---
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -45,7 +44,7 @@ For $a \neq 0$, $a^0$ is defined to be $1$.
|
||||
For positive, integer values of $n$, we have by definition that $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$.
|
||||
For $n$ a positive integer, we can define $a^{1/n}$ to be the unique, positive, real solution to $x^n=a$.
|
||||
|
||||
|
||||
Using the key properties of exponents we can extend this to a definition of $a^x$ for any rational $x$.
|
||||
@@ -57,31 +56,45 @@ Defining $a^x$ for any real number requires some more sophisticated mathematics.
|
||||
One method is to use a [theorem](http://tinyurl.com/zk86c8r) that says a *bounded* monotonically increasing sequence will converge. (This uses the [Completeness Axiom](https://en.wikipedia.org/wiki/Completeness_of_the_real_numbers).) 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$:
|
||||
This definition can be done to ensure the rules of exponents hold.
|
||||
|
||||
::: {.relationship title="Rules of exponents"}
|
||||
For $a > 0$:
|
||||
|
||||
|
||||
$$
|
||||
a^{x + y} = a^x \cdot a^y, \quad (a^x)^y = a^{x \cdot y}.
|
||||
\begin{align*}
|
||||
a^{x + y} &= a^x \cdot a^y,\\
|
||||
(a^x)^y &= a^{x \cdot y}.
|
||||
\end{align*}
|
||||
$$
|
||||
:::
|
||||
|
||||
In `Julia` these functions are implemented using `^`. A special value of the base, $e$, may be defined as well in terms of a limit. The exponential function $e^x$ is implemented in `exp`.
|
||||
|
||||
|
||||
::: {#fig-family-of-exponential-functions}
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
plot(x -> (1/2)^x, -2, 2, label="1/2")
|
||||
plot!(x -> 1^x, label="1")
|
||||
plot!(x -> 2^x, label="2")
|
||||
plot!(x -> exp(x), label="e")
|
||||
```
|
||||
|
||||
Plots of different exponential functions, when $0 < a < 1$ there is decay; when $a=1$ a constant; and when $a > 1$ exponential growth.
|
||||
:::
|
||||
|
||||
We see examples of some general properties:
|
||||
|
||||
|
||||
* The domain is all real $x$ and the range is all *positive* $y$ (provided $a \neq 1$).
|
||||
* For $0 < a < 1$ the functions are monotonically decreasing.
|
||||
* For $a > 1$ the functions are monotonically increasing.
|
||||
* If $1 < a < b$ and $x > 0$ we have $a^x < b^x$.
|
||||
* The domain is all real $x$ and the range is all *positive* $y$ (provided $a \neq 1$).
|
||||
|
||||
* For $0 < a < 1$ the functions are monotonically decreasing.
|
||||
|
||||
* For $a > 1$ the functions are monotonically increasing.
|
||||
|
||||
* If $1 < a < b$ and $x > 0$ we have $a^x < b^x$.
|
||||
|
||||
|
||||
##### Example
|
||||
@@ -102,6 +115,7 @@ P0 * exp(r2*t), P0 * exp(r8*t)
|
||||
|
||||
As can be seen, there is quite a bit of difference.
|
||||
|
||||
##### Example: Rule of 72
|
||||
|
||||
In $1494$, [Pacioli](http://tinyurl.com/gsy939y) 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$.
|
||||
|
||||
@@ -138,7 +152,7 @@ n = 2 * 24
|
||||
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."
|
||||
|
||||
|
||||
:::{.callout-note}
|
||||
::: {.callout-note}
|
||||
## Note
|
||||
The value of `2^n` and `2.0^n` is different in `Julia`. The former remains an integer and is subject to integer overflow for `n > 62`. As used above, `2^(n/6)` will not overflow for larger `n`, as when the exponent is a floating point value, the base is promoted to a floating point value.
|
||||
|
||||
@@ -156,7 +170,7 @@ That is evidence that the $F_n \approx c\cdot 1.618^n$. (See [Relation to golden
|
||||
##### 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.
|
||||
In a 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 easy 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$.
|
||||
@@ -171,34 +185,6 @@ Later we will see an easy way to certify this statement.
|
||||
Euler's number, $e$, may be defined several ways. One way is to define $e^x$ by the limit as $n$ grows infinitely large of $(1+x/n)^n$. Then $e=e^1$. The value is an irrational number. This number turns up to be the natural base to use for many problems arising in calculus. In `Julia` there are a few mathematical constants that get special treatment, so that when needed, extra precision is available. The value `e` is not immediately assigned to this value, rather `ℯ` is. This is typed `\euler[tab]`. The label `e` is thought too important for other uses to reserve the name for representing a single number. However, users can issue the command `using Base.MathConstants` and `e` will be available to represent this number. When the `CalculusWithJulia` package is loaded, the value `e` is defined to be the floating point number returned by `exp(1)`. This loses the feature of arbitrary precision, but has other advantages.
|
||||
|
||||
|
||||
A [cute](https://www.mathsisfun.com/numbers/e-eulers-number.html) appearance of $e$ is in this problem: Let $a>0$. Cut $a$ into $n$ equal pieces and then multiply them. What $n$ will produce the largest value? Note that the formula is $(a/n)^n$ for a given $a$ and $n$.
|
||||
|
||||
|
||||
Suppose $a=5$ then for $n=1,2,3$ we get:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
a = 5
|
||||
(a/1)^1, (a/2)^2, (a/3)^3
|
||||
```
|
||||
|
||||
We'd need to compare more, but at this point $n=2$ is the winner when $a=5$.
|
||||
|
||||
|
||||
With calculus, we will be able to see that the function $f(x) = (a/x)^x$ will be maximized at $a/e$, but for now we approach this in an exploratory manner. Suppose $a=5$, then we have:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
a = 5
|
||||
n = 1:10
|
||||
f(n) = (a/n)^n
|
||||
@. [n f(n) (a/n - e)] # @. just allows broadcasting
|
||||
```
|
||||
|
||||
We can see more clearly that $n=2$ is the largest value for $f$ and $a/2$ is the closest value to $e$. This would be the case for any $a>0$, pick $n$ so that $a/n$ is closest to $e$.
|
||||
|
||||
|
||||
##### Example: The limits to growth
|
||||
|
||||
@@ -206,45 +192,48 @@ We can see more clearly that $n=2$ is the largest value for $f$ and $a/2$ is the
|
||||
The $1972$ book [The limits to growth](https://donellameadows.org/wp-content/userfiles/Limits-to-Growth-digital-scan-version.pdf) by Meadows et. al. discusses the implications of exponential growth. It begins stating their conclusion (emphasis added): "If the present *growth* trends in world population, industrialization, pollution, food production, and resource depletion continue *unchanged*, the limits to growth on this planet will be reached sometime in the next *one hundred* years." They note it is possible to alter these growth trends. We are now half way into this time period.
|
||||
|
||||
|
||||
Let's consider one of their examples, the concentration of carbon dioxide in the atmosphere. In their Figure $15$ they show data from $1860$ onward of CO$_2$ concentration extrapolated out to the year $2000$. At [climate.gov](https://www.climate.gov/news-features/understanding-climate/climate-change-atmospheric-carbon-dioxide) we can see actual measurements from $1960$ to $2020$. Numbers from each graph are read from the graphs, and plotted in the code below:
|
||||
|
||||
Let's consider one of their examples, the concentration of carbon dioxide in the atmosphere. In their Figure $15$ they show data from $1860$ onward of CO$_2$ concentration extrapolated out to the year $2000$. At [climate.gov](https://www.climate.gov/news-features/understanding-climate/climate-change-atmospheric-carbon-dioxide) we can see actual measurements from $1960$ to $2020$. Numbers from each graph are read from the graphs, and plotted in the code below. See @fig-plot-of-climate-data-1960-2020.
|
||||
|
||||
::: {#fig-plot-of-climate-data-1960-2020}
|
||||
```{julia}
|
||||
co2_1970 = [(1860, 293), (1870, 293), (1880, 294), (1890, 295), (1900, 297),
|
||||
(1910, 298), (1920, 300), (1930, 303), (1940, 305), (1950, 310),
|
||||
(1960, 313), (1970, 320), (1980, 330), (1990, 350), (2000, 380)]
|
||||
co2_2021 = [(1960, 318), (1970, 325), (1980, 338), (1990, 358), (2000, 370),
|
||||
(2010, 390), (2020, 415)]
|
||||
co2_1970 = [(1860, 293), (1870, 293), (1880, 294), (1890, 295),
|
||||
(1900, 297), (1910, 298), (1920, 300), (1930, 303),
|
||||
(1940, 305), (1950, 310), (1960, 313), (1970, 320),
|
||||
(1980, 330), (1990, 350), (2000, 380)]
|
||||
co2_2021 = [(1960, 318), (1970, 325), (1980, 338), (1990, 358),
|
||||
(2000, 370), (2010, 390), (2020, 415)]
|
||||
|
||||
plot(co2_1970, legend=false) # vector of points interface
|
||||
plot!(co2_2021)
|
||||
|
||||
exp_model(;r, x0, P0) = x -> P0 * exp(r * (x - x0))
|
||||
|
||||
# add two exponential models
|
||||
r = 0.002
|
||||
x0, P0 = 1960, 313
|
||||
plot!(exp_model(; r, x0, P0), 1950, 1990, linewidth=5, alpha=0.25)
|
||||
m1(x) = P0 * exp(r * (x - x0))
|
||||
plot!(m1, 1950, 1990, line=(:blue, 5, 0.25))
|
||||
|
||||
r = 0.005
|
||||
x0, P0 = 2000, 370
|
||||
|
||||
plot!(exp_model(; r, x0, P0), 1960, 2020, linewidth=5, alpha=0.25)
|
||||
m2(x) = P0 * exp(r * (x - x0))
|
||||
plot!(m2, 1960, 2020, line=(:blue, 5, 0.25))
|
||||
```
|
||||
|
||||
Plot of $CO_2$ concentration over time with two exponential models layered on
|
||||
:::
|
||||
|
||||
We can see that the projections from the year $1970$ hold up fairly well.
|
||||
|
||||
On this plot we added two *exponential* models. at $1960$ we added a *roughly* $0.2$ percent per year growth (a rate mentioned in an accompanying caption) and at $2000$ a roughly $0.5$ percent per year growth. The former barely keeping up with the data. (To do so, we used a parameterized function making for easier code reuse.)
|
||||
On this plot we added two *exponential* models. at $1960$ we added a *roughly* $0.2$ percent per year growth (a rate mentioned in an accompanying caption) and at $2000$ a roughly $0.5$ percent per year growth. The former barely keeping up with the data.
|
||||
|
||||
|
||||
The word **roughly** above could be made exact. Suppose we knew that between $1960$ and $1970$ the rate went from $313$ to $320$. If this followed an exponential model, then $r$ above would satisfy:
|
||||
The word *roughly* above could be made exact. Suppose we knew that between $1960$ and $1970$ the rate went from $313$ to $320$. If this followed an exponential model, then $r$ above would satisfy:
|
||||
|
||||
|
||||
$$
|
||||
P_{1970} = P_{1960} e^{r \cdot (1970 - 1960)}
|
||||
$$
|
||||
|
||||
or on division $320/313 = e^{r\cdot 10}$. Solving for $r$ can be done – as explained next – and yields $0.002211\dots$.
|
||||
or on division $320/313 = e^{r\cdot 10}$. Solving for $r$ can be done---as explained next---and yields $0.002211\dots$.
|
||||
|
||||
|
||||
## Logarithmic functions
|
||||
@@ -262,9 +251,10 @@ That is $a^{\log_a(x)} = x$ for $x > 0$ and $\log_a(a^x) = x$ for all $x$.
|
||||
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$. (Also `log1p` computes an accurate value of $\log(1 + p)$ when $p \approx 0$.)
|
||||
|
||||
|
||||
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$:
|
||||
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$. Though we made three graphs, only two are seen in @fig-plot-2-to-x-inverse-log2, as the graph of `log2` matches that of the inverse function.
|
||||
|
||||
|
||||
::: {#fig-plot-2-to-x-inverse-log2}
|
||||
```{julia}
|
||||
#| hold: true
|
||||
f(x) = 2^x
|
||||
@@ -277,7 +267,8 @@ xs = range(1/4, stop=4, length=100)
|
||||
plot!(xs, log2.(xs), color=:green, label="log₂") # plot log2
|
||||
```
|
||||
|
||||
Though we made three graphs, only two are seen, as the graph of `log2` matches that of the inverse function.
|
||||
Plot of $f(x) = 2^x$, its inverse function (e.g. `plot(ys,xs)`), and the function $\log_2(x)$.
|
||||
:::
|
||||
|
||||
|
||||
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.
|
||||
@@ -318,7 +309,7 @@ If $1/10$ of the original carbon $14$ remains, how old is the item? This amounts
|
||||
-5730 * log2(1/10)
|
||||
```
|
||||
|
||||
:::{.callout-note}
|
||||
::: {.callout-note}
|
||||
## Note
|
||||
(Historically) Libby and James Arnold proceeded to test the radiocarbon dating theory by analyzing samples with known ages. For example, two samples taken from the tombs of two Egyptian kings, Zoser and Sneferu, independently dated to $2625$ BC plus or minus $75$ years, were dated by radiocarbon measurement to an average of $2800$ BC plus or minus $250$ years. These results were published in Science in $1949$. Within $11$ years of their announcement, more than $20$ radiocarbon dating laboratories had been set up worldwide. Source: [Wikipedia](http://tinyurl.com/p5msnh6).
|
||||
|
||||
@@ -327,15 +318,19 @@ If $1/10$ of the original carbon $14$ remains, how old is the item? This amounts
|
||||
### 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$:
|
||||
|
||||
The basic graphs of logarithms ($a > 1$) are all similar with growth from $-\infty$ to $\infty$ as $x$ goes from just bigger than $0$ towards $\infty$. @fig-basic-logarithmic-graphs shows larger bases lead to slower growing functions, though all satisfy $\log_a(1) = 0$:
|
||||
|
||||
::: {#fig-basic-logarithmic-graphs}
|
||||
```{julia}
|
||||
plot(log2, 1/2, 10, label="2") # base 2
|
||||
plot!(log, 1/2, 10, label="e") # base e
|
||||
plot!(log10, 1/2, 10, label="10") # base 10
|
||||
#| echo: false
|
||||
plot(log2, 1/5, 10, label="log2") # base 2
|
||||
plot!(log, 1/5, 10, label="log") # base e
|
||||
plot!(log10, 1/5, 10, label="log10") # base 10
|
||||
```
|
||||
|
||||
Graphs of `log2`, `log` and `log10`
|
||||
:::
|
||||
|
||||
Now, what do the properties of exponents imply about logarithms?
|
||||
|
||||
|
||||
@@ -384,7 +379,11 @@ a^{(\log_b(x)/\log_b(a))} = (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 when $a, b$ are positive bases; $u,v$ are positive numbers; and $x$ is any real number:
|
||||
In short, we have three properties of logarithmic functions.
|
||||
|
||||
::: {.relationship title="Basic properties of logarithmic functions"}
|
||||
|
||||
If $a, b$ are positive bases; $u,v$ are positive numbers; and $x$ is any real number, then
|
||||
|
||||
|
||||
$$
|
||||
@@ -394,6 +393,7 @@ $$
|
||||
\log_a(u) &= \log_b(u)/\log_b(a).
|
||||
\end{align*}
|
||||
$$
|
||||
:::
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -534,7 +534,7 @@ radioq(choices, answ, keep_order=true)
|
||||
###### Question
|
||||
|
||||
|
||||
The [Loudest band](https://en.wikipedia.org/wiki/Loudest_band) can possibly be measured in [decibels](https://en.wikipedia.org/wiki/Decibel). 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?
|
||||
The [Loudest band](https://en.wikipedia.org/wiki/Loudest_band) can possibly quantified by measuring in [decibels](https://en.wikipedia.org/wiki/Decibel). 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?
|
||||
|
||||
|
||||
```{julia}
|
||||
|
||||
Reference in New Issue
Block a user