lots of cleanup

This commit is contained in:
jverzani
2026-08-11 17:17:08 -04:00
parent ae461659e0
commit 253295ff6e
91 changed files with 18284 additions and 7872 deletions

View File

@@ -9,8 +9,7 @@ This section uses these add-on packages:
```{julia}
using CalculusWithJulia
using Plots
plotly()
using Plots; plotly()
using SymPy
using QuadGK
```
@@ -21,38 +20,22 @@ using QuadGK
## Surfaces of revolution
::: {#fig-gehry-hendrix-museum}
```{julia}
#| hold: true
#| echo: false
imgfile = "figures/gehry-hendrix.jpg"
caption = """
![](./figures/gehry-hendrix.jpg)
The exterior of the Jimi Hendrix Museum in Seattle has the signature
style of its architect Frank Gehry. The surface is comprised of
patches. A general method to find the amount of material to cover the
surface - the surface area - might be to add up the area of *each* of the
surface---the surface area---might be to add up the area of *each* of the
patches. However, in this section we will see for surfaces of
revolution, there is an easier way. (Photo credit to
[firepanjewellery](http://firepanjewellery.com/).)
"""
:::
# ImageFile(:integrals, imgfile, caption)
nothing
```
In this section we see how to find the surface area of volumes generated by revolution.
![The exterior of the Jimi Hendrix Museum in Seattle has the signature
style of its architect Frank Gehry. The surface is comprised of
patches. A general method to find the amount of material to cover the
surface - the surface area - might be to add up the area of *each* of the
patches. However, in this section we will see for surfaces of
revolution, there is an easier way. (Photo credit to
[firepanjewellery](http://firepanjewellery.com/).)
](./figures/gehry-hendrix.jpg)
::: {.callout-note icon=false}
## Surface area of a rotated curve
::: {.definition title="Surface area of a rotated curve"}
The surface area generated by rotating the graph of $f(x)$ between $a$ and $b$ about the $x$-axis is given by the integral
@@ -70,7 +53,7 @@ These formulas do not add in the surface area of either of the ends.
:::
::: {#fig-surface-revolution-cone}
```{julia}
#| hold: true
#| echo: false
@@ -82,6 +65,9 @@ surface(ws..., legend=false)
plot!([-0.5,1.5], [0,0],[0,0])
```
Surface of revolution forming a cone
:::
The above figure shows a cone (the line $y=x$) presented as a surface of revolution about the $x$-axis.
@@ -234,7 +220,7 @@ Illustration of function $(g(t), f(t))$ rotated about the $x$ axis with a secti
Consider a right-circular cone parameterized by an angle $\theta$ which at a given height has radius $r$ and slant height $l$ (so that the height satisfies $r/l=\sin(\theta)$). If this cone were made of paper, cut up a side, and laid out flat, it would form a sector of a circle, as illustrated below:
Consider a right-circular cone parameterized by an angle $\theta$ which at a given height has radius $r$ and slant height $l$ (so that the height satisfies $r/l=\sin(\theta)$). If this cone were made of paper, cut up a side, and laid out flat, it would form a sector of a circle, as illustrated in @fig-frustum-cone-area.
::: {#fig-frustum-cone-area}
@@ -433,8 +419,10 @@ Putting this altogether we get that the surface area generarated by rotating the
$$
\text{sa}_i = \pi (f(t_i)^2 - f(t_{i-1})^2) \cdot \sqrt{(\Delta g)^2 + (\Delta f)^2} / \Delta f =
2\pi \frac{f(t_i) + f(t_{i-1})}{2} \cdot \sqrt{(\Delta g)^2 + (\Delta f)^2}.
\begin{align*}
\text{sa}_i &= \pi \left(f(t_i)^2 - f(t_{i-1})^2\right) \cdot \sqrt{(\Delta g)^2 + (\Delta f)^2} / \Delta f\\
&= 2\pi \frac{f(t_i) + f(t_{i-1})}{2} \cdot \sqrt{(\Delta g)^2 + (\Delta f)^2}.
\end{align*}
$$
(This is $2 \pi$ times the average radius times the slant height.)
@@ -444,10 +432,10 @@ As was done in the derivation of the formula for arc length, these pieces are mu
$$
\text{sa}_i = \pi (f(t_i) + f(t_{i-1})) \cdot \sqrt{(g'(\xi))^2 + (f'(\psi))^2} \cdot (t_i - t_{i-1}).
\text{sa}_i = \pi \left(f(t_i) + f(t_{i-1})\right) \cdot \sqrt{(g'(\xi))^2 + (f'(\psi))^2} \cdot (t_i - t_{i-1}).
$$
Adding these up, $\text{sa}_1 + \text{sa}_2 + \cdots + \text{sa}_n$, we get a Riemann sum approximation to the integral
Adding these up, $\text{sa}_1 + \text{sa}_2 + \cdots + \text{sa}_n$, we get a Riemann sum approximation to the integral:
$$
@@ -472,7 +460,7 @@ $$
\begin{align*}
\int_0^h 2\pi f(x) \sqrt{1 + f'(x)^2}dx
&= \int_0^h 2\pi x \tan(\theta) \sqrt{1 + \tan(\theta)^2}dx \\
&= (2\pi\tan(\theta)\sqrt{1 + \tan(\theta)^2}) x^2/2 \big|_0^h \\
&= (2\pi\tan(\theta)\sqrt{1 + \tan(\theta)^2}) \frac{x^2}{2} \Big|_0^h \\
&= \pi \tan(\theta) \sec(\theta) h^2 \\
&= \pi r^2 / \sin(\theta).
\end{align*}
@@ -522,47 +510,65 @@ f(u) = 2cos(u)
a, b = 0, 2pi
```
The plot of this curve is:
The plot of this curve is shown in @fig-plot-of-some-circle-begin-rotated.
::: {#fig-plot-of-some-circle-begin-rotated}
```{julia}
#| hold: true
us = range(a, b, length=100)
plot(g.(us), f.(us), xlims=(-0.5, 9), aspect_ratio=:equal, legend=false)
plot!([(0, -3), (0, 3)], line=(:red, 5)) # z axis emphasis
plot!([(3, 0), (9, 0)], line=(:green, 5)) # x axis emphasis
plot!([(0, -3), (0, 3)], line=(5, :red)) # z axis emphasis
plot!([(3, 0), (9, 0)], line=(5, :green)) # x axis emphasis
```
Plot of curve to be rotated to form a torus
:::
Though parametric plots have a convenience constructor, `plot(g, f, a, b)`, we constructed the points with `Julia`'s broadcasting notation, as we will need to do for a surface of revolution. The `xlims` are adjusted to show the $y$ axis, which is emphasized with a layered line. The line is drawn by specifying two points, $(x_0, y_0)$ and $(x_1, y_1)$ using tuples and wrapping in a vector.
Though parametric plots have a convenience constructor, `plot(g, f, a, b)`, we constructed the points with `Julia`'s broadcasting notation, as we will need to do for a surface of revolution. The `xlims` are adjusted to show the $y$ axis, which is emphasized with a layered line. (The line is drawn by specifying two points, $(x_0, y_0)$ and $(x_1, y_1)$, using tuples and wrapping in a vector.)
Now, to rotate this about the $z$ axis, creating a surface plot, we have the following pattern:
Now, to rotate this about the $z$ axis, creating a surface plot, we have the following pattern. First we form a function $S$ of two variables in terms of $g$ and $f$:
```{julia}
S(u,v) = [g(u)*cos(v), g(u)*sin(v), f(u)]
```
The steps to plot the surface are then always similar, save for possibly adjustments to the viewing window, as is done with `zlims` in forming @fig-torus-plotted-as-rotated-parameterized-circle-of-radius-2
::: {#fig-torus-plotted-as-rotated-parameterized-circle-of-radius-2}
```{julia}
us = range(a, b, length=100)
vs = range(0, 2pi, length=100)
ws = unzip(S.(us, vs')) # reorganize data
surface(ws..., zlims=(-6,6), legend=false)
plot!([(0,0,-3), (0,0,3)], line=(:red, 5)) # z axis emphasis
ws = unzip(S.(us, vs')) # reorganize data into 3 vectors
surface(ws...; zlims=(-10,10), legend=false)
plot!([(0, 0, -10), (0, 0, 10)]; line=(5, :red, 0.25)) # add axis of rotation
```
A circle of radius $2$ rotated about the $z$ axis forms a torus
:::
The `unzip` function is not part of base `Julia`, rather part of `CalculusWithJulia` (it is really `SplitApplyCombine`'s `invert` function). This function rearranges data into a form consumable by the plotting methods like `surface`. In this case, the result of `S.(us,vs')` is a grid (matrix) of points, the result of `unzip` is three grids of values, one for the $x$ values, one for the $y$ values, and one for the $z$ values. A manual adjustment to the `zlims` is used, as `aspect_ratio` does not have an effect with the `plotly()` backend.
To rotate this about the $x$ axis, we have this pattern:
To rotate this region about the $x$ axis, we have the pattern forming @fig-surface-of-rotation-formed-by-rotating-about-x-axis.
::: {#fig-surface-of-rotation-formed-by-rotating-about-x-axis}
```{julia}
S(u,v) = [g(u), f(u)*cos(v), f(u)*sin(v)]
us = range(a, b, length=100)
vs = range(0, 2pi, length=100)
ws = unzip(S.(us,vs'))
plot([(3,0,0), (9,0,0)], line=(:green,5)) # x axis emphasis
surface!(ws..., legend=false)
surface(ws...; zlims=(-3,3), legend=false)
plot!([(3,0,0), (9,0,0)], line=(5, :green)) # emphasize axis of rotation
```
The above pattern covers the case of rotating the graph of a function $f(x)$ of $a,b$ by taking $g(t)=t$.
Figure showing rotation of circle parameterized by $(g, f)$ being rotated around the $x$ axis
:::
The above pattern covers the case of rotating the graph of a function $f(x)$ over $[a,b]$ by taking $g(t)=t$.
##### Example
@@ -584,17 +590,19 @@ val
(The function is not defined at $x=0$ mathematically, but is on the computer to be $1$, the limiting value. Even were this not the case, the `quadgk` function doesn't evaluate the function at the points `a` and `b` that are specified.)
::: {#fig-rotate-x-to-x-about-x-axis}
```{julia}
#| hold: true
g(u) = u
f(u) = u^u
S(u,v) = [g(u), f(u)*cos(v), f(u)*sin(v)]
us = range(0, 3/2, length=100)
vs = range(0, pi, length=100) # not 2pi (to see inside)
vs = range(0, pi, length=100) # not 2pi (to see inside)
ws = unzip(S.(us,vs'))
surface(ws..., alpha=0.75)
```
Partial rotation of $x^x$ about the $x$ axis
:::
We compare this answer to that of the frustum of a cone with radii $1$ and $(3/2)^2$, formed by rotating the line segment connecting $(0,f(0))$ with $(3/2,f(3/2))$. From looking at the graph of the surface, these values should be comparable. The surface area of the cone part is $\pi (r_1^2 - r_0^2) / \sin(\theta) = \pi (r_1 + r_0) \cdot \sqrt{(\Delta h)^2 + (r_1-r_0)^2}$.
@@ -613,8 +621,10 @@ What is the surface area generated by Gabriel's Horn, the solid formed by rotati
$$
\text{SA} = \int_a^b 2\pi f(x) \sqrt{1 + f'(x)^2}dx =
\lim_{M \rightarrow \infty} \int_1^M 2\pi \frac{1}{x} \sqrt{1 + (-1/x^2)^2} dx.
\begin{align*}
\text{SA} &= \int_1^\infty 2\pi f(x) \sqrt{1 + f'(x)^2}dx \\
&= \lim_{M \rightarrow \infty} \int_1^M 2\pi \frac{1}{x} \sqrt{1 + (-1/x^2)^2} dx.
\end{align*}
$$
We do this with `SymPy`:
@@ -632,7 +642,7 @@ The limit as $M$ gets large is of interest. The only term that might get out of
limit(asinh(M), M => oo)
```
So indeed it does. There is nothing to balance this out, so the integral will be infinite, as this shows:
So indeed that term gets out of hand. There is nothing to balance this out, so the integral will be infinite, as this shows:
```{julia}
@@ -648,9 +658,9 @@ This figure would have infinite surface, were it possible to actually construct
The curve described parametrically by $g(t) = 2(1 + \cos(t))\cos(t)$ and $f(t) = 2(1 + \cos(t))\sin(t)$ from $0$ to $\pi$ is rotated about the $x$ axis. Find the resulting surface area.
The graph shows half a heart, the resulting area will resemble an apple.
@fig-rotate-heart-to-get-apple shows half a heart, the resulting rotated surface area will resemble an apple.
::: {#fig-rotate-heart-to-get-apple}
```{julia}
#| hold: true
g(t) = 2(1 + cos(t)) * cos(t)
@@ -658,6 +668,9 @@ f(t) = 2(1 + cos(t)) * sin(t)
plot(g, f, 0, 1pi)
```
Paremeterized curve to rotate about $x$ axis
:::
The integrand simplifies to $8\sqrt{2}\pi \sin(t) (1 + \cos(t))^{3/2}$. This lends itself to $u$-substitution with $u=\cos(t)$.
@@ -665,7 +678,7 @@ $$
\begin{align*}
\int_0^\pi 8\sqrt{2}\pi \sin(t) (1 + \cos(t))^{3/2}
&= 8\sqrt{2}\pi \int_1^{-1} (1 + u)^{3/2} (-1) du\\
&= 8\sqrt{2}\pi (2/5) (1+u)^{5/2} \big|_{-1}^1\\
&= 8\sqrt{2}\pi (2/5) (1+u)^{5/2} \Big|_{-1}^1\\
&= 8\sqrt{2}\pi (2/5) 2^{5/2} = \frac{2^7 \pi}{5}.
\end{align*}
$$
@@ -681,13 +694,13 @@ $$
\text{SA} = 2 \pi \rho L
$$
That is, the surface area is simply the circumference of the circle traced out by the centroid of the curve times the length of the curve - the distances rotated are collapsed to that of just the centroid.
That is, the surface area is simply the circumference of the circle traced out by the centroid of the curve times the length of the curve---the distances rotated are collapsed to that of just the centroid.
##### Example
The surface area of an open cone can be computed, as the arc length is $\sqrt{h^2 + r^2}$ and the centroid of the line is a distance $r/2$ from the axis. This gives SA$=2\pi (r/2) \sqrt{h^2 + r^2} = \pi r \sqrt{h^2 + r^2}$.
The surface area of an open cone can be computed, as the arc length is $\sqrt{h^2 + r^2}$ and the centroid *of the line* is a distance $r/2$ from the axis. This gives $\text{SA} = 2\pi (r/2) \sqrt{h^2 + r^2} = \pi r \sqrt{h^2 + r^2}$.
##### Example
@@ -696,22 +709,9 @@ The surface area of an open cone can be computed, as the arc length is $\sqrt{h^
We can get the surface area of a torus from this formula.
The torus is found by rotating the curve $(x-b)^2 + y^2 = a^2$ about the $y$ axis. The centroid is $b$, the arc length $2\pi a$, so the surface area is $2\pi (b) (2\pi a) = 4\pi^2 a b$.
The torus is found by rotating the curve $(x-b)^2 + y^2 = a^2$ about the $y$ axis. The centroid is $b$, the arc length $2\pi a$, so the surface area is $2\pi (b) (2\pi a) = 4\pi^2 a b$. A torus with $a=2$ and $b=6$ was plotted for @fig-torus-plotted-as-rotated-parameterized-circle-of-radius-2.
A torus with $a=2$ and $b=6$
```{julia}
#| hold: true
#| echo: false
a,b = 2, 6
F₀(u,v) = [a*(cos(u) + b)*cos(v), a*(cos(u) + b)*sin(v), a*sin(u)]
us = vs = range(0, 2pi, length=35)
ws = unzip(F₀.(us, vs'))
surface(ws..., legend=false, zlims=(-12,12))
```
##### Example
@@ -720,8 +720,8 @@ The surface area of sphere will be SA$=2\pi \rho (\pi r) = 2 \pi^2 r \cdot \rho$
$$
\begin{align*}
\text{cm}_x &= \frac{1}{L} \int_a^b g(t) \sqrt{g'(t)^2 + f'(t)^2} dt\\
\text{cm}_y &= \frac{1}{L} \int_a^b f(t) \sqrt{g'(t)^2 + f'(t)^2} dt.
\overline{\text{cm}}_x &= \frac{1}{L} \int_a^b g(t) \sqrt{g'(t)^2 + f'(t)^2} dt\\
\overline{\text{cm}}_y &= \frac{1}{L} \int_a^b f(t) \sqrt{g'(t)^2 + f'(t)^2} dt.
\end{align*}
$$
@@ -733,11 +733,14 @@ For the sphere parameterized by $g(t) = r \cos(t)$, $f(t) = r\sin(t)$, we get th
$$
\text{cm}_x = \frac{1}{L}\int_0^\pi r\cos(t) \sqrt{r^2(\sin(t)^2 + \cos(t)^2)} dt = \frac{1}{L}r^2 \int_0^\pi \cos(t) = 0.
$$
$$
\text{cm}_y = \frac{1}{L}\int_0^\pi r\sin(t) \sqrt{r^2(\sin(t)^2 + \cos(t)^2)} dt = \frac{1}{L}r^2 \int_0^\pi \sin(t) = \frac{1}{\pi r} r^2 \cdot 2 = \frac{2r}{\pi}.
\begin{align*}
\overline{\text{cm}}_x &= \frac{1}{L}\int_0^\pi r\cos(t) \sqrt{r^2(\sin(t)^2 + \cos(t)^2)} dt\\
&= \frac{1}{L}r^2 \int_0^\pi \cos(t)\\
&= 0\\
\overline{\text{cm}}_y &= \frac{1}{L}\int_0^\pi r\sin(t) \sqrt{r^2(\sin(t)^2 + \cos(t)^2)} dt\\
&= \frac{1}{L}r^2 \int_0^\pi \sin(t) \\
&= \frac{1}{\pi r} r^2 \cdot 2 = \frac{2r}{\pi}.
\end{align*}
$$
Combining this, we see that the surface area of a sphere is $2 \pi^2 r (2r/\pi) = 4\pi r^2$, by Pappus' Theorem.
@@ -760,8 +763,8 @@ choices = [
"``-\\int_1^{_1} 2\\pi u \\sqrt{1 + u^2} du``",
"``-\\int_1^{_1} 2\\pi u^2 \\sqrt{1 + u} du``"
]
answ = 1
radioq(choices, answ)
answer = 1
radioq(choices, answer)
```
Though the integral can be computed by hand, give a numeric value.
@@ -830,8 +833,8 @@ choices = [
"``\\int_u^{u_h} 2\\pi y dx``",
"``\\int_u^{u_h} 2\\pi x dx``"
]
answ = 1
radioq(choices, answ)
answer = 1
radioq(choices, answer)
```
##### Questions