From 82c51c7d58b5e391fb4e2b02e8d1ea3e3089f561 Mon Sep 17 00:00:00 2001 From: Fang Liu Date: Fri, 21 Jul 2023 16:47:36 +0800 Subject: [PATCH] update some typos. --- quarto/alternatives/SciML.qmd | 22 +++++++++++----------- quarto/alternatives/makie_plotting.qmd | 4 ++-- quarto/alternatives/plotly_plotting.qmd | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/quarto/alternatives/SciML.qmd b/quarto/alternatives/SciML.qmd index 4c224fa..94a6d1a 100644 --- a/quarto/alternatives/SciML.qmd +++ b/quarto/alternatives/SciML.qmd @@ -129,7 +129,7 @@ This problem can also be solved using a bracketing method. The package has both ```{julia} u0 = (1.0, 2.0) -prob = NonlinearProblem(f, u0) +prob = IntervalNonlinearProblem(f, u0) ``` And @@ -149,7 +149,7 @@ Incorporating parameters is readily done. For example to solve $f(x) = \cos(x) - f(x, p) = @. cos(x) - x/p u0 = (0, pi/2) p = 2 -prob = NonlinearProblem(f, u0, p) +prob = IntervalNonlinearProblem(f, u0, p) solve(prob, Bisection()) ``` @@ -159,7 +159,7 @@ The *insignificant* difference in stopping criteria used by `NonlinearSolve` and ```{julia} -an = solve(NonlinearProblem{false}(f, u0, p), Bisection()) +an = solve(IntervalNonlinearProblem{false}(f, u0, p), Bisection()) ar = solve(Roots.ZeroProblem(f, u0), Roots.Bisection(); p=p) nextfloat(an[]) == ar, f(an[], p), f(ar, p) ``` @@ -418,7 +418,7 @@ prob = OptimizationProblem(sys, u0, p; grad=true, hess=true) soln = solve(prob, LBFGS()) ``` -We used an initial guess of $x=4$ above. The `LBFGS` method is a computationally efficient modification of the Broyden-Fletcher-Goldfarb-Shanno algorithm ... It is a quasi-Newton method that updates an approximation to the Hessian using past approximations as well as the gradient." On this problem it performs similarly to `Newton`, though in general may be preferable for higher-dimensional problems. +We used an initial guess of $x=4$ above. The `LBFGS` method is a computationally efficient modification of the Broyden-Fletcher-Goldfarb-Shanno algorithm. It is a quasi-Newton method that updates an approximation to the Hessian using past approximations as well as the gradient. On this problem it performs similarly to `Newton`, though in general may be preferable for higher-dimensional problems. ### Two dimensional @@ -515,7 +515,7 @@ For a simple definite integral, such as $\int_0^\pi \sin(x)dx$, we have: ```{julia} f(x, p) = sin(x) -prob = IntegralProblem(f, 0.0, pi) +prob = IntegralProblem(f, 0.0, 1pi) soln = solve(prob, QuadGKJL()) ``` @@ -546,7 +546,7 @@ The `Integrals` solution is a bit more verbose, but it is more flexible. For exa ```{julia} f(x, p) = sin.(x) -prob = IntegralProblem(f, [0.0], [pi]) +prob = IntegralProblem(f, [0.0], [1pi]) soln = solve(prob, HCubatureJL()) ``` @@ -574,7 +574,7 @@ Consider $d/dp \int_0^\pi \sin(px) dx$. We can do this integral directly to get \frac{d}{dp} \int_0^\pi \sin(px)dx &= \frac{d}{dp}\left( \frac{-1}{p} \cos(px)\Big\rvert_0^\pi\right)\\ &= \frac{d}{dp}\left( -\frac{\cos(p\cdot\pi)-1}{p}\right)\\ -&= \frac{\cos(p\cdot \pi) - 1)}{p^2} + \frac{\pi\cdot\sin(p\cdot\pi)}{p} +&= \frac{\cos(p\cdot \pi) - 1}{p^2} + \frac{\pi\cdot\sin(p\cdot\pi)}{p} \end{align*} Using `Integrals` with `QuadGK` we have: @@ -583,7 +583,7 @@ Using `Integrals` with `QuadGK` we have: ```{julia} f(x, p) = sin(p*x) function ∫sinpx(p) - prob = IntegralProblem(f, 0.0, pi, p) + prob = IntegralProblem(f, 0.0, 1pi, p) solve(prob, QuadGKJL()) end ``` @@ -614,7 +614,7 @@ The power of a common interface is the ability to swap backends and the uniformi #### $f: R^n \rightarrow R$ -The area under a surface generated by $z=f(x,y)$ over a rectangular region $[a,b]\times[c,d]$ can be readily computed. The two coding implementations require $f$ to be expressed as a function of a vector–*and* a parameter–and the interval to be expressed using two vectors, one for the left endpoints (`[a,c]`) and on for the right endpoints (`[b,d]`). +The area under a surface generated by $z=f(x,y)$ over a rectangular region $[a,b]\times[c,d]$ can be readily computed. The two coding implementations require $f$ to be expressed as a function of a vector–*and* a parameter–and the interval to be expressed using two vectors, one for the left endpoints (`[a,c]`) and one for the right endpoints (`[b,d]`). For example, the area under the function $f(x,y) = 1 + x^2 + 2y^2$ over $[-1/2, 1/2] \times [-1,1]$ is computed by: @@ -664,7 +664,7 @@ To compute this transformed integral, we might have: ```{julia} function vol_sphere(ρ) f(rθ, p) = sqrt(ρ^2 - rθ[1]^2) * rθ[1] - ls = [0,0] + ls = [0.0,0.0] rs = [ρ, 2pi] prob = IntegralProblem(f, ls, rs) solve(prob, HCubatureJL()) @@ -677,7 +677,7 @@ If it is possible to express the region to integrate as $G(R)$ where $R$ is a re $$ -\iint_{G(R)} f(x) dA = \iint_R (f\circ G)(u) |det(J_G(u)| dU +\iint_{G(R)} f(x) dA = \iint_R (f\circ G)(u) |det(J_G(u))| dU $$ turns the integral into the non-rectangular domain $G(R)$ into one over the rectangular domain $R$. The key is to *identify* $G$ and to compute the Jacobian. The latter is simply accomplished with `ForwardDiff.jacobian`. diff --git a/quarto/alternatives/makie_plotting.qmd b/quarto/alternatives/makie_plotting.qmd index 3d3b7c8..a4a8c61 100644 --- a/quarto/alternatives/makie_plotting.qmd +++ b/quarto/alternatives/makie_plotting.qmd @@ -15,7 +15,7 @@ The [Makie.jl webpage](https://github.com/JuliaPlots/Makie.jl) says :::{.callout-note} ## Examples and tutorials -`Makie` is a sophisticated plotting package, and capable of an enormous range of plots (cf. [examples](https://makie.juliaplots.org/stable/examples/plotting_functions/).) `Makie` also has numerous [tutorials](https://makie.juliaplots.org/stable/tutorials/) to learn from. These are far more extensive that what is described herein, as this section focuses just on the graphics from calculus. +`Makie` is a sophisticated plotting package, and capable of an enormous range of plots (cf. [examples](https://makie.juliaplots.org/stable/examples/plotting_functions/).) `Makie` also has numerous [tutorials](https://makie.juliaplots.org/stable/tutorials/) to learn from. These are far more extensive than what is described herein, as this section focuses just on the graphics from calculus. ::: @@ -186,7 +186,7 @@ The curves of calculus are lines. The `lines` command of `Makie` will render a c The basic plot of univariate calculus is the graph of a function $f$ over an interval $[a,b]$. This is implemented using a familiar strategy: produce a series of representative values between $a$ and $b$; produce the corresponding $f(x)$ values; plot these as points and connect the points with straight lines. -To create regular values between `a` and `b` typically the `range` function or the range operator (`a:h:b`) are employed. The the related `LinRange` function is also an option. +To create regular values between `a` and `b` typically the `range` function or the range operator (`a:h:b`) are employed. The related `LinRange` function is also an option. For example: diff --git a/quarto/alternatives/plotly_plotting.qmd b/quarto/alternatives/plotly_plotting.qmd index bef29e1..5ba72ab 100644 --- a/quarto/alternatives/plotly_plotting.qmd +++ b/quarto/alternatives/plotly_plotting.qmd @@ -149,7 +149,7 @@ The difference is solely the specification of the `mode` value, for a line plot ### Nothing -The line graph plays connect-the-dots with the points specified by paired `x` and `y` values. *Typically*, when and `x` value is `NaN` that "dot" (or point) is skipped. However, `NaN` doesn't pass through the JSON conversion – `nothing` can be used. +The line graph plays connect-the-dots with the points specified by paired `x` and `y` values. *Typically*, when `x` value is `NaN` that "dot" (or point) is skipped. However, `NaN` doesn't pass through the JSON conversion – `nothing` can be used. ```{julia} @@ -381,17 +381,17 @@ In the following, to highlight the difference between $f(x) = \cos(x)$ and $p(x) xs = range(-1, 1, 100) data = [ Config( - x=xs, y=cos.(xs), - fill = "tonexty", - fillcolor = "rgba(0,0,255,0.25)", # to get transparency - line = Config(color=:blue) - ), - Config( x=xs, y=[1 - x^2/2 for x ∈ xs ], fill = "tozeroy", fillcolor = "rgba(255,0,0,0.25)", # to get transparency line = Config(color=:red) - ) + ), + Config( + x=xs, y=cos.(xs), + fill = "tonexty", + fillcolor = "rgba(0,0,255,0.25)", # to get transparency + line = Config(color=:blue) + ) ] Plot(data) ``` @@ -428,7 +428,7 @@ lyt = Config(title = "Main chart title", Plot(data, lyt) ``` -The `xaxis` and `yaxis` keys have many customizations. For example: `nticks` specifies the maximum number of ticks; `range` to set the range of the axis; `type` to specify the axis type from "linear", "log", "date", "category", or "multicategory;" and `visible` +The `xaxis` and `yaxis` keys have many customizations. For example: `nticks` specifies the maximum number of ticks; `range` to set the range of the axis; `type` to specify the axis type from "linear", "log", "date", "category", or "multicategory"; and `visible`. The aspect ratio of the chart can be set to be equal through the `scaleanchor` key, which specifies another axis to take a value from. For example, here is a parametric plot of a circle: