use plotly; fix bitrot
This commit is contained in:
@@ -9,6 +9,7 @@ This section uses these add-on packages:
|
||||
```{julia}
|
||||
using CalculusWithJulia
|
||||
using Plots
|
||||
plotly()
|
||||
using SymPy
|
||||
using Roots
|
||||
```
|
||||
@@ -20,7 +21,7 @@ using Roots
|
||||
The Babylonian method is an algorithm to find an approximate value for $\sqrt{k}$. It was described by the first-century Greek mathematician Hero of [Alexandria](http://en.wikipedia.org/wiki/Babylonian_method).
|
||||
|
||||
|
||||
The method starts with some initial guess, called $x_0$. It then applies a formula to produce an improved guess. This is repeated until the improved guess is accurate enough or it is clear the algorithm fails to work.
|
||||
The method starts with some initial guess, called $x_0$. This is usually some nearby value to the answer. The method then applies a formula to produce an improved guess. This is repeated until the improved guess is accurate enough or it is clear the algorithm fails to work.
|
||||
|
||||
|
||||
For the Babylonian method, the next guess, $x_{i+1}$, is derived from the current guess, $x_i$. In mathematical notation, this is the updating step:
|
||||
@@ -250,7 +251,7 @@ nothing
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
### {{{newtons_method_example}}}
|
||||
|
||||
gr()
|
||||
caption = """
|
||||
|
||||
Illustration of Newton's Method converging to a zero of a function.
|
||||
@@ -266,7 +267,7 @@ end
|
||||
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 1)
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
@@ -730,6 +731,7 @@ What can go wrong when one of these isn't the case is illustrated next:
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
### {{{newtons_method_poor_x0}}}
|
||||
gr()
|
||||
caption = """
|
||||
|
||||
Illustration of Newton's Method converging to a zero of a function,
|
||||
@@ -748,7 +750,7 @@ end
|
||||
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 2)
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
@@ -757,6 +759,7 @@ ImageFile(imgfile, caption)
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
# {{{newtons_method_flat}}}
|
||||
gr()
|
||||
caption = L"""
|
||||
|
||||
Illustration of Newton's method failing to converge as for some $x_i$,
|
||||
@@ -777,7 +780,7 @@ anim = @animate for i=1:n
|
||||
end
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 1)
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
@@ -789,7 +792,7 @@ ImageFile(imgfile, caption)
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
# {{{newtons_method_cycle}}}
|
||||
|
||||
gr()
|
||||
fn, a, b, c, = x -> abs(x)^(0.49), -2, 2, 1.0
|
||||
caption = L"""
|
||||
|
||||
@@ -808,6 +811,7 @@ end
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 2)
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
@@ -819,7 +823,7 @@ ImageFile(imgfile, caption)
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
# {{{newtons_method_wilkinson}}}
|
||||
|
||||
gr()
|
||||
caption = L"""
|
||||
|
||||
The function $f(x) = x^{20} - 1$ has two bad behaviours for Newton's
|
||||
@@ -845,7 +849,7 @@ anim = @animate for i=1:n
|
||||
end
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 1)
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user