Merge branch 'main' into v0.18

This commit is contained in:
jverzani
2023-06-01 11:21:23 -04:00
4 changed files with 46 additions and 44 deletions

View File

@@ -220,6 +220,7 @@ function euler(F, x0, xn, y0, n)
xs[i + 1] = xs[i] + h xs[i + 1] = xs[i] + h
ys[i + 1] = ys[i] + h * F(ys[i], xs[i]) ys[i + 1] = ys[i] + h * F(ys[i], xs[i])
end end
xs[end] = xn
linterp(xs, ys) linterp(xs, ys)
end end
``` ```
@@ -288,7 +289,6 @@ We graphically compare our approximate answer with the exact one:
```{julia} ```{julia}
plot(f, x0, xn)
𝒐ut = dsolve(D(u)(x) - F(u(x),x), u(x), ics = Dict(u(x0) => y0)) 𝒐ut = dsolve(D(u)(x) - F(u(x),x), u(x), ics = Dict(u(x0) => y0))
plot(rhs(𝒐ut), x0, xn) plot(rhs(𝒐ut), x0, xn)
plot!(f, x0, xn) plot!(f, x0, xn)
@@ -348,7 +348,7 @@ The [Brachistochrone problem](http://www.unige.ch/~gander/Preprints/Ritz.pdf) wa
imgfile = "figures/bead-game.jpg" imgfile = "figures/bead-game.jpg"
caption = """ caption = """
A child's bead game. What shape wire will produce the shortest time for a bed to slide from a top to the bottom? A child's bead game. What shape wire will produce the shortest time for a bead to slide from a top to the bottom?
""" """
#ImageFile(:ODEs, imgfile, caption) #ImageFile(:ODEs, imgfile, caption)
@@ -464,11 +464,11 @@ The race is on. An illustration of beads falling along a path, as can be seen, s
ImageFile(imgfile, caption) ImageFile(imgfile, caption)
``` ```
Now, the natural question is which path is best? The solution can be [reduced](http://mathworld.wolfram.com/BrachistochroneProblem.html) to solving this equation for a positive $c$: Now, the natural question is which path is best? The solution can be [reduced](http://mathworld.wolfram.com/BrachistochroneProblem.html) to solving this equation for a positive $C$:
$$ $$
1 + (y'(x))^2 = \frac{c}{y}, \quad c > 0. 1 + (y'(x))^2 = \frac{C}{y}, \quad C > 0.
$$ $$
Reexpressing, this becomes: Reexpressing, this becomes:
@@ -482,7 +482,7 @@ This is a separable equation and can be solved, but even `SymPy` has trouble wit
$$ $$
x(u) = c\cdot u - \frac{c}{2}\sin(2u), \quad y(u) = \frac{c}{2}( 1- \cos(2u)), \quad 0 \leq u \leq U. x(u) = C\cdot u - \frac{C}{2}\sin(2u), \quad y(u) = \frac{C}{2}( 1- \cos(2u)), \quad 0 \leq u \leq U.
$$ $$
The values of $U$ and $c$ must satisfy $(x(U), y(U)) = (B, A)$. The values of $U$ and $c$ must satisfy $(x(U), y(U)) = (B, A)$.
@@ -495,7 +495,7 @@ The equation can be written in terms of $y'=F(y,x)$, where
$$ $$
F(y,x) = \sqrt{\frac{c-y}{y}}. F(y,x) = \sqrt{\frac{C-y}{y}}.
$$ $$
But as $y_0 = 0$, we immediately would have a problem with the first step, as there would be division by $0$. But as $y_0 = 0$, we immediately would have a problem with the first step, as there would be division by $0$.
@@ -609,7 +609,7 @@ u_{n+1} &= u_n + h v_n,\\
v_{n+1} &= v_n - h \cdot g/l \cdot \sin(u_n). v_{n+1} &= v_n - h \cdot g/l \cdot \sin(u_n).
\end{align*} \end{align*}
Here we need *two* initial conditions: one for the initial value $u(t_0)$ and the initial value of $u'(t_0)$. We have seen if we start at an angle $a$ and release the bob from rest, so $u'(0)=0$ we get a sinusoidal answer to the linearized model. What happens here? We let $a=1$, $L=5$ and $g=9.8$: Here we need *two* initial conditions: one for the initial value $u(t_0)$ and the initial value of $u'(t_0)$. We have seen if we start at an angle $a$ and release the bob from rest, so $u'(0)=0$ we get a sinusoidal answer to the linearized model. What happens here? We let $a=1$, $l=5$ and $g=9.8$:
We write a function to solve this starting from $(x_0, y_0)$ and ending at $x_n$: We write a function to solve this starting from $(x_0, y_0)$ and ending at $x_n$:
@@ -624,12 +624,12 @@ function euler2(x0, xn, y0, yp0, n; g=9.8, l = 5)
xs[i+1] = xs[i] + h xs[i+1] = xs[i] + h
us[i+1] = us[i] + h * vs[i] us[i+1] = us[i] + h * vs[i]
vs[i+1] = vs[i] + h * (-g / l) * sin(us[i]) vs[i+1] = vs[i] + h * (-g / l) * sin(us[i])
end end
linterp(xs, us) linterp(xs, us)
end end
``` ```
Let's take $a = \pi/4$ as the initial angle, then the approximate solution should be $\pi/4\cos(\sqrt{g/l}x)$ with period $T = 2\pi\sqrt{l/g}$. We try first to plot then over 4 periods: Let's take $a = \pi/4$ as the initial angle, then the approximate solution should be $\pi/4\cos(\sqrt{g/l}x)$ with period $T = 2\pi\sqrt{l/g}$. We try first to plot them over 4 periods:
```{julia} ```{julia}

View File

@@ -88,7 +88,7 @@ Again, we can integrate to get an answer for any value $t$:
\begin{align*} \begin{align*}
x(t) - x(t_0) &= \int_{t_0}^t \frac{dv}{dt} dt \\ x(t) - x(t_0) &= \int_{t_0}^t \frac{dx}{dt} dt \\
&= (v_0t + \frac{1}{2}a t^2 - at_0 t) |_{t_0}^t \\ &= (v_0t + \frac{1}{2}a t^2 - at_0 t) |_{t_0}^t \\
&= (v_0 - at_0)(t - t_0) + \frac{1}{2} a (t^2 - t_0^2). &= (v_0 - at_0)(t - t_0) + \frac{1}{2} a (t^2 - t_0^2).
\end{align*} \end{align*}
@@ -216,7 +216,7 @@ Let $F(y) = \int_{y_0}^y du/g(u)$, then a solution to the above is $F(y) = x - x
[Toricelli's Law](http://tinyurl.com/hxvf3qp) describes the speed a jet of water will leave a vessel through an opening below the surface of the water. The formula is $v=\sqrt{2gh}$, where $h$ is the height of the water above the hole and $g$ the gravitational constant. This arises from equating the kinetic energy gained, $1/2 mv^2$ and potential energy lost, $mgh$, for the exiting water. [Toricelli's Law](http://tinyurl.com/hxvf3qp) describes the speed a jet of water will leave a vessel through an opening below the surface of the water. The formula is $v=\sqrt{2gh}$, where $h$ is the height of the water above the hole and $g$ the gravitational constant. This arises from equating the kinetic energy gained, $1/2 mv^2$ and potential energy lost, $mgh$, for the exiting water.
An application of Torricelli's law is to describe the volume of water in a tank over time, $V(t)$. Imagine a cylinder of cross sectional area $A$ with a hole of cross sectional diameter $a$ at the bottom, Then $V(t) = A h(t)$, with $h$ giving the height. The change in volume over $\Delta t$ units of time must be given by the value $a v(t) \Delta t$, or An application of Torricelli's law is to describe the volume of water in a tank over time, $V(t)$. Imagine a cylinder of cross sectional area $A$ with a hole of cross sectional area $a$ at the bottom, Then $V(t) = A h(t)$, with $h$ giving the height. The change in volume over $\Delta t$ units of time must be given by the value $a v(t) \Delta t$, or
$$ $$
@@ -511,7 +511,7 @@ $$
Here, the solution is in terms of sines and cosines, with period given by $T = 2\pi/\sqrt{k} = 2\pi\cdot\sqrt{l/g}$. The answer does not depend on the mass, $m$, of the bob nor the amplitude of the motion, provided the small-angle approximation is valid. Here, the solution is in terms of sines and cosines, with period given by $T = 2\pi/\sqrt{k} = 2\pi\cdot\sqrt{l/g}$. The answer does not depend on the mass, $m$, of the bob nor the amplitude of the motion, provided the small-angle approximation is valid.
If we pull the bob back an angle $a$ and release it then the initial conditions are $\theta(0) = a$ and $\theta'(a) = 0$. This gives the solution: If we pull the bob back an angle $a$ and release it then the initial conditions are $\theta(0) = a$ and $\theta'(0) = 0$. This gives the solution:
```{julia} ```{julia}
@@ -652,10 +652,12 @@ Furthermore, we can solve for $t$ from $x(t)$, to get an equation describing $y(
```{julia} ```{julia}
#| hold: true #| hold: true
@syms x0::real y0::real v0::real alpha::real g::real @syms x0::real y0::real v0::real alpha::real g::real
@syms t x u() @syms t::positive x u()
a1 = dsolve(D2(u)(x) ~ 0, u(x), ics=Dict(u(0) => x0, D(u)(0) => v0 * cos(alpha))) Dₜ = Differential(t)
a2 = dsolve(D2(u)(x) ~ -g, u(x), ics=Dict(u(0) => y0, D(u)(0) => v0 * sin(alpha))) D2ₜ = Dₜ ∘ Dₜ
ts = solve(t - rhs(a1), x)[1] a1 = dsolve(D2ₜ(u)(t) ~ 0, u(t), ics=Dict(u(0) => x0, Dₜ(u)(0) => v0 * cos(alpha)))
a2 = dsolve(D2ₜ(u)(t) ~ -g, u(t), ics=Dict(u(0) => y0, Dₜ(u)(0) => v0 * sin(alpha)))
ts = solve(x - rhs(a1), t)[1]
y = simplify(rhs(a2)(t => ts)) y = simplify(rhs(a2)(t => ts))
sympy.Poly(y, x).coeffs() sympy.Poly(y, x).coeffs()
``` ```
@@ -676,9 +678,9 @@ We now attempt to solve these.
```{julia} ```{julia}
@syms alpha::real, γ::postive, t::positive, v() @syms alpha::real, γ::postive, v()
@syms x_0::real y_0::real v_0::real @syms x_0::real y_0::real v_0::real
Dₜ = Differential(t)
eq₁ = Dₜ(Dₜ(u))(t) ~ - γ * Dₜ(u)(t) eq₁ = Dₜ(Dₜ(u))(t) ~ - γ * Dₜ(u)(t)
eq₂ = Dₜ(Dₜ(v))(t) ~ -g - γ * Dₜ(v)(t) eq₂ = Dₜ(Dₜ(v))(t) ~ -g - γ * Dₜ(v)(t)
@@ -931,7 +933,7 @@ The differential equation with boundary values
$$ $$
\frac{r^2 \frac{dc}{dr}}{dr} = 0, \quad c(1)=2, c(10)=1, \frac{d(r^2 \frac{dc}{dr})}{dr} = 0, \quad c(1)=2, c(10)=1,
$$ $$
can be solved with `SymPy`. What is the value of $c(5)$? can be solved with `SymPy`. What is the value of $c(5)$?

View File

@@ -148,9 +148,9 @@ $$
:::{.callout-note} :::{.callout-note}
## Note ## Note
[Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/exhibits/bressoud/) notes that Gregory (1668) proved this formula for arc length of the graph of a function by showing that the length of the curve $f(x)$ is defined by the area under $\sqrt{1 + f'(x)^2}$. (It is commented that this was also known a bit earlier by von Heurat.) Gregory went further though, as part of the fundamental theorem of calculus was contained in his work. Gregory then posed this inverse question: given a curve $y=g(x)$ find a function $u(x)$ so that the area under $g$ is equal to the length of the second curve. The answer given was $u(x) = (1/c)\int_a^x \sqrt{g^2(t) - c^2}$, which if $g(t) = \sqrt{1 + f'(t)^2}$ and $c=1$ says $u(x) = \int_a^x f(t)dt$. [Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/exhibits/bressoud/) notes that Gregory (1668) proved this formula for arc length of the graph of a function by showing that the length of the curve $f(x)$ is defined by the area under $\sqrt{1 + f'(x)^2}$. (It is commented that this was also known a bit earlier by von Heurat.) Gregory went further though, as part of the fundamental theorem of calculus was contained in his work. Gregory then posed this inverse question: given a curve $y=g(x)$ find a function $u(x)$ so that the area under $g$ is equal to the length of the second curve. The answer given was $u(x) = (1/c)\int_a^x \sqrt{g^2(t) - c^2}dt$, where $g(t) = \sqrt{1 + u'(t)^2}$ if $c=1$ says $\int_a^x\sqrt{1 + u'(t)^2}dt = \int_a^x g(t)dt$.
An analogy might be a sausage maker. These take a mass of ground-up sausage material and return a long length of sausage. The material going in would depend on time via an equation like $\int_0^t g(u) du$ and the length coming out would be a constant (accounting for the cross section) times $u(t) = \int_0^t \sqrt{1 + g'(s)} ds$. An analogy might be a sausage maker. These take a mass of ground-up sausage material and return a long length of sausage. The material going in would depend on time via an equation like $\int_0^t g(u) du$ and the length coming out would be a constant (accounting for the cross section) times $\int_0^t \sqrt{1 + u'(s)^2} ds$.
::: :::
@@ -483,7 +483,7 @@ What looks at first glance to be just a slightly more complicated equation is th
\begin{align*} \begin{align*}
s(u) &= \int_0^u \sqrt{(-\sin(t))^2 + b\cos(t)^2} dt\\ s(u) &= \int_0^u \sqrt{(-\sin(t))^2 + b\cos(t)^2} dt\\
&= \int_0^u \sqrt{\sin(t))^2 + \cos(t)^2 + c\cos(t)^2} dt \\ &= \int_0^u \sqrt{\sin(t)^2 + \cos(t)^2 + c\cos(t)^2} dt \\
&=\int_0^u \sqrt{1 + c\cos(t)^2} dt. &=\int_0^u \sqrt{1 + c\cos(t)^2} dt.
\end{align*} \end{align*}
@@ -521,7 +521,7 @@ Here we see visually that the new parameterization yields the same curve:
g(t) = 𝒂 * cos(t) g(t) = 𝒂 * cos(t)
f(t) = 𝒃 * sin(t) f(t) = 𝒃 * sin(t)
plot(t -> g(𝒔(t)), t -> f(𝒔(t)), 0, 𝒔(2*pi)) plot(t -> g(𝒔(t)), t -> f(𝒔(t)), 0, sinv(2*pi))
``` ```
#### Example: An implication of concavity #### Example: An implication of concavity
@@ -704,7 +704,7 @@ For the latter claim, integrating in the $y$ variable gives
Now, the area under $h$ over $[u,c]$ is greater than that over $[c,v]$ as $(u+v)/2 < c$ or $v-c < c-u$. That means the area under $f$ over $[u,c]$ is greater than that over $[c,v]$. Now, the area under $h$ over $[u,c]$ is greater than that over $[c,v]$ as $(u+v)/2 < c$ or $v-c < c-u$. That means the area under $f$ over $[u,c]$ is greater than that over $[c,v]$.
> There is more arc length for $f$over $[a,u]$ than $[v,b]$; more arc length for $f$ over $[u,c]$ than $[c,v]$. In particular more arc length over $[a,c]$ than $[c,b]$. > There is more arc length for $f$ over $[a,u]$ than $[v,b]$; more arc length for $f$ over $[u,c]$ than $[c,v]$. In particular more arc length over $[a,c]$ than $[c,b]$.
@@ -712,10 +712,10 @@ let $\phi(z) = f_2^{-1}(f_1(z))$ be the function taking $u$ to $v$, and $a$ to $
$$ $$
f'(\phi(z)) \cdot \phi'(z) = f'(z) < 0 f'(\phi(z)) \cdot \phi'(z) = f'(z) > 0
$$ $$
or $\phi'(z) < 0$. Moreover, we have by the first assertion that $f'(z) < -f'(\phi(z))$ so $|\phi'(z)| = |f(z)/f'(\phi(z))| < 1$. or $\phi'(z) < 0$. Moreover, we have by the first assertion that $f'(z) < -f'(\phi(z))$ so $|\phi'(z)| = |f'(z)/f'(\phi(z))| < 1$.
Using the substitution $x = \phi(z)$ gives: Using the substitution $x = \phi(z)$ gives:
@@ -732,7 +732,7 @@ Using the substitution $x = \phi(z)$ gives:
\end{align*} \end{align*}
Letting $h=f(u) \rightarrow c$ we get the *inequality* Letting $h=f(u \rightarrow c)$ we get the *inequality*
$$ $$
@@ -789,7 +789,7 @@ y''(t) &= -g - W(t,x(t), x'(t), y(t), y'(t)) \cdot y'(t)\\
with initial conditions: $x(0) = y(0) = 0$ and $x'(0) = v_0 \cos(\theta), y'(0) = v_0 \sin(\theta)$. with initial conditions: $x(0) = y(0) = 0$ and $x'(0) = v_0 \cos(\theta), y'(0) = v_0 \sin(\theta)$.
Only with certain drag forces, can this set of equations be be solved exactly, though it can be approximated numerically for admissible $W$, but if $W$ is strictly positive then it can be shown $x(t)$ is increasing on $[0, x_\infty)$ and so invertible, and $f(u) = y(x^{-1}(u))$ is three times differentiable with both $f$ and $f'$ being strictly concave, as it can be shown that (say $x(v) = u$ so $dv/du = 1/x'(v) > 0$): Only with certain drag forces, can this set of equations be solved exactly, though it can be approximated numerically for admissible $W$, but if $W$ is strictly positive then it can be shown $x(t)$ is increasing on $[0, x_\infty)$ and so invertible, and $f(u) = y(x^{-1}(u))$ is three times differentiable with both $f$ and $f'$ being strictly concave, as it can be shown that (say $x(v) = u$ so $dv/du = 1/x'(v) > 0$):
@@ -837,7 +837,7 @@ The length of the curve given by $f(x) = e^x$ between $0$ and $1$ is certainly l
#| hold: true #| hold: true
#| echo: false #| echo: false
f(x) = exp(x) f(x) = exp(x)
val = sqrt( (f(1) - f(0))^2 - (1 - 0)^2) val = sqrt( (f(1) - f(0))^2 + (1 - 0)^2)
numericq(val) numericq(val)
``` ```
@@ -888,7 +888,7 @@ A [pursuit](http://www-history.mcs.st-and.ac.uk/Curves/Pursuit.html) curve is a
#| echo: false #| echo: false
f(x) = x^2 - log(x) f(x) = x^2 - log(x)
a, b= 1/10, 2 a, b= 1/10, 2
val, _ = quadgk( x -> sqrt(1 + (f)(x)^2), a, b) val, _ = quadgk( x -> sqrt(1 + D(f)(x)^2), a, b)
numericq(val) numericq(val)
``` ```
@@ -918,7 +918,7 @@ sqrt((tan(pi/4) - tan(-pi/4))^2 + (pi/4 - -pi/4)^2)
###### Question ###### Question
Find the length of the graph of the function $g(x) =\int_0^x \tan(x)dx$ between $0$ and $\pi/4$ by hand or numerically: Find the length of the graph of the function $g(x) =\int_0^x \tan(t)dt$ between $0$ and $\pi/4$ by hand or numerically:
```{julia} ```{julia}
@@ -981,7 +981,7 @@ f(x,a) = a * cosh(x/a)
inside = 1 + diff(f(x,a), x)^2 inside = 1 + diff(f(x,a), x)^2
``` ```
Just trying `integrate(sqrt(inside), x)` will fail, but if we try `integrate(sqrt(simplify(inside), x))` an antiderivative can be found. What is it? Just trying `integrate(sqrt(inside), x)` will fail, but if we try `integrate(sqrt(simplify(inside)), x)` an antiderivative can be found. What is it?
```{julia} ```{julia}

View File

@@ -83,7 +83,7 @@ To see why this formula is as it is, we look at the parameterized case, the firs
Let a partition of $[a,b]$ be given by $a = t_0 < t_1 < t_2 < \cdots < t_n =b$. This breaks the curve into a collection of line segments. Consider the line segment connecting $(g(t_{i-1}), f(t_{i-1}))$ to $(g(t_i), f(t_i))$. Rotating this around the $x$ axis will generate something approximating a disc, but in reality will be the frustum of a cone. What will be the surface area? Let a partition of $[a,b]$ be given by $a = t_0 < t_1 < t_2 < \cdots < t_n =b$. This breaks the curve into a collection of line segments. Consider the line segment connecting $(g(t_{i-1}), f(t_{i-1}))$ to $(g(t_i), f(t_i))$. Rotating this around the $x$ axis will generate something approximating a disc, but in reality will be the frustum of a cone. What will be the surface area?
Consider a right-circular cone parameterized by an angle $\theta$ and the largest radius $r$ (so that the height satisfies $r/h=\tan(\theta)$). If this cone were made of paper, cut up a side, and layed out flat, it would form a sector of a circle, whose area would be $R\gamma$ where $R$ is the radius of the circle (also the side length of our cone), and $\gamma$ an angle that we can figure out from $r$ and $\theta$. To do this, we note that the arc length of the circle's edge is $R\gamma$ and also the circumference of the bottom of the cone so $R\gamma = 2\pi r$. With all this, we can solve to get $A = \pi r^2/\sin(\theta)$. But we have a frustum of a cone with radii $r_0$ and $r_1$, so the surface area is a difference: $A = \pi (r_1^2 - r_0^2) /\sin(\theta)$. Consider a right-circular cone parameterized by an angle $\theta$ and the largest radius $r$ (so that the height satisfies $r/h=\tan(\theta)$). If this cone were made of paper, cut up a side, and layed out flat, it would form a sector of a circle, whose area would be $R^2\gamma/2$ where $R$ is the radius of the circle (also the side length of our cone), and $\gamma$ an angle that we can figure out from $r$ and $\theta$. To do this, we note that the arc length of the circle's edge is $R\gamma$ and also the circumference of the bottom of the cone so $R\gamma = 2\pi r$. With all this, we can solve to get $A = \pi r^2/\sin(\theta)$. But we have a frustum of a cone with radii $r_0$ and $r_1$, so the surface area is a difference: $A = \pi (r_1^2 - r_0^2) /\sin(\theta)$.
Relating this to our values in terms of $f$ and $g$, we have $r_1=f(t_i)$, $r_0 = f(t_{i-1})$, and $\sin(\theta) = \Delta f / \sqrt{(\Delta g)^2 + (\Delta f)^2}$, where $\Delta f = f(t_i) - f(t_{i-1})$ and similarly for $\Delta g$. Relating this to our values in terms of $f$ and $g$, we have $r_1=f(t_i)$, $r_0 = f(t_{i-1})$, and $\sin(\theta) = \Delta f / \sqrt{(\Delta g)^2 + (\Delta f)^2}$, where $\Delta f = f(t_i) - f(t_{i-1})$ and similarly for $\Delta g$.
@@ -100,7 +100,7 @@ $$
(This is $2 \pi$ times the average radius times the slant height.) (This is $2 \pi$ times the average radius times the slant height.)
As was done in the derivation of the formula for arc length, these pieces are multiplied both top and bottom by $\Delta t = t_{i} - t_{i-1}$. Carrying the bottom inside the square root and noting that by the mean value theorem $\Delta g/\Delta t = g(\xi)$ and $\Delta f/\Delta t = f(\psi)$ for some $\xi$ and $\psi$ in $[t_{i-1}, t_i]$, this becomes: As was done in the derivation of the formula for arc length, these pieces are multiplied both top and bottom by $\Delta t = t_{i} - t_{i-1}$. Carrying the bottom inside the square root and noting that by the mean value theorem $\Delta g/\Delta t = g'(\xi)$ and $\Delta f/\Delta t = f'(\psi)$ for some $\xi$ and $\psi$ in $[t_{i-1}, t_i]$, this becomes:
$$ $$
@@ -160,14 +160,14 @@ ImageFile(imgfile, caption)
Lets see that the surface area of an open cone follows from this formula, even though we just saw how to get this value. Lets see that the surface area of an open cone follows from this formula, even though we just saw how to get this value.
A cone be be envisioned as rotating the function $f(x) = x\tan(\theta)$ between $0$ and $h$ around the $x$ axis. This integral yields the surface area: A cone can be envisioned as rotating the function $f(x) = x\tan(\theta)$ between $0$ and $h$ around the $x$ axis. This integral yields the surface area:
\begin{align*} \begin{align*}
\int_0^h 2\pi f(x) \sqrt{1 + f'(x)^2}dx \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 \\ &= \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}) x^2/2 \big|_0^h \\
&= \pi \tan(\theta) \sec(\theta) h^2 \\ &= \pi \tan(\theta) \sec(\theta) h^2 \\
&= \pi r^2 / \sin(\theta). &= \pi r^2 / \sin(\theta).
\end{align*} \end{align*}
@@ -287,7 +287,7 @@ val
#| hold: true #| hold: true
g(u) = u g(u) = u
f(u) = u^u f(u) = u^u
S(u,v) = [g(u)*cos(v), g(u)*sin(v), f(u)] S(u,v) = [g(u), f(u)*cos(v), f(u)*sin(v)]
us = range(0, 3/2, length=100) 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')) ws = unzip(S.(us,vs'))
@@ -515,7 +515,7 @@ $$
A = \int_u^{u+h} 2\pi f(x) \sqrt{1 + f'(x)^2} dx. A = \int_u^{u+h} 2\pi f(x) \sqrt{1 + f'(x)^2} dx.
$$ $$
If we let $f(x) = y$ then $f'(x) = x/y$. With this, what does the integral above come down to after cancellations: If we let $f(x) = y$ then $f'(x) = -x/y$. With this, what does the integral above come down to after cancellations:
```{julia} ```{julia}
@@ -544,7 +544,7 @@ Numerically find the value.
#| echo: false #| echo: false
g(t) = cos(t) g(t) = cos(t)
f(t) = sin(t) f(t) = sin(t)
a, b = 0, pi/4 a, b = 0, pi/6
val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b) val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b)
numericq(val) numericq(val)
``` ```
@@ -558,8 +558,8 @@ The [astroid](http://www-history.mcs.st-and.ac.uk/Curves/Astroid.html) is parame
```{julia} ```{julia}
#| hold: true #| hold: true
#| echo: false #| echo: false
g(t) = cos(t^3) g(t) = cos(t)^3
f(t) = sin(t^3) f(t) = sin(t)^3
a, b = 0, pi a, b = 0, pi
val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b) val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b)
numericq(val) numericq(val)
@@ -574,8 +574,8 @@ For the curve parameterized by $g(t) = a\cos(t)^5$ and $f(t) = a \sin(t)^5$. L
```{julia} ```{julia}
#| hold: true #| hold: true
#| echo: false #| echo: false
g(t) = cos(t^5) g(t) = cos(t)^5
f(t) = sin(t^5) f(t) = sin(t)^5
a, b = 0, pi a, b = 0, pi
val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b) val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b)
numericq(val) numericq(val)