Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani committed Apr 28, 2022
2 parents 4164967 + f297108 commit 1415f7d
Show file tree
Hide file tree
Showing 90 changed files with 3,231 additions and 30,986 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,25 @@ jobs:
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: doctest
using CalculusWithJulia
doctest(CalculusWithJulia)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
115 changes: 115 additions & 0 deletions CwJ/TODO/ladder-questions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
###### Question (Ladder [questions](http://www.mathematische-basteleien.de/ladder.htm))


A ``7``meter ladder leans against wall with the base ``1.5``meters from wall at its base. At which height does the ladder touch the wall?

```julia; hold=true; echo=false
l = 7
adj = 1.5
opp = sqrt(l^2 - adj^2)
numericq(opp, 1e-3)
```


----

A ``7``meter ladder leans against the wall. Between the ladder and the wall is a ``1``m cube box. The ladder touches the wall, the box and the ground. There are two such positions, what is the height of the ladder of the more upright position?

You might find this code of help:

```julia; eval=false
@syms x y
l, b = 7, 1
eq = (b+x)^2 + (b+y)^2
eq = subs(eq, x=> b*(b/y)) # x/b = b/y
solve(eq ~ l^2, y)
```

What is the value `b+y` in the above?

```julia; echo=false
radioq(("The height of the ladder",
"The height of the box plus ladder",
"The distance from the base of the ladder to the box,"
"The distance from the base of the ladder to the base of the wall"
),1)
```


What is the height of the ladder

```julia; hold=true; echo=false
numericq(6.90162289514212, 1e-3)
```


----

A ladder of length ``c`` is to moved through a 2-dimensional hallway of width ``b`` which has a right angled bend. If ``4b=c``, when will the ladder get stuck?

Consider this picture

```julia; hold=true; echo=false
p = plot(; axis=nothing, legend=false, aspect_ratio=:equal)
x,y=1,2
b = sqrt(x*y)
plot!(p, [0,0,b+x], [b+y,0,0], linestyle=:dot)
plot!(p, [0,b+x],[b,b], color=:black, linestyle=:dash)
plot!(p, [b,b],[0,b+y], color=:black, linestyle=:dash)
plot!(p, [b+x,0], [0, b+y], color=:black)
```


