make pdf file generation work
This commit is contained in:
@@ -20,9 +20,13 @@ The following image is the calculator that Google presents upon searching for "c
|
||||
#
|
||||
imgfile = "figures/calculator.png"
|
||||
caption = "Screenshot of a calculator provided by the Google search engine."
|
||||
ImageFile(:precalc, imgfile, caption)
|
||||
# ImageFile(:precalc, imgfile, caption)
|
||||
nothing
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
This calculator should have a familiar appearance with a keypad of numbers, a set of buttons for arithmetic operations, a set of buttons for some common mathematical functions, a degree/radian switch, and buttons for interacting with the calculator: `Ans`, `AC` (also `CE`), and `=`.
|
||||
|
||||
|
||||
@@ -43,7 +47,7 @@ txt = """
|
||||
</iframe>
|
||||
</center>
|
||||
"""
|
||||
HTMLoutput(txt)
|
||||
a = HTMLoutput(txt)
|
||||
```
|
||||
|
||||
## Operations
|
||||
@@ -204,6 +208,16 @@ Below we use the underscore as a separator, which is parsed as commas are to sep
|
||||
|
||||
Or not quite a million per pound.
|
||||
|
||||
Using a pound is $2.2$ killograms or $2,200$ grams, we can this many ants per gram:
|
||||
|
||||
|
||||
```{julia}
|
||||
20_000_000_000_000_000 / (1_000_000 * 12 * 2000) / 2200
|
||||
```
|
||||
|
||||
Such combinations will be easier to check for correctness when variable names are assigned the respective values.
|
||||
|
||||
|
||||
|
||||
## Order of operations
|
||||
|
||||
@@ -816,7 +830,7 @@ radioq(choices, answ)
|
||||
###### Question
|
||||
|
||||
|
||||
In the U.S. version of the Office, the opening credits include a calculator calculation. The key sequence shown is `9653 +` which produces `11532`. What value was added to?
|
||||
In the U.S. version of the Office, the opening credits include a calculator calculation. The key sequence shown is `9653 +` which produces `11532`. What value was added to `9653`?
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -1040,7 +1054,7 @@ radioq(choices, answ)
|
||||
A twitter post from popular mechanics generated some attention.
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
What is the answer?
|
||||
|
||||
@@ -27,7 +27,7 @@ The family of exponential functions is defined by $f(x) = a^x, -\infty< x < \inf
|
||||
For a given $a$, defining $a^n$ for positive integers is straightforward, as it means multiplying $n$ copies of $a.$ From this, for *integer powers*, 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 example with $x=3$ and $y=2$:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
a^3 \cdot a^2 &= (a\cdot a \cdot a) \cdot (a \cdot a) \\
|
||||
&= (a \cdot a \cdot a \cdot a \cdot a) \\
|
||||
@@ -36,7 +36,7 @@ a^3 \cdot a^2 &= (a\cdot a \cdot a) \cdot (a \cdot a) \\
|
||||
&= (a\cdot a \cdot a \cdot a\cdot a \cdot a) \\
|
||||
&= a^6 = a^{3\cdot 2}.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
For $a \neq 0$, $a^0$ is defined to be $1$.
|
||||
|
||||
@@ -388,13 +388,13 @@ 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:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\log_a(uv) &= \log_a(u) + \log_a(v), \\
|
||||
\log_a(u^x) &= x \log_a(u), \text{ and} \\
|
||||
\log_a(u) &= \log_b(u)/\log_b(a).
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
##### Example
|
||||
|
||||
|
||||
@@ -69,13 +69,13 @@ However, typically we have a rule describing our function. What is the process t
|
||||
When we solve algebraically for $x$ in $y=9/5 \cdot x + 32$ we do the same thing as we do verbally: we subtract $32$ from each side, and then divide by $9/5$ to isolate $x$:
|
||||
|
||||
|
||||
$$
|
||||
\begin{align}
|
||||
|
||||
\begin{align*}
|
||||
y &= 9/5 \cdot x + 32\\
|
||||
y - 32 &= 9/5 \cdot x\\
|
||||
(y-32) / (9/5) &= x.
|
||||
\end{align}
|
||||
$$
|
||||
\end{align*}
|
||||
|
||||
|
||||
From this, we have the function $g(y) = (y-32) / (9/5)$ is the inverse function of $f(x) = 9/5\cdot x + 32$.
|
||||
|
||||
@@ -101,7 +101,7 @@ Suppose a transformation of $x$ is given by $y = f(x) = (ax + b)/(cx+d)$. This f
|
||||
From the expression $y=f(x)$ we *algebraically* solve for $x$:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
y &= \frac{ax +b}{cx+d}\\
|
||||
y \cdot (cx + d) &= ax + b\\
|
||||
@@ -109,7 +109,7 @@ ycx - ax &= b - yd\\
|
||||
(cy-a) \cdot x &= b - dy\\
|
||||
x &= -\frac{dy - b}{cy-a}.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
We see that to solve for $x$ we need to divide by $cy-a$, so this expression can not be zero. So, using $x$ as the dummy variable, we have
|
||||
|
||||
@@ -127,14 +127,14 @@ The function $f(x) = (x-1)^5 + 2$ is strictly increasing and so will have an inv
|
||||
Again, we solve algebraically starting with $y=(x-1)^5 + 2$ and solving for $x$:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
y &= (x-1)^5 + 2\\
|
||||
y - 2 &= (x-1)^5\\
|
||||
(y-2)^{1/5} &= x - 1\\
|
||||
(y-2)^{1/5} + 1 &= x.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
We see that $f^{-1}(x) = 1 + (x - 2)^{1/5}$. The fact that the power $5$ is an odd power is important, as this ensures a unique (real) solution to the fifth root of a value, in the above $y-2$.
|
||||
|
||||
@@ -170,14 +170,14 @@ The [inverse function theorem](https://en.wikipedia.org/wiki/Inverse_function_th
|
||||
Consider the function $f(x) = (1+x^2)^{-1}$. This bell-shaped function is even (symmetric about $0$), so can not possibly be one-to-one. However, if the domain is restricted to $[0,\infty)$ it is. The restricted function is strictly decreasing and its inverse is found, as follows:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
y &= \frac{1}{1 + x^2}\\
|
||||
1+x^2 &= \frac{1}{y}\\
|
||||
x^2 &= \frac{1}{y} - 1\\
|
||||
x &= \sqrt{(1-y)/y}, \quad 0 \leq y \leq 1.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
Then $f^{-1}(x) = \sqrt{(1-x)/x}$ where $0 < x \leq 1$. The somewhat complicated restriction for the the domain coincides with the range of $f(x)$. We shall see next that this is no coincidence.
|
||||
|
||||
|
||||
@@ -122,7 +122,11 @@ Thinking in terms of transformations, this looks like the function $f(x) = x$ (w
|
||||
The indeterminate value `x` (or some other symbol) in a polynomial, is like a variable in a function and unlike a variable in `Julia`. Variables in `Julia` are identifiers, just a means to look up a specific, already determined, value. Rather, the symbol `x` is not yet determined, it is essentially a place holder for a future value. Although we have seen that `Julia` makes it very easy to work with mathematical functions, it is not the case that base `Julia` makes working with expressions of algebraic symbols easy. This makes sense, `Julia` is primarily designed for technical computing, where numeric approaches rule the day. However, symbolic math can be used from within `Julia` through add-on packages.
|
||||
|
||||
|
||||
Symbolic math programs include well-known ones like the commercial programs Mathematica and Maple. Mathematica powers the popular [WolframAlpha](www.wolframalpha.com) website, which turns "natural" language into the specifics of a programming language. The open-source Sage project is an alternative to these two commercial giants. It includes a wide-range of open-source math projects available within its umbrella framework. (`Julia` can even be run from within the free service [cloud.sagemath.com](https://cloud.sagemath.com/projects).) A more focused project for symbolic math, is the [SymPy](www.sympy.org) Python library. SymPy is also used within Sage. However, SymPy provides a self-contained library that can be used standalone within a Python session. That is great for `Julia` users, as the `PyCall` and `PythonCall` packages glue `Julia` to Python in a seamless manner. This allows the `Julia` package `SymPy` to provide functionality from SymPy within `Julia`.
|
||||
Symbolic math programs include well-known ones like the commercial programs Mathematica and Maple. Mathematica powers the popular [WolframAlpha](www.wolframalpha.com) website, which turns "natural" language into the specifics of a programming language. The open-source [Sage](https://www.sagemath.org/) project is an alternative to these two commercial giants. It includes a wide-range of open-source math projects available within its umbrella framework. (`Julia` can even be run from within the free service [cloud.sagemath.com](https://cloud.sagemath.com/projects).) A more focused project for symbolic math, is the [SymPy](www.sympy.org) Python library. SymPy is also used within Sage. However, SymPy provides a self-contained library that can be used standalone within a Python session.
|
||||
|
||||
The [Symbolics](https://github.com/JuliaSymbolics/Symbolics.jl) package for `Julia` provides a "fast and modern CAS for fast and modern language." It is described further in [Symbolics.jl](../alternatives/symbolics.qmd).
|
||||
|
||||
As `SymPy` has some features not yet implemented in `Symbolics`, we use that her. The `PyCall` and `PythonCall` packages are available to glue `Julia` to Python in a seamless manner. These allow the `Julia` package `SymPy` to provide functionality from SymPy within `Julia`.
|
||||
|
||||
|
||||
:::{.callout-note}
|
||||
|
||||
@@ -249,13 +249,13 @@ A line, $y=mx+b$ can be a linear polynomial or a constant depending on $m$, so w
|
||||
Knowing we can succeed, we approach the problem of $3$ points, say $(x_0, y_0)$, $(x_1,y_1)$, and $(x_2, y_2)$. There is a polynomial $p = a\cdot x^2 + b\cdot x + c$ with $p(x_i) = y_i$. This gives $3$ equations for the $3$ unknown values $a$, $b$, and $c$:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
a\cdot x_0^2 + b\cdot x_0 + c &= y_0\\
|
||||
a\cdot x_1^2 + b\cdot x_1 + c &= y_1\\
|
||||
a\cdot x_2^2 + b\cdot x_2 + c &= y_2\\
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
Solving this with `SymPy` is tractable. A comprehension is used below to create the $3$ equations; the `zip` function is a simple means to iterate over $2$ or more iterables simultaneously:
|
||||
|
||||
@@ -388,13 +388,13 @@ radioq(choices, answ, keep_order=true)
|
||||
Consider the polynomial $p(x) = a_1 x - a_3 x^3 + a_5 x^5$ where
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
a_1 &= 4(\frac{3}{\pi} - \frac{9}{16}) \\
|
||||
a_3 &= 2a_1 -\frac{5}{2}\\
|
||||
a_5 &= a_1 - \frac{3}{2}.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
* Form the polynomial `p` by first computing the $a$s and forming `p=Polynomial([0,a1,0,-a3,0,a5])`
|
||||
* Form the polynomial `q` by these commands `x=variable(); q=p(2x/pi)`
|
||||
@@ -544,13 +544,13 @@ This last answer is why $p$ is called an *interpolating* polynomial and this que
|
||||
The Chebyshev ($T$) polynomials are polynomials which use a different basis from the standard basis. Denote the basis elements $T_0$, $T_1$, ... where we have $T_0(x) = 1$, $T_1(x) = x$, and for bigger indices $T_{i+1}(x) = 2xT_i(x) - T_{i-1}(x)$. The first others are then:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
T_2(x) &= 2xT_1(x) - T_0(x) = 2x^2 - 1\\
|
||||
T_3(x) &= 2xT_2(x) - T_1(x) = 2x(2x^2-1) - x = 4x^3 - 3x\\
|
||||
T_4(x) &= 2xT_3(x) - T_2(x) = 2x(4x^3-3x) - (2x^2-1) = 8x^4 - 8x^2 + 1
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
With these definitions what is the polynomial associated to the coefficients $[0,1,2,3]$ with this basis?
|
||||
|
||||
|
||||
@@ -111,13 +111,13 @@ $$
|
||||
If can be helpful to think of the argument to $f$ as a "box" that gets filled in by $g$:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
g(x) &=e^x - x\\
|
||||
f(\square) &= (\square)^2 + 2(\square) - 1\\
|
||||
f(g(x)) &= (g(x))^2 + 2(g(x)) - 1 = (e^x - x)^2 + 2(e^x - x) - 1.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
Here we look at a few compositions:
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@ annotate!([(.75, .25, "θ"), (4.0, 1.25, "opposite"), (2, -.25, "adjacent"), (1.
|
||||
With these, the basic definitions for the primary trigonometric functions are
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\sin(\theta) &= \frac{\text{opposite}}{\text{hypotenuse}} &\quad(\text{the sine function})\\
|
||||
\cos(\theta) &= \frac{\text{adjacent}}{\text{hypotenuse}} &\quad(\text{the cosine function})\\
|
||||
\tan(\theta) &= \frac{\text{opposite}}{\text{adjacent}}. &\quad(\text{the tangent function})
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
:::{.callout-note}
|
||||
## Note
|
||||
@@ -119,12 +119,12 @@ Julia has the $6$ basic trigonometric functions defined through the functions `s
|
||||
Two right triangles - the one with equal, $\pi/4$, angles; and the one with angles $\pi/6$ and $\pi/3$ can have the ratio of their sides computed from basic geometry. In particular, this leads to the following values, which are usually committed to memory:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\sin(0) &= 0, \quad \sin(\pi/6) = \frac{1}{2}, \quad \sin(\pi/4) = \frac{\sqrt{2}}{2}, \quad\sin(\pi/3) = \frac{\sqrt{3}}{2},\text{ and } \sin(\pi/2) = 1\\
|
||||
\cos(0) &= 1, \quad \cos(\pi/6) = \frac{\sqrt{3}}{2}, \quad \cos(\pi/4) = \frac{\sqrt{2}}{2}, \quad\cos(\pi/3) = \frac{1}{2},\text{ and } \cos(\pi/2) = 0.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
Using the circle definition allows these basic values to inform us of values throughout the unit circle.
|
||||
|
||||
@@ -360,8 +360,9 @@ As can be seen, even a somewhat simple combination can produce complicated graph
|
||||
```{julia}
|
||||
#| echo: false
|
||||
txt ="""
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/rrmx2Q3sO1Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
<iframe width="560" height="315" src="https://www.youtube.com/embed/rrmx2Q3sO1Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
"""
|
||||
|
||||
HTMLoutput(txt; centered=true, caption="Julia logo animated")
|
||||
```
|
||||
|
||||
@@ -391,21 +392,24 @@ According to [Wikipedia](https://en.wikipedia.org/wiki/Trigonometric_functions#I
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
ImageFile(:precalc, "figures/summary-sum-and-difference-of-two-angles.jpg", "Relations between angles")
|
||||
# ImageFile(:precalc, "figures/summary-sum-and-difference-of-two-angles.jpg", "Relations between angles")
|
||||
nothing
|
||||
```
|
||||
|
||||

|
||||
|
||||
To read this, there are three triangles: the bigger (green with pink part) has hypotenuse $1$ (and adjacent and opposite sides that form the hypotenuses of the other two); the next biggest (yellow) hypotenuse $\cos(\beta)$, adjacent side (of angle $\alpha$) $\cos(\beta)\cdot \cos(\alpha)$, and opposite side $\cos(\beta)\cdot\sin(\alpha)$; and the smallest (pink) hypotenuse $\sin(\beta)$, adjacent side (of angle $\alpha$) $\sin(\beta)\cdot \cos(\alpha)$, and opposite side $\sin(\beta)\sin(\alpha)$.
|
||||
|
||||
|
||||
This figure shows the following sum formula for sine and cosine:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\sin(\alpha + \beta) &= \sin(\alpha)\cos(\beta) + \cos(\alpha)\sin(\beta), & (\overline{CE} + \overline{DF})\\
|
||||
\cos(\alpha + \beta) &= \cos(\alpha)\cos(\beta) - \sin(\alpha)\sin(\beta). & (\overline{AC} - \overline{DE})
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
Using the fact that $\sin$ is an odd function and $\cos$ an even function, related formulas for the difference $\alpha - \beta$ can be derived.
|
||||
|
||||
@@ -413,12 +417,12 @@ Using the fact that $\sin$ is an odd function and $\cos$ an even function, relat
|
||||
Taking $\alpha = \beta$ we immediately get the "double-angle" formulas:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\sin(2\alpha) &= 2\sin(\alpha)\cos(\alpha)\\
|
||||
\cos(2\alpha) &= \cos(\alpha)^2 - \sin(\alpha)^2.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
The latter looks like the Pythagorean identify, but has a minus sign. In fact, the Pythagorean identify is often used to rewrite this, for example $\cos(2\alpha) = 2\cos(\alpha)^2 - 1$ or $1 - 2\sin(\alpha)^2$.
|
||||
|
||||
@@ -432,12 +436,12 @@ Applying the above with $\alpha = \beta/2$, we get that $\cos(\beta) = 2\cos(\be
|
||||
Consider the expressions $\cos((n+1)\theta)$ and $\cos((n-1)\theta)$. These can be re-expressed as:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\cos((n+1)\theta) &= \cos(n\theta + \theta) = \cos(n\theta) \cos(\theta) - \sin(n\theta)\sin(\theta), \text{ and}\\
|
||||
\cos((n-1)\theta) &= \cos(n\theta - \theta) = \cos(n\theta) \cos(-\theta) - \sin(n\theta)\sin(-\theta).
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
But $\cos(-\theta) = \cos(\theta)$, whereas $\sin(-\theta) = -\sin(\theta)$. Using this, we add the two formulas above to get:
|
||||
|
||||
@@ -663,12 +667,12 @@ end
|
||||
These values are more commonly expressed using the exponential function as:
|
||||
|
||||
|
||||
$$
|
||||
|
||||
\begin{align*}
|
||||
\sinh(x) &= \frac{e^x - e^{-x}}{2}\\
|
||||
\cosh(x) &= \frac{e^x + e^{-x}}{2}.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
The hyperbolic tangent is then the ratio of $\sinh$ and $\cosh$. As well, three inverse hyperbolic functions can be defined.
|
||||
|
||||
|
||||
@@ -18,9 +18,13 @@ nothing
|
||||
#| echo: false
|
||||
imgfile = "figures/calculator.png"
|
||||
caption = "Screenshot of a calculator provided by the Google search engine."
|
||||
ImageFile(:precalc, imgfile, caption)
|
||||
# ImageFile(:precalc, imgfile, caption)
|
||||
nothing
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
The Google calculator has a button `Ans` to refer to the answer to the previous evaluation. This is a form of memory. The last answer is stored in a specific place in memory for retrieval when `Ans` is used. In some calculators, more advanced memory features are possible. For some, it is possible to push values onto a stack of values for them to be referred to at a later time. This proves useful for complicated expressions, say, as the expression can be broken into smaller intermediate steps to be computed. These values can then be appropriately combined. This strategy is a good one, though the memory buttons can make its implementation a bit cumbersome.
|
||||
|
||||
|
||||
|
||||
@@ -83,13 +83,14 @@ For the motion in the above figure, the object's $x$ and $y$ values change accor
|
||||
It is common to work with *both* formulas at once. Mathematically, when graphing, we naturally pair off two values using Cartesian coordinates (e.g., $(x,y)$). Another means of combining related values is to use a *vector*. The notation for a vector varies, but to distinguish them from a point we will use $\langle x,~ y\rangle$. With this notation, we can use it to represent the position, the velocity, and the acceleration at time $t$ through:
|
||||
|
||||
|
||||
$$
|
||||
\begin{align}
|
||||
|
||||
\begin{align*}
|
||||
\vec{x} &= \langle x_0 + v_{0x}t,~ -(1/2) g t^2 + v_{0y}t + y_0 \rangle,\\
|
||||
\vec{v} &= \langle v_{0x},~ -gt + v_{0y} \rangle, \text{ and }\\
|
||||
\vec{a} &= \langle 0,~ -g \rangle.
|
||||
\end{align}
|
||||
$$
|
||||
\end{align*}
|
||||
|
||||
|
||||
|
||||
Don't spend time thinking about the formulas if they are unfamiliar. The point emphasized here is that we have used the notation $\langle x,~ y \rangle$ to collect the two values into a single object, which we indicate through a label on the variable name. These are vectors, and we shall see they find use far beyond this application.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user