From c4bd214ecdf2324f28ff3f6e610c1af33de8ab03 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 19:21:20 -0400 Subject: [PATCH 1/8] WIP: Plots --- quarto/alternatives/Project.toml | 7 ++++- quarto/alternatives/SciML.qmd | 2 +- quarto/alternatives/makie_plotting.qmd | 36 +++++++++++++------------ quarto/alternatives/plotly_plotting.qmd | 35 +----------------------- quarto/alternatives/symbolics.qmd | 9 +------ 5 files changed, 28 insertions(+), 61 deletions(-) diff --git a/quarto/alternatives/Project.toml b/quarto/alternatives/Project.toml index 4188acb..1e24643 100644 --- a/quarto/alternatives/Project.toml +++ b/quarto/alternatives/Project.toml @@ -5,11 +5,13 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" -Implicit3DPlotting = "d997a800-832a-4a4c-b340-7dddf3c1ad50" Integrals = "de52edbc-65ea-441a-8357-d3a637375a31" +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" +Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba" OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e" @@ -19,6 +21,7 @@ PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c" PlotlyLight = "ca7969ec-10b3-423e-8d99-40f33abb42bf" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +QuizQuestions = "612c44de-1021-4a21-84fb-7261cf5eb2d4" Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -26,3 +29,5 @@ SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" SymbolicLimits = "19f23fe9-fdab-4a78-91af-e7b7767979c3" SymbolicNumericIntegration = "78aadeae-fbc0-11eb-17b6-c7ec0477ba9e" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" +Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d" diff --git a/quarto/alternatives/SciML.qmd b/quarto/alternatives/SciML.qmd index 8092595..a6e23c1 100644 --- a/quarto/alternatives/SciML.qmd +++ b/quarto/alternatives/SciML.qmd @@ -250,7 +250,7 @@ With the system defined, we can pass this to `NonlinearProblem`, as was done wit ```{julia} -prob = NonlinearProblem(ns, [1.0], [α => 1.0]) +prob = NonlinearProblem(mtkcompile(ns), [1.0], Dict(α => 1.0)) ``` The problem is solved as before: diff --git a/quarto/alternatives/makie_plotting.qmd b/quarto/alternatives/makie_plotting.qmd index 1cca87b..61ed0b0 100644 --- a/quarto/alternatives/makie_plotting.qmd +++ b/quarto/alternatives/makie_plotting.qmd @@ -865,20 +865,19 @@ end #### Implicitly defined surfaces, $F(x,y,z)=0$ -To plot the equation $F(x,y,z)=0$, for $F$ a scalar-valued function, again the implicit function theorem says that, under conditions, near any solution $(x,y,z)$, $z$ can be represented as a function of $x$ and $y$, so the graph will look likes surfaces stitched together. The `Implicit3DPlotting` package takes an approach like `ImplicitPlots` to represent these surfaces. It replaces the `Contour` package computation with a $3$-dimensional alternative provided through the `Meshing` and `GeometryBasics` packages. +To plot the equation $F(x,y,z)=0$, for $F$ a scalar-valued function, again the implicit function theorem says that, under conditions, near any solution $(x,y,z)$, $z$ can be represented as a function of $x$ and $y$, so the graph will look like surfaces stitched together. -```{julia} -using Implicit3DPlotting -``` +With `Makie`, many implicitly defined surfaces can be adequately represented using `countour` with the attribute `levels=[0]`. We will illustrate this technique. +The `Implicit3DPlotting` package takes an approach like `ImplicitPlots` to represent these surfaces. It replaces the `Contour` package computation with a $3$-dimensional alternative provided through the `Meshing` and `GeometryBasics` packages. This package has a `plot_implicit_surface` function that does something similar to below. We don't illustrate it, as it *currently* doesn't work with the latest version of `Makie`. -This example, plotting an implicitly defined sphere, comes from the documentation of `Implicit3DPlotting`. The `f` to be plotted is a scalar-valued function of a vector: +To begin, we plot a sphere implicitly as a solution to $F(x,y,z) = x^2 + y^2 + z^2 - 1 = 0$> ```{julia} -f(x) = sum(x.^2) - 1 -xlims = ylims = zlims = (-5, 5) -plot_implicit_surface(f; xlims, ylims, zlims) +f(x,y,z) = x^2 + y^2 + z^2 - 1 +xs = ys = zs = range(-3/2, 3/2, 100) +contour(xs, ys, zs, f; levels=[0]) ``` @@ -887,11 +886,13 @@ Here we visualize an intersection of a sphere with another figure: ```{julia} -r₂(x) = sum(x.^2) - 5/4 # a sphere +r₂(x) = sum(x.^2) - 2 # a sphere r₄(x) = sum(x.^4) - 1 -xlims = ylims = zlims = (-2, 2) -p = plot_implicit_surface(r₂; xlims, ylims, zlims, color=:yellow) -plot_implicit_surface!(p, r₄; xlims, ylims, zlims, color=:red) +ϕ(x,y,z) = (x,y,z) + +xs = ys = zs = range(-2, 2, 100) +contour(xs, ys, zs, r₂∘ϕ; levels = [0], colormap=:RdBu) +contour!(xs, ys, zs, r₄∘ϕ; levels = [0], colormap=:viridis) current_figure() ``` @@ -900,11 +901,12 @@ This example comes from [Wikipedia](https://en.wikipedia.org/wiki/Implicit_surfa ```{julia} f(x,y,z) = 2y*(y^2 -3x^2)*(1-z^2) + (x^2 +y^2)^2 - (9z^2-1)*(1-z^2) -xlims = ylims = zlims = (-5/2, 5/2) -plot_implicit_surface(x -> f(x...); xlims, ylims, zlims) +xs = ys = zs = range(-5/2, 5/2, 100) +contour(xs, ys, zs, f; levels=[0], colormap=:RdBu) + ``` -(This figure does not render well through `contour(xs, ys, zs, f, levels=[0])`, as the hole is not shown.) +(This figure does not render well though, as the hole is not shown.) For one last example from Wikipedia, we have the Cassini oval which "can be defined as the point set for which the *product* of the distances to $n$ given points is constant." That is: @@ -915,8 +917,8 @@ function cassini(λ, ps = ((1,0,0), (-1, 0, 0))) n = length(ps) x -> prod(norm(x .- p) for p ∈ ps) - λ^n end -xlims = ylims = zlims = (-2, 2) -plot_implicit_surface(cassini(1.05); xlims, ylims, zlims) +xs = ys = zs = range(-2, 2, 100) +contour(xs, ys, zs, cassini(0.80) ∘ ϕ; levels=[0], colormap=:RdBu) ``` ## Vector fields. Visualizations of $f:R^2 \rightarrow R^2$ diff --git a/quarto/alternatives/plotly_plotting.qmd b/quarto/alternatives/plotly_plotting.qmd index 32b4254..c44546e 100644 --- a/quarto/alternatives/plotly_plotting.qmd +++ b/quarto/alternatives/plotly_plotting.qmd @@ -251,40 +251,7 @@ The `text` mode specification is necessary to have text be displayed on the char #### RGB Colors -The `ColorTypes` package is the standard `Julia` package providing an `RGB` type (among others) for specifying red-green-blue colors. To make this work with `Config` and `JSON3` requires some type-piracy (modifying `Base.string` for the `RGB` type) to get, say, `RGB(0.5, 0.5, 0.5)` to output as `"rgb(0.5, 0.5, 0.5)"`. (RGB values in JavaScript are integers between $0$ and $255$ or floating point values between $0$ and $1$.) A string with this content can be specified. Otherwise, something like the following can be used to avoid the type piracy: - - -```{julia} -struct rgb - r - g - b -end -PlotlyLight.JSON3.StructTypes.StructType(::Type{rgb}) = PlotlyLight.JSON3.StructTypes.StringType() -Base.string(x::rgb) = "rgb($(x.r), $(x.g), $(x.b))" -``` - -With these defined, red-green-blue values can be used for colors. For example to give a range of colors, we might have: - - -```{julia} -#| hold: true -cols = [rgb(i,i,i) for i in range(10, 245, length=5)] -sizes = [12, 16, 20, 24, 28] -data = Config(x = 1:5, - y = rand(5), - mode="markers+text", - type="scatter", - name="scatter plot", - text = ["marker $i" for i in 1:5], - textposition = "top center", - marker = Config(size=sizes, color=cols) - ) -Plot(data) -``` - -The `opacity` key can be used to control the transparency, with a value between $0$ and $1$. - +The `ColorTypes` package is the standard `Julia` package providing an `RGB` type (among others) for specifying red-green-blue colors. To make this work with `Config` and `JSON3` requires some type-piracy (modifying `Base.string` for the `RGB` type) to get, say, `RGB(0.5, 0.5, 0.5)` to output as `"rgb(0.5, 0.5, 0.5)"`. (RGB values in JavaScript are integers between $0$ and $255$ or floating point values between $0$ and $1$.) A string with this content can be specified. #### Marker symbols diff --git a/quarto/alternatives/symbolics.qmd b/quarto/alternatives/symbolics.qmd index 06bd02b..f4a3225 100644 --- a/quarto/alternatives/symbolics.qmd +++ b/quarto/alternatives/symbolics.qmd @@ -601,14 +601,7 @@ det(N) det(collect(N)) ``` -Similarly, with `norm`: - - -```{julia} -norm(v) -``` - -and +Similarly, with `norm`, which returns a generator unless collected: ```{julia} From 23e00863a5e3da78b53be13e2cd4437491565633 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 19:21:39 -0400 Subject: [PATCH 2/8] Plots --- quarto/_quarto.yml | 4 ++-- quarto/integral_vector_calculus/Project.toml | 5 +++++ quarto/misc/Project.toml | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 quarto/misc/Project.toml diff --git a/quarto/_quarto.yml b/quarto/_quarto.yml index b1dd890..4379fab 100644 --- a/quarto/_quarto.yml +++ b/quarto/_quarto.yml @@ -156,5 +156,5 @@ format: execute: error: false -# freeze: false - freeze: auto + freeze: false +# freeze: auto diff --git a/quarto/integral_vector_calculus/Project.toml b/quarto/integral_vector_calculus/Project.toml index 7a49be7..818f132 100644 --- a/quarto/integral_vector_calculus/Project.toml +++ b/quarto/integral_vector_calculus/Project.toml @@ -4,9 +4,14 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49" IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" ImplicitIntegration = "bc256489-3a69-4a66-afc4-127cc87e6182" +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +QuizQuestions = "612c44de-1021-4a21-84fb-7261cf5eb2d4" Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" +Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d" diff --git a/quarto/misc/Project.toml b/quarto/misc/Project.toml new file mode 100644 index 0000000..43aec5b --- /dev/null +++ b/quarto/misc/Project.toml @@ -0,0 +1,2 @@ +[deps] +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" From 2af5a6a213bacac16d449b8b4b87b4d1743e25e8 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 19:23:48 -0400 Subject: [PATCH 3/8] WIP --- quarto/alternatives/makie_plotting.qmd | 29 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/quarto/alternatives/makie_plotting.qmd b/quarto/alternatives/makie_plotting.qmd index 61ed0b0..ed558e6 100644 --- a/quarto/alternatives/makie_plotting.qmd +++ b/quarto/alternatives/makie_plotting.qmd @@ -304,7 +304,6 @@ current_figure() ### Text (`annotations`) - Text can be placed at a point, as a marker is. To place text, the desired text and a position need to be specified along with any adjustments to the default attributes. @@ -315,25 +314,43 @@ For example: xs = 1:5 pts = Point2.(xs, xs) scatter(pts) -annotations!("Point " .* string.(xs), pts; - fontsize = 50 .- 2*xs, - rotation = 2pi ./ xs) +annotation!(pts; + text = "Point " .* string.(xs), + fontsize = 30 .- 5*xs) current_figure() ``` -The graphic shows that `fontsize` adjusts the displayed size and `rotation` adjusts the orientation. (The graphic also shows a need to manually override the limits of the `y` axis, as the `Point 5` is chopped off; the `ylims!` function to do so will be shown later.) +The graphic shows that `fontsize` adjusts the displayed size. Attributes for `text`, among many others, include: * `align` Specify the text alignment through `(:pos, :pos)`, where `:pos` can be `:left`, `:center`, or `:right`. - * `rotation` to indicate how the text is to be rotated * `fontsize` the font point size for the text * `font` to indicate the desired font +Annotations with an arrow can be useful to highlight a feature of a graph. This example is modified from the documentation and utilizes some interval functions to draw an arrow with an arc: + +```{julia} +g(x) = cos(6x) * exp(x) +xs = 0:0.01:4 + +_, ax, _ = lines(xs, g.(xs); axis = (; xgridvisible = false, ygridvisible = false)) + +annotation!(ax, 1, 20, 2.1, g(2.1), + text = "A relative maximum", + path = Ann.Paths.Arc(0.3), + style = Ann.Styles.LineArrow(), + labelspace = :data +) + +current_figure() +``` + + #### Line attributes From 145bc6043f7cb1a08362d13491cbaf08164477a9 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 20:53:48 -0400 Subject: [PATCH 4/8] WIP --- quarto/misc/Project.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/quarto/misc/Project.toml b/quarto/misc/Project.toml index 43aec5b..671818d 100644 --- a/quarto/misc/Project.toml +++ b/quarto/misc/Project.toml @@ -1,2 +1,12 @@ [deps] +CalculusWithJulia = "a2e0e22d-7d4c-5312-9169-8b992201a882" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49" +LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +QuizQuestions = "612c44de-1021-4a21-84fb-7261cf5eb2d4" +SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" +Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d" From 30300f295b25394bd4518d67789159ef01b5f100 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 20:55:42 -0400 Subject: [PATCH 5/8] adjust plots --- adjust_plotly.jl | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 adjust_plotly.jl diff --git a/adjust_plotly.jl b/adjust_plotly.jl new file mode 100644 index 0000000..34a0d01 --- /dev/null +++ b/adjust_plotly.jl @@ -0,0 +1,43 @@ +# The issue with `PlotlyLight` appears to be that +# the `str` below is called *after* the inclusion of `require.min.js` +# (That str is included in the `.qmd` file to be included in the header +# but the order of inclusion appears not to be adjustable) +# This little script just adds a line *before* the require call +# which seems to make it all work. The line number 83 might change. + +#alternatives/plotly_plotting.html +function _add_plotly(f) + lineno = 117 + +str = """ + +""" + + r = readlines(f) + open(f, "w") do io + for (i,l) ∈ enumerate(r) + i == lineno && println(io, str) + println(io, l) + end + end +end + + + +function (@main)(args...) + for (root, dirs, files) in walkdir("_book") + for fᵢ ∈ files + f = joinpath(root, fᵢ) + if endswith(f, ".html") + _add_plotly(f) + end + end + end + + #f = "_book/integrals/center_of_mass.html" + #_add_plotly(f) + + return 1 +end + + ["ODEs", "alternatives", "derivatives", "differentiable_vector_calculus", "integral_vector_calculus", "integrals", "limits", "misc", "precalc", "site_libs"] From aa8e9e04ca151538394da95e1cbc811f662a9c7a Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 21:02:20 -0400 Subject: [PATCH 6/8] script to adjust plotly position in loading of javascript --- quarto/adjust_plotly.jl | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/quarto/adjust_plotly.jl b/quarto/adjust_plotly.jl index 5060e98..c646e5e 100644 --- a/quarto/adjust_plotly.jl +++ b/quarto/adjust_plotly.jl @@ -5,19 +5,40 @@ # This little script just adds a line *before* the require call # which seems to make it all work. The line number 83 might change. -f = "_book/alternatives/plotly_plotting.html" -lineno = 88 +#alternatives/plotly_plotting.html +function _add_plotly(f) + lineno = 117 str = """ - - """ -r = readlines(f) -open(f, "w") do io - for (i,l) ∈ enumerate(r) - i == lineno && println(io, str) - println(io, l) + r = readlines(f) + open(f, "w") do io + for (i,l) ∈ enumerate(r) + i == lineno && println(io, str) + println(io, l) + end end end + + + +function (@main)(args...) + for (root, dirs, files) in walkdir("_book") + for fᵢ ∈ files + f = joinpath(root, fᵢ) + if endswith(f, ".html") + @show :adjust, f + _add_plotly(f) + end + end + end + + #f = "_book/integrals/center_of_mass.html" + #_add_plotly(f) + + return 1 +end + + ["ODEs", "alternatives", "derivatives", "differentiable_vector_calculus", "integral_vector_calculus", "integrals", "limits", "misc", "precalc", "site_libs"] From bc71a0b9d76a6c0e5a24a7ab76db503a7c35d7a2 Mon Sep 17 00:00:00 2001 From: Fang Liu Date: Wed, 2 Jul 2025 09:26:04 +0800 Subject: [PATCH 7/8] some typos. --- .../polar_coordinates.qmd | 2 +- .../scalar_functions.qmd | 2 +- .../vector_valued_functions.qmd | 10 +++++----- quarto/precalc/vectors.qmd | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/quarto/differentiable_vector_calculus/polar_coordinates.qmd b/quarto/differentiable_vector_calculus/polar_coordinates.qmd index b8b91f4..b2a1975 100644 --- a/quarto/differentiable_vector_calculus/polar_coordinates.qmd +++ b/quarto/differentiable_vector_calculus/polar_coordinates.qmd @@ -199,7 +199,7 @@ r(theta) = a * sin(k * theta) plot_polar(0..pi, r) ``` -This graph has radius $0$ whenever $\sin(k\theta) = 0$ or $k\theta =n\pi$. Solving means that it is $0$ at integer multiples of $\pi/k$. In the above, with $k=5$, there will $5$ zeroes in $[0,\pi]$. The entire curve is traced out over this interval, the values from $\pi$ to $2\pi$ yield negative value of $r$, so are related to values within $0$ to $\pi$ via the relation $(r,\pi +\theta) = (-r, \theta)$. +This graph has radius $0$ whenever $\sin(k\theta) = 0$ or $k\theta =n\pi$. Solving means that it is $0$ at integer multiples of $\pi/k$. In the above, with $k=5$, there will $6$ zeroes in $[0,\pi]$. The entire curve is traced out over this interval, the values from $\pi$ to $2\pi$ yield negative value of $r$, so are related to values within $0$ to $\pi$ via the relation $(r,\pi +\theta) = (-r, \theta)$. ##### Example diff --git a/quarto/differentiable_vector_calculus/scalar_functions.qmd b/quarto/differentiable_vector_calculus/scalar_functions.qmd index 2e5046c..af75fec 100644 --- a/quarto/differentiable_vector_calculus/scalar_functions.qmd +++ b/quarto/differentiable_vector_calculus/scalar_functions.qmd @@ -125,7 +125,7 @@ Then we can define an alternative method with just a single variable and use spl j(v) = j(v...) ``` -The we can call `j` with a vector or point: +Then we can call `j` with a vector or point: ```{julia} diff --git a/quarto/differentiable_vector_calculus/vector_valued_functions.qmd b/quarto/differentiable_vector_calculus/vector_valued_functions.qmd index 738b8c4..b6267b6 100644 --- a/quarto/differentiable_vector_calculus/vector_valued_functions.qmd +++ b/quarto/differentiable_vector_calculus/vector_valued_functions.qmd @@ -104,7 +104,7 @@ However, we will use a different approach, as the component functions are not n In `Plots`, the command `plot(xs, ys)`, where, say, `xs=[x1, x2, ..., xn]` and `ys=[y1, y2, ..., yn]`, will make a connect-the-dot plot between corresponding pairs of points. As previously discussed, this can be used as an alternative to plotting a function through `plot(f, a, b)`: first make a set of $x$ values, say `xs=range(a, b, length=100)`; then the corresponding $y$ values, say `ys = f.(xs)`; and then plotting through `plot(xs, ys)`. -Similarly, were a third vector, `zs`, for $z$ components used, `plot(xs, ys, zs)` will make a $3$-dimensional connect the dot plot +Similarly, were a third vector, `zs`, for $z$ components used, `plot(xs, ys, zs)` will make a $3$-dimensional connect the dot plot. However, our representation of vector-valued functions naturally generates a vector of points: `[[x1,y1], [x2, y2], ..., [xn, yn]]`, as this comes from broadcasting `f` over some time values. That is, for a collection of time values, `ts` the command `f.(ts)` will produce a vector of points. (Technically a vector of vectors, but points if you identify the $2$-$d$ vectors as points.) @@ -1247,7 +1247,7 @@ $$ \kappa = (x'y''-x''y')/\|r'\|^3. \quad (r(t) =\langle x(t), y(t) \rangle) $$ -Curvature can also be defined as derivative of the tangent vector, $\hat{T}$, *when* the curve is parameterized by arc length, a topic still to be taken up. The vector $\vec{r}'(t)$ is the direction of motion, whereas $\vec{r}''(t)$ indicates how fast and in what direction this is changing. For curves with little curve in them, the two will be nearly parallel and the cross product small (reflecting the presence of $\cos(\theta)$ in the definition). For "curvy" curves, $\vec{r}''$ will be in a direction opposite of $\vec{r}'$ to the $\cos(\theta)$ term in the cross product will be closer to $1$. +Curvature can also be defined as derivative of the tangent vector, $\hat{T}$, *when* the curve is parameterized by arc length, a topic still to be taken up. The vector $\vec{r}'(t)$ is the direction of motion, whereas $\vec{r}''(t)$ indicates how fast and in what direction this is changing. For curves with little curve in them, the two will be nearly parallel and the cross product small (reflecting the presence of $\sin(\theta)$ in the definition). For "curvy" curves, $\vec{r}''$ will be in a direction orthogonal of $\vec{r}'$ to the $\sin(\theta)$ term in the cross product will be closer to $1$. Let $\vec{r}(t) = k \cdot \langle \cos(t), \sin(t), 0 \rangle$. This will have curvature: @@ -1728,7 +1728,7 @@ $$ \begin{align*} \vec{0} &= (\vec{U} + a(\alpha' - \kappa) \sin(\alpha) \vec{U} -+ a(\alpha' - \kappa) \cos(\alpha)\vec{V}) \times +- a(\alpha' - \kappa) \cos(\alpha)\vec{V}) \times (\vec{U} \cos(\alpha) + \vec{V} \sin(\alpha)) \\ &= (\vec{U} \times \vec{V}) \sin(\alpha) + a(\alpha' - \kappa) \sin(\alpha) \vec{U} \times \vec{V} \sin(\alpha) - @@ -1762,7 +1762,7 @@ $$ $$ -From this $\|\vec{B}(u)\| = |\cos(\alpha)\|$. But $1 = \|d\vec{B}/dv\| = \|d\vec{B}/du \| \cdot |du/dv|$ and $|dv/du|=|\cos(\alpha)|$ follows. +From this $\|\vec{B}'(u)\| = |\cos(\alpha)|$. But $1 = \|d\vec{B}/dv\| = \|d\vec{B}/du \| \cdot |du/dv|$ and $|dv/du|=|\cos(\alpha)|$ follows. @@ -2804,7 +2804,7 @@ What is the resulting curve? choices = [ "An astroid of the form ``c \\langle \\cos^3(t), \\sin^3(t) \\rangle``", "An cubic parabola of the form ``\\langle ct^3, dt^2\\rangle``", -"An ellipse of the form ``\\langle a\\cos(t), b\\sin(t)``", +"An ellipse of the form ``\\langle a\\cos(t), b\\sin(t)\\rangle``", "A cyloid of the form ``c\\langle t + \\sin(t), 1 - \\cos(t)\\rangle``" ] answ = 1 diff --git a/quarto/precalc/vectors.qmd b/quarto/precalc/vectors.qmd index e5e93f3..bb23e18 100644 --- a/quarto/precalc/vectors.qmd +++ b/quarto/precalc/vectors.qmd @@ -144,7 +144,7 @@ Two operations on vectors are fundamental. * Vectors can be multiplied by a scalar (a real number): $c\vec{v} = \langle cx,~ cy \rangle$. Geometrically this scales the vector by a factor of $\lvert c \rvert$ and switches the direction of the vector by $180$ degrees (in the $2$-dimensional case) when $c < 0$. A *unit vector* is one with magnitude $1$, and, except for the $\vec{0}$ vector, can be formed from $\vec{v}$ by dividing $\vec{v}$ by its magnitude. A vector's two parts are summarized by its direction given by a unit vector **and** its magnitude given by the norm. - * Vectors can be added: $\vec{v} + \vec{w} = \langle v_x + w_x,~ v_y + w_y \rangle$. That is, each corresponding component adds to form a new vector. Similarly for subtraction. The $\vec{0}$ vector then would be just $\langle 0,~ 0 \rangle$ and would satisfy $\vec{0} + \vec{v} = \vec{v}$ for any vector $\vec{v}$. Vector addition, $\vec{v} + \vec{w}$, is visualized by placing the tail of $\vec{w}$ at the tip of $\vec{v}$ and then considering the new vector with tail coming from $\vec{v}$ and tip coming from the position of the tip of $\vec{w}$. Subtraction is different, place both the tails of $\vec{v}$ and $\vec{w}$ at the same place and the new vector has tail at the tip of $\vec{v}$ and tip at the tip of $\vec{w}$. + * Vectors can be added: $\vec{v} + \vec{w} = \langle v_x + w_x,~ v_y + w_y \rangle$. That is, each corresponding component adds to form a new vector. Similarly for subtraction. The $\vec{0}$ vector then would be just $\langle 0,~ 0 \rangle$ and would satisfy $\vec{0} + \vec{v} = \vec{v}$ for any vector $\vec{v}$. Vector addition, $\vec{v} + \vec{w}$, is visualized by placing the tail of $\vec{w}$ at the tip of $\vec{v}$ and then considering the new vector with tail coming from $\vec{v}$ and tip coming from the position of the tip of $\vec{w}$. Subtraction is different, place both the tails of $\vec{v}$ and $\vec{w}$ at the same place and the new vector has tail at the tip of $\vec{w}$ and tip at the tip of $\vec{v}$. ```{julia} From 6c108037122ced1e653ac8aef89898f058821458 Mon Sep 17 00:00:00 2001 From: jverzani Date: Wed, 2 Jul 2025 11:09:37 -0400 Subject: [PATCH 8/8] modify adjust_plotly --- quarto/adjust_plotly.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/quarto/adjust_plotly.jl b/quarto/adjust_plotly.jl index c646e5e..ec06770 100644 --- a/quarto/adjust_plotly.jl +++ b/quarto/adjust_plotly.jl @@ -7,16 +7,19 @@ #alternatives/plotly_plotting.html function _add_plotly(f) - lineno = 117 + #lineno = 117 -str = """ - -""" r = readlines(f) + inserted = false open(f, "w") do io for (i,l) ∈ enumerate(r) - i == lineno && println(io, str) + if contains(l, "require.min.js") + !inserted && println(io, """ + +""") + inserted = true + end println(io, l) end end @@ -29,7 +32,7 @@ function (@main)(args...) for fᵢ ∈ files f = joinpath(root, fᵢ) if endswith(f, ".html") - @show :adjust, f + dirname(f) == "_book" && continue _add_plotly(f) end end