make pdf file generation work

This commit is contained in:
jverzani
2022-10-10 14:28:05 -04:00
parent a0b913eed8
commit a9ca131870
59 changed files with 884 additions and 1330 deletions

View File

@@ -36,13 +36,11 @@ nothing
Consider a function $f: R^n \rightarrow R$. It has multiple arguments for its input (an $x_1, x_2, \dots, x_n$) and only one, *scalar*, value for an output. Some simple examples might be:
$$
\begin{align}
\begin{align*}
f(x,y) &= x^2 + y^2\\
g(x,y) &= x \cdot y\\
h(x,y) &= \sin(x) \cdot \sin(y)
\end{align}
$$
\end{align*}
For two examples from real life consider the elevation Point Query Service (of the [USGS](https://nationalmap.gov/epqs/)) returns the elevation in international feet or meters for a specific latitude/longitude within the United States. The longitude can be associated to an $x$ coordinate, the latitude to a $y$ coordinate, and the elevation a $z$ coordinate, and as long as the region is small enough, the $x$-$y$ coordinates can be thought to lie on a plane. (A flat earth assumption.)
@@ -468,9 +466,12 @@ imgfile = "figures/daily-map.jpg"
caption = """
Image from [weather.gov](https://www.weather.gov/unr/1943-01-22) of a contour map showing atmospheric pressures from January 22, 1943 in Rapid City, South Dakota.
"""
ImageFile(:differentiable_vector_calculus, imgfile, caption)
# ImageFile(:differentiable_vector_calculus, imgfile, caption)
nothing
```
![Image from [weather.gov](https://www.weather.gov/unr/1943-01-22) of a contour map showing atmospheric pressures from January 22, 1943 in Rapid City, South Dakota.](./figures/daily-map.jpg)
This day is highlighted as "The most notable temperature fluctuations occurred on January 22, 1943 when temperatures rose and fell almost 50 degrees in a few minutes. This phenomenon was caused when a frontal boundary separating extremely cold Arctic air from warmer Pacific air rolled like an ocean tide along the northern and eastern slopes of the Black Hills."
@@ -490,9 +491,18 @@ imgfile = "figures/australia.png"
caption = """
Image from [IRI](https://iridl.ldeo.columbia.edu/maproom/Global/Ocean_Temp/Monthly_Temp.html) shows mean sea surface temperature near Australia in January 1982. IRI has zoomable graphs for this measurement from 1981 to the present. The contour lines are in 2 degree Celsius increments.
"""
ImageFile(:differentiable_vector_calculus, imgfile, caption)
#ImageFile(:differentiable_vector_calculus, imgfile, caption)
nothing
```
![Image from
[IRI](https://iridl.ldeo.columbia.edu/maproom/Global/Ocean_Temp/Monthly_Temp.html)
shows mean sea surface temperature near Australia in January 1982. IRI
has zoomable graphs for this measurement from 1981 to the present. The
contour lines are in 2 degree Celsius
increments.](./figures/australia.png)
##### Example
@@ -621,26 +631,23 @@ Before answering this, we discuss *directional* derivatives along the simplified
If we compose $f \circ \vec\gamma_x$, we can visualize this as a curve on the surface from $f$ that moves in the $x$-$y$ plane along the line $y=c$. The derivative of this curve will satisfy:
$$
\begin{align}
\begin{align*}
(f \circ \vec\gamma_x)'(x) &=
\lim_{t \rightarrow x} \frac{(f\circ\vec\gamma_x)(t) - (f\circ\vec\gamma_x)(x)}{t-x}\\
&= \lim_{t\rightarrow x} \frac{f(t, c) - f(x,c)}{t-x}\\
&= \lim_{h \rightarrow 0} \frac{f(x+h, c) - f(x, c)}{h}.
\end{align}
$$
\end{align*}
The latter expresses this to be the derivative of the function that holds the $y$ value fixed, but lets the $x$ value vary. It is the rate of change in the $x$ direction. There is special notation for this:
$$
\begin{align}
\begin{align*}
\frac{\partial f(x,y)}{\partial x} &=
\lim_{h \rightarrow 0} \frac{f(x+h, y) - f(x, y)}{h},\quad\text{and analogously}\\
\frac{\partial f(x,y)}{\partial y} &=
\lim_{h \rightarrow 0} \frac{f(x, y+h) - f(x, y)}{h}.
\end{align}
$$
\end{align*}
These are called the *partial* derivatives of $f$. The symbol $\partial$, read as "partial", is reminiscent of "$d$", but indicates the derivative is only in a given direction. Other notations exist for this:
@@ -678,12 +685,10 @@ Let $f(x,y) = x^2 - 2xy$, then to compute the partials, we just treat the other
Then
$$
\begin{align}
\begin{align*}
\frac{\partial (x^2 - 2xy)}{\partial x} &= 2x - 2y\\
\frac{\partial (x^2 - 2xy)}{\partial y} &= 0 - 2x = -2x.
\end{align}
$$
\end{align*}
Combining, gives $\nabla{f} = \langle 2x -2y, -2x \rangle$.
@@ -691,13 +696,12 @@ Combining, gives $\nabla{f} = \langle 2x -2y, -2x \rangle$.
If $g(x,y,z) = \sin(x) + z\cos(y)$, then
$$
\begin{align}
\begin{align*}
\frac{\partial g }{\partial x} &= \cos(x) + 0 = \cos(x),\\
\frac{\partial g }{\partial y} &= 0 + z(-\sin(y)) = -z\sin(y),\\
\frac{\partial g }{\partial z} &= 0 + \cos(y) = \cos(y).
\end{align}
$$
\end{align*}
Combining, gives $\nabla{g} = \langle \cos(x), -z\sin(y), \cos(y) \rangle$.
@@ -1379,16 +1383,14 @@ $$
The last expression is a suggestion, as it is an abuse of previously used notation: the dot product isn't between vectors of the same type, as the rightmost vector is representing a vector of vectors. The [Jacobian](https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant) matrix combines these vectors into a rectangular array, though with the vectors written as *row* vectors. If $G: R^m \rightarrow R^n$, then the Jacobian is the $n \times m$ matrix with $(i,j)$ entry given by $\partial G_i, \partial u_j$:
$$
J = \left[
\begin{align}
J =
\begin{bmatrix}
\frac{\partial G_1}{\partial u_1} & \frac{\partial G_1}{\partial u_2} & \dots \frac{\partial G_1}{\partial u_m}\\
\frac{\partial G_2}{\partial u_1} & \frac{\partial G_2}{\partial u_2} & \dots \frac{\partial G_2}{\partial u_m}\\
& \vdots & \\
\frac{\partial G_n}{\partial u_1} & \frac{\partial G_n}{\partial u_2} & \dots \frac{\partial G_n}{\partial u_m}
\end{align}
\right].
\end{bmatrix}
$$
With this notation, and matrix multiplication we have $(\nabla(f\circ G))^t = \nabla(f)^t J$.
@@ -1406,20 +1408,17 @@ Let $f(x,y) = x^2 + y^2$ be a scalar function. We have if $G(r, \theta) = \langl
Were this computed through the chain rule, we have:
$$
\begin{align}
\begin{align*}
\nabla G_1 &= \langle \frac{\partial r\cos(\theta)}{\partial r}, \frac{\partial r\cos(\theta)}{\partial \theta} \rangle=
\langle \cos(\theta), -r \sin(\theta) \rangle,\\
\nabla G_2 &= \langle \frac{\partial r\sin(\theta)}{\partial r}, \frac{\partial r\sin(\theta)}{\partial \theta} \rangle=
\langle \sin(\theta), r \cos(\theta) \rangle.
\end{align}
$$
\end{align*}
We have $\partial f/\partial x = 2x$ and $\partial f/\partial y = 2y$, which at $G$ are $2r\cos(\theta)$ and $2r\sin(\theta)$, so by the chain rule, we should have
$$
\begin{align}
\begin{align*}
\frac{\partial (f\circ G)}{\partial r} &=
\frac{\partial{f}}{\partial{x}}\frac{\partial G_1}{\partial r} +
\frac{\partial{f}}{\partial{y}}\frac{\partial G_2}{\partial r} =
@@ -1429,8 +1428,8 @@ $$
\frac{\partial f}{\partial x}\frac{\partial G_1}{\partial \theta} +
\frac{\partial f}{\partial y}\frac{\partial G_2}{\partial \theta} =
2r\cos(\theta)(-r\sin(\theta)) + 2r\sin(\theta)(r\cos(\theta)) = 0.
\end{align}
$$
\end{align*}
## Higher order partial derivatives
@@ -1487,14 +1486,11 @@ is uniquely defined. That is, which order the partial derivatives are taken is u
The [Hessian](https://en.wikipedia.org/wiki/Hessian_matrix) matrix is the matrix of mixed partials defined (for $n=2$) by:
$$
H = \left[
\begin{align}
H = \begin{bmatrix}
\frac{\partial^2 f}{\partial x \partial x} & \frac{\partial^2 f}{\partial x \partial y}\\
\frac{\partial^2 f}{\partial y \partial x} & \frac{\partial^2 f}{\partial y \partial y}
\end{align}
\right].
\end{bmatrix}.
$$
For symbolic expressions, the Hessian may be computed directly in `SymPy` with its `hessian` function:
@@ -1673,9 +1669,12 @@ The figure (taken from [openstreetmap.org](https://www.openstreetmap.org/way/537
```{julia}
#| hold: true
#| echo: false
ImageFile(:differentiable_vector_calculus, "figures/stelvio-pass.png", "Stelvio Pass")
#ImageFile(:differentiable_vector_calculus, "figures/stelvio-pass.png", "Stelvio Pass")
nothing
```
![Stelvio Pass](./figures/stelvio-pass.png)
The road through the pass (on the right) makes a series of switch backs.
@@ -1903,9 +1902,12 @@ The figure shows climbers on their way to summit Mt. Everest:
#| echo: false
imgfile = "figures/everest.png"
caption = "Climbers en route to the summit of Mt. Everest"
ImageFile(:differentiable_vector_calculus, imgfile, caption)
#ImageFile(:differentiable_vector_calculus, imgfile, caption)
nothing
```
![Climbers en route to the summit of Mt. Everest](./figures/everest.png)
If the surface of the mountain is given by a function $z=f(x,y)$ then the climbers move along a single path parameterized, say, by $\vec{\gamma}(t) = \langle x(t), y(t)\rangle$, as set up by the Sherpas.
@@ -2301,7 +2303,7 @@ $$
\frac{f(x+\Delta x, y + \Delta y) - f(x, y+\Delta{y}) - f(x+\Delta x,y) + f(x,y)}{\Delta x \Delta y}.
$$
At $(0,0)$ what is $ \frac{\partial \frac{\partial f}{\partial x}}{ \partial y}$?
At $(0,0)$ what is $\frac{\partial \frac{\partial f}{\partial x}}{ \partial y}$?
```{julia}
@@ -2311,7 +2313,7 @@ answ = -1
numericq(answ)
```
At $(0,0)$ what is $ \frac{\partial \frac{\partial f}{\partial y}}{ \partial x}$?
At $(0,0)$ what is $\frac{\partial \frac{\partial f}{\partial y}}{ \partial x}$?
```{julia}