use plotly; fix bitrot

This commit is contained in:
jverzani
2024-06-07 13:07:09 -04:00
parent 0bcc8b5a6c
commit 55f37a6dfb
59 changed files with 423 additions and 176 deletions

View File

@@ -9,6 +9,7 @@ This section uses the following add-on packages:
```{julia}
using CalculusWithJulia
using Plots
plotly()
using Richardson # for extrapolation
using SymPy # for symbolic limits
```
@@ -28,7 +29,7 @@ There wasn't a ready-made formula for the area of this shape, as was known for a
#| echo: false
#| cache: true
###{{{archimedes_parabola}}}
gr()
f(x) = x^2
colors = [:black, :blue, :orange, :red, :green, :orange, :purple]
@@ -76,6 +77,7 @@ The first triangle has area $1/2$, the second has area $1/8$, then $2$ have area
With some algebra, the total area then should be $1/2 \cdot (1 + (1/4) + (1/4)^2 + \cdots) = 2/3$.
"""
plotly()
ImageFile(imgfile, caption)
```
@@ -102,7 +104,7 @@ Next, we illustrate how Archimedes approximated $\pi$ the ratio of the circu
#| hold: true
#| echo: false
## Archimedes approximation for pi
gr()
blue, green, purple, red = :royalblue, :forestgreen, :mediumorchid3, :brown3
@@ -161,7 +163,7 @@ end
caption = L"""
The ratio of the circumference of a circle to its diameter, $\pi$, can be approximated from above and below by computing the perimeters of the inscribed $n$-gons. Archimedes computed the perimeters for $n$ being $12$, $24$, $48$, and $96$ to determine that $3~1/7 \leq \pi \leq 3~10/71$.
"""
plotly()
ImageFile(p, caption)
```
@@ -217,6 +219,7 @@ The above bound comes from this figure, for small $x > 0$:
```{julia}
#| hold: true
#| echo: false
gr()
p = plot(x -> sqrt(1 - x^2), 0, 1, legend=false, aspect_ratio=:equal,
linewidth=3, color=:black)
θ = π/6
@@ -237,6 +240,7 @@ imgfile = tempname() * ".png"
savefig(p, imgfile)
caption = "Triangle ``ABD` has less area than the shaded wedge, which has less area than triangle ``ACD``. Their respective areas are ``(1/2)\\sin(\\theta)``, ``(1/2)\\theta``, and ``(1/2)\\tan(\\theta)``. The inequality used to show ``\\sin(x)/x`` is bounded below by ``\\cos(x)`` and above by ``1`` comes from a division by ``(1/2) \\sin(x)`` and taking reciprocals.
"
plotly()
ImageFile(imgfile, caption)
```
@@ -1022,7 +1026,7 @@ Then the limit of $f$ must also be $L$.
```{julia}
#| hold: true
#| echo: false
gr()
function squeeze_example(x)
x₀ = 0.5
plot(cos, 0, x₀, label="cos")
@@ -1043,6 +1047,7 @@ gif(anim, imgfile, fps = 1)
caption = """
As ``x`` goes to ``0``, the values of ``\\sin(x)/x`` are squeezed between ``\\cos(x)`` and ``1`` which both converge to ``1``.
"""
plotly()
ImageFile(imgfile, caption)
```
@@ -1089,6 +1094,7 @@ In this case, $\delta$ is easy to guess, as the function is linear and has slope
#| echo: false
#| cache: true
## {{{ limit_e_d }}}
gr()
function make_limit_e_d(n)
f(x) = x^3
@@ -1135,7 +1141,7 @@ does not leave the top or bottom of the box (except possibly at the
edges). In this example $\delta^3=\epsilon$.
"""
plotly()
ImageFile(imgfile, caption)
```
@@ -1247,6 +1253,7 @@ Select the graph for which there is no limit at $a$.
```{julia}
#| hold: true
#| echo: false
gr()
let
p1 = plot(;axis=nothing, legend=false)
title!(p1, "(a)")
@@ -1281,6 +1288,11 @@ let
end
```
```{julia}
#| echo: false
plotly();
```
###### Question