Suppose ``b=5``, then with ``b+x`` and ``b+y`` being the lengths on the walls where it is stuck *and* by similar triangles ``b/x = y/b`` we can solve for ``x``. (In the case take the largest positive value. The answer would be the angle ``\theta`` with ``\tan(\theta) = (b+y)/(b+x)``.

```julia; hold=true; echo=false
b = 5
l = 4*b
@syms x y
eq = (b+x)^2 + (b+y)^2
eq =subs(eq, y=> b^2/x)
x₀ = N(maximum(filter(>(0), solve(eq ~ l^2, x))))
y₀ = b^2/x₀
θ₀ = Float64(atan((b+y₀)/(b+x₀)))
numericq(θ₀, 1e-2)
```


-----

Two ladders of length ``a`` and ``b`` criss-cross between two walls of width ``x``. They meet at a height of ``c``.

```julia; hold=true; echo=false
p = plot(; legend=false, axis=nothing, aspect_ratio=:equal)
ya,yb,x = 2,3,1
plot!(p, [0,x],[ya,0], color=:black)
plot!(p, [0,x],[0, yb], color=:black)
plot!(p, [0,0], [0,yb], color=:blue, linewidth=5)
plot!(p, [x,x], [0,yb], color=:blue, linewidth=5)
plot!(p, [0,x], [0,0], color=:blue, linewidth=5)
xc = ya/(ya+yb)
c = yb*xc
plot!(p, [xc,xc],[0,c])
p
```

Suppose ``c=1``, ``b=3``, and ``a=5``. Find ``x``.

Introduce ``x = z + y``, and ``h`` and ``k`` the heights of the ladders along the left wall and the right wall.

The ``z/c = x/k`` and ``y/c = x/h`` by similar triangles. As ``z + y`` is ``x`` we can solve to get

```math
x = z + y = \frac{xc}{k} + \frac{xc}{h}
= \frac{xc}{\sqrt{b^2 - x^2}} + \frac{xc}{\sqrt{a^2 - x^2}}
```

With ``a,b,c`` as given, this can be solved with

```julia; hold=true; echo=false
a,b,c = 5, 3, 1
f(x) = x*c/sqrt(b^2 - x^2) + x*c/sqrt(a^2 - x^2) - x
find_zero(f, (0, b))
```

The answer is ``2.69\dots``.
54 changes: 10 additions & 44 deletions CwJ/derivatives/derivatives.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,8 @@ Consider this picture of composition:
```julia; hold=true; echo=false
f(x) = sin(x)
g(x) = exp(x)
a,b = 0, 1.6
a,b = 0, 1.55

xs = range(a, b, length=100)
ys = g.(xs)
us = range(extrema(ys)..., length=100)
Expand Down Expand Up @@ -1425,59 +1426,24 @@ Assuming the approximation gets better for ``h`` close to ``0``, as it visually
&= \lim_{h\rightarrow 0} \frac{f(g(1) + g'(1)h)-f(g(1))}{h}\\
&= \lim_{h\rightarrow 0} \frac{f(g(1) + g'(1)h)-f(g(1))}{g'(1)h} \cdot g'(1)\\
&= \lim_{h\rightarrow 0} (f\circ g)'(1) \cdot g'(1).
\end{align*
\end{align*}
```

Whta limit law (described below assuming all limits exist) allows the last equals sign?

```julia; hold=true; echo=false
choices = [
"""
The limit of a sum is the sum of the limits:
``\lim_{x\rightarrow c}(af(x)+bg(x)) = a\lim_{x\rightarrow c}f(x) + b\lim_{x\rightarrow c}g(x)``
""",
"""
The limit of a product is the product of the limits:
``\lim_{x\rightarrow c}(f(x)\cdot g(x)) = \lim_{x\rightarrow c}f(x) \cdot \lim_{x\rightarrow c}g(x)``
""",
"""
The limit of a composition (``f`` is continuous):
``\lim_{x \rightarrow c}f(g(x)) = \lim_{v \rightarrow \lim_{x \rightarrow c}g(x)} f(v)``.
"""
]
radioq(choices, 3, keep_order=true)
```


Consider the function ``k(x) = f(a + bx)``. We can directly find the ``k'(0)`` using a limit (as an alternative to using the chain rule):

```math
\begin{align*}
g'(x) &= \lim_{h\rightarrow 0} \frac{k(h) - k(0)}{h}\\
&= \lim_{h\rightarrow 0} \frac{f(a + b\cdot h) - f(a)}{h}\\
&= \lim_{h\rightarrow 0} \frac{f(a+ bh)) - f(a)}{bh} \cdot b\\
&= \lim_{v\rightarrow 0} \frac{f(a+ v)) - f(a)}{v} \cdot b \quad\text{where } v = bh\\
&= f'(a) \cdot b
\end{align*
```

Which, with ``a = g(x)`` and ``b=g'(x)`` shows heuristically that ``(f\circ g)'(x) = f'(g(x)) \cdot g'(x)``.

What limit law (described below assuming all limits exist) allows the second to last equals sign?

```julia; hold=true; echo=false
choices = [
"""
raw"""
The limit of a sum is the sum of the limits:
``\lim_{x\rightarrow c}(af(x)+bg(x)) = a\lim_{x\rightarrow c}f(x) + b\lim_{x\rightarrow c}g(x)``
``\lim_{x\rightarrow c}(au(x)+bv(x)) = a\lim_{x\rightarrow c}u(x) + b\lim_{x\rightarrow c}v(x)``
""",
"""
raw"""
The limit of a product is the product of the limits:
``\lim_{x\rightarrow c}(f(x)\cdot g(x)) = \lim_{x\rightarrow c}f(x) \cdot \lim_{x\rightarrow c}g(x)``
``\lim_{x\rightarrow c}(u(x)\cdot v(x)) = \lim_{x\rightarrow c}u(x) \cdot \lim_{x\rightarrow c}v(x)``
""",
"""
The limit of a composition (``f`` is continuous):
``\lim_{x \rightarrow c}f(g(x)) = \lim_{v \rightarrow \lim_{x \rightarrow c}g(x)} f(v)``.
raw"""
The limit of a composition (under assumptions on ``v``):
``\lim_{x \rightarrow c}u(v(x)) = \lim_{w \rightarrow \lim_{x \rightarrow c}v(x)} u(w)``.
"""
]
radioq(choices, 3, keep_order=true)
Expand Down
3 changes: 1 addition & 2 deletions CwJ/derivatives/implicit_differentiation.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -936,11 +936,10 @@ imgfile = "figures/fcarc-may2016-fig35-350.gif"
caption = """
Image number 35 from L'Hospitals calculus book (the first). Given a description of the curve, identify the point ``E`` which maximizes the height.
"""
#ImageFile(:derivatives, imgfile, caption)
ImageFile(:derivatives, imgfile, caption)
nothing
```

![Image number 35 from L'Hospitals calculus book (the first). Given a description of the curve, identify the point ``E`` which maximizes the height.](https://raw.githubusercontent.com/jverzani/CalculusWithJulia.jl/master/CwJ/derivatives/figures/fcarc-may2016-fig35-350.gif)

The figure above shows a problem appearing in L'Hospital's first calculus book. Given a function defined implicitly by ``x^3 + y^3 = axy`` (with ``AP=x``, ``AM=y`` and ``AB=a``) find the point ``E`` that maximizes the height. In the [AMS feature column](http://www.ams.org/samplings/feature-column/fc-2016-05) this problem is illustrated and solved in the historical manner, with the comment that the concept of implicit differentiation wouldn't have occurred to L'Hospital.

Expand Down
18 changes: 9 additions & 9 deletions CwJ/derivatives/mean_value_theorem.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ That is the function $f(x)$, minus the secant line between $(a,f(a))$ and $(b, f

```julia; hold=true; echo=false
# Need to bring jsxgraph into PLUTO
caption = """
Illustration of the mean value theorem from
[jsxgraph](https://jsxgraph.uni-bayreuth.de/).
The polynomial function interpolates the points ``A``,``B``,``C``, and ``D``.
Adjusting these creates different functions. Regardless of the
function -- which as a polynomial will always be continuous and
differentiable -- the slope of the secant line between ``A`` and ``B`` is always matched by **some** tangent line between the points ``A`` and ``B``.
"""
JSXGraph(:derivatives, "mean-value.js", caption)
#caption = """
#Illustration of the mean value theorem from
#[jsxgraph](https://jsxgraph.uni-bayreuth.de/).
#The polynomial function interpolates the points ``A``,``B``,``C``, and ``D``.
#Adjusting these creates different functions. Regardless of the
#function -- which as a polynomial will always be continuous and
#differentiable -- the slope of the secant line between ``A`` and ``B`` is alway#s matched by **some** tangent line between the points ``A`` and ``B``.
#"""
#JSXGraph(:derivatives, "mean-value.js", caption)
nothing
```

Expand Down
2 changes: 1 addition & 1 deletion CwJ/derivatives/taylor_series_polynomials.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ radioq(choices, ans)

###### Question

The ``5``th order Taylor polynomial for $\sin(x)$ about $c=0$ is: $x - x^3/3! + x^5/5!$. Use this to find the first ``3`` terms of the Taylor polynomial of $\sin(x^2)$ about $c=0$.
The ``5``th order Taylor polynomial for $\sin(x)$ about $c=0$ is: $x - x^3/3! + x^5/5!$. Use this to find the first ``3`` terms of the Taylor polynomial of $\sin(x^2)$ about $c=0$.

They are:

Expand Down
Loading

0 comments on commit 1415f7d

Please sign in to comment.