From 2326c233531e8eafc92a835c1ca71bfada652e8a Mon Sep 17 00:00:00 2001 From: jverzani Date: Tue, 18 Jul 2023 18:01:25 -0400 Subject: [PATCH] issue with animation and surface --- Project.toml => quarto/Project.toml | 0 quarto/_quarto.yml | 5 +- quarto/integrals/surface_area.qmd | 88 +++++++++++++++-------------- 3 files changed, 50 insertions(+), 43 deletions(-) rename Project.toml => quarto/Project.toml (100%) diff --git a/Project.toml b/quarto/Project.toml similarity index 100% rename from Project.toml rename to quarto/Project.toml diff --git a/quarto/_quarto.yml b/quarto/_quarto.yml index ef804a7..8287a86 100644 --- a/quarto/_quarto.yml +++ b/quarto/_quarto.yml @@ -1,4 +1,5 @@ -version: "0.16" +version: "0.18" +jupyter: julia-1.9 project: type: book @@ -127,6 +128,8 @@ book: # - misc/bibliography.qmd - references.qmd +execute-dir: project + bibliography: references.bib website: diff --git a/quarto/integrals/surface_area.qmd b/quarto/integrals/surface_area.qmd index d412fdb..28bb5f9 100644 --- a/quarto/integrals/surface_area.qmd +++ b/quarto/integrals/surface_area.qmd @@ -1,8 +1,9 @@ # Surface Area - {{< include ../_common_code.qmd >}} + + This section uses these add-on packages: @@ -13,6 +14,7 @@ using SymPy using QuadGK ``` + --- @@ -114,46 +116,9 @@ $$ \text{SA} = \int_a^b 2\pi f(t) \sqrt{g'(t)^2 + f'(t)^2} dt. $$ -If we assume integrability of the integrand, then as our partition size goes to zero, this approximate surface area converges to the value given by the limit. (As with arc length, this needs a technical adjustment to the Riemann integral theorem as here we are evaluating the integrand function at four points ($t_i$, $t_{i-1}$, $\xi$ and $\psi$) and not just at some $c_i$. +If we assume integrability of the integrand, then as our partition size goes to zero, this approximate surface area converges to the value given by the limit. (As with arc length, this needs a technical adjustment to the Riemann integral theorem as here we are evaluating the integrand function at four points ($t_i$, $t_{i-1}$, $\xi$ and $\psi$) and not just at some $c_i$. An figure appears at the end. -```{julia} -#| hold: true -#| echo: false -## {{{approximate_surface_area}}} - -xs,ys = range(-1, stop=1, length=50), range(-1, stop=1, length=50) -f(x,y)= 2 - (x^2 + y^2) - -dr = [1/2, 3/4] -df = [f(dr[1],0), f(dr[2],0)] - -function sa_approx_graph(i) - p = plot(xs, ys, f, st=[:surface], legend=false) - for theta in range(0, stop=i/10*2pi, length=10*i ) - path3d!(p,sin(theta)*dr, cos(theta)*dr, df) - end - p -end -n = 10 - -anim = @animate for i=1:n - sa_approx_graph(i) -end - -imgfile = tempname() * ".gif" -gif(anim, imgfile, fps = 1) - - -caption = L""" - -Surface of revolution of $f(x) = 2 - x^2$ about the $y$ axis. The lines segments are the images of rotating the secant line connecting $(1/2, f(1/2))$ and $(3/4, f(3/4))$. These trace out the frustum of a cone which approximates the corresponding surface area of the surface of revolution. In the limit, this approximation becomes exact and a formula for the surface area of surfaces of revolution can be used to compute the value. - -""" - -ImageFile(imgfile, caption) -``` - #### Examples @@ -232,14 +197,12 @@ Though parametric plots have a convenience constructor, `plot(g, f, a, b)`, we c Now, to rotate this about the $y$ axis, creating a surface plot, we have the following pattern: - ```{julia} S(u,v) = [g(u)*cos(v), g(u)*sin(v), f(u)] 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], [0,0], [-3,3], color=:red, linewidth=5) # y axis emphasis ``` @@ -256,7 +219,6 @@ us = range(a, b, length=100) vs = range(0, 2pi, length=100) ws = unzip(S.(us,vs')) surface(ws..., legend=false) - plot!([3,9], [0,0],[0,0], color=:green, linewidth=5) # x axis emphasis ``` @@ -580,3 +542,45 @@ a, b = 0, pi val, _ = quadgk(t -> 2pi* f(t) * sqrt(g'(t)^2 + f'(t)^2), a, b) numericq(val) ``` + + +# Appendix + +```{julia} +#| hold: true +#| echo: false + +## For **some reason** having this in the natural place messes up the plots. +## {{{approximate_surface_area}}} + +xs,ys = range(-1, stop=1, length=50), range(-1, stop=1, length=50) +f(x,y)= 2 - (x^2 + y^2) + +dr = [1/2, 3/4] +df = [f(dr[1],0), f(dr[2],0)] + +function sa_approx_graph(i) + p = plot(xs, ys, f, st=[:surface], legend=false) + for theta in range(0, stop=i/10*2pi, length=10*i ) + path3d!(p,sin(theta)*dr, cos(theta)*dr, df) + end + p +end +n = 10 + +anim = @animate for i=1:n + sa_approx_graph(i) +end + +imgfile = tempname() * ".gif" +gif(anim, imgfile, fps = 1) + + +caption = L""" + +Surface of revolution of $f(x) = 2 - x^2$ about the $y$ axis. The lines segments are the images of rotating the secant line connecting $(1/2, f(1/2))$ and $(3/4, f(3/4))$. These trace out the frustum of a cone which approximates the corresponding surface area of the surface of revolution. In the limit, this approximation becomes exact and a formula for the surface area of surfaces of revolution can be used to compute the value. + +""" + +ImageFile(imgfile, caption) +```