edits
This commit is contained in:
@@ -72,7 +72,7 @@ The definition says three things
|
||||
* The value of the limit is the same as $f(c)$.
|
||||
|
||||
|
||||
The defined speaks to continuity at a point, we can extend it to continuity over an interval $(a,b)$ by saying:
|
||||
The definition speaks to continuity at a point, we can extend it to continuity over an interval $(a,b)$ by saying:
|
||||
|
||||
::: {.callout-note icon=false}
|
||||
## Definition of continuity over an open interval
|
||||
@@ -130,9 +130,9 @@ There are various reasons why a function may not be continuous.
|
||||
|
||||
$$
|
||||
f(x) = \begin{cases}
|
||||
-1 & x < 0 \\
|
||||
0 & x = 0 \\
|
||||
1 & x > 0
|
||||
-1 &~ x < 0 \\
|
||||
0 &~ x = 0 \\
|
||||
1 &~ x > 0
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
@@ -148,25 +148,57 @@ is implemented by `Julia`'s `sign` function. It has a value at $0$, but no limit
|
||||
plot([-1,-.01], [-1,-.01], legend=false, color=:black)
|
||||
plot!([.01, 1], [.01, 1], color=:black)
|
||||
scatter!([0], [1/2], markersize=5, markershape=:circle)
|
||||
ts = range(0, 2pi, 100)
|
||||
C = Shape(0.02 * sin.(ts), 0.03 * cos.(ts))
|
||||
plot!(C, fill=(:white,1), line=(:black, 1))
|
||||
```
|
||||
|
||||
is not continuous at $x=0$. It has a limit of $0$ at $0$, a function value $f(0) =1/2$, but the limit and the function value are not equal.
|
||||
|
||||
|
||||
* The `floor` function, which rounds down to the nearest integer, is also not continuous at the integers, but is right continuous at the integers, as, for example, $\lim_{x \rightarrow 0+} f(x) = f(0)$. This graph emphasizes the right continuity by placing a point for the value of the function when there is a jump:
|
||||
|
||||
* The `floor` function, which rounds down to the nearest integer, is also not continuous at the integers, but is right continuous at the integers, as, for example, $\lim_{x \rightarrow 0+} f(x) = f(0)$. This graph emphasizes the right continuity by placing a filled marker for the value of the function when there is a jump and an open marker where the function is not that value.
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
x = [0,1]; y=[0,0]
|
||||
plt = plot(x.-2, y.-2, color=:black, legend=false)
|
||||
plot!(plt, x.-1, y.-1, color=:black)
|
||||
plot!(plt, x.-0, y.-0, color=:black)
|
||||
plot!(plt, x.+1, y.+1, color=:black)
|
||||
plot!(plt, x.+2, y.+2, color=:black)
|
||||
scatter!(plt, [-2,-1,0,1,2], [-2,-1,0,1,2], markersize=5, markershape=:circle)
|
||||
plt = let
|
||||
empty_style = (xticks=-4:4, yticks=-4:4,
|
||||
framestyle=:origin,
|
||||
legend=false)
|
||||
axis_style = (arrow=true, side=:head, line=(:gray, 1))
|
||||
text_style = (10,)
|
||||
fn_style = (;line=(:black, 3))
|
||||
fn2_style = (;line=(:red, 4))
|
||||
mark_style = (;line=(:gray, 1, :dot))
|
||||
domain_style = (;fill=(:orange, 0.35), line=nothing)
|
||||
range_style = (; fill=(:blue, 0.35), line=nothing)
|
||||
|
||||
ts = range(0, 2pi, 100)
|
||||
xys = sincos.(ts)
|
||||
xys = [.1 .* xy for xy in xys]
|
||||
|
||||
plot(; empty_style..., aspect_ratio=:equal)
|
||||
plot!([-4.25,4.25], [0,0]; axis_style...)
|
||||
plot!([0,0], [-4.25, 4.25]; axis_style...)
|
||||
|
||||
for k in -4:4
|
||||
P,Q = (k,k),(k+1,k)
|
||||
plot!([P,Q], line=(:black,1))
|
||||
S = Shape([k .+ xy for xy in xys])
|
||||
plot!(S; fill=(:black,))
|
||||
S = Shape([(k+1,k) .+ xy for xy in xys])
|
||||
plot!(S; fill=(:white,), line=(:black,1))
|
||||
end
|
||||
|
||||
|
||||
current()
|
||||
end
|
||||
plt
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly()
|
||||
nothing
|
||||
```
|
||||
|
||||
* The function $f(x) = 1/x^2$ is not continuous at $x=0$: $f(x)$ is not defined at $x=0$ and $f(x)$ has no limit at $x=0$ (in the usual sense).
|
||||
@@ -176,8 +208,8 @@ plt
|
||||
$$
|
||||
f(x) =
|
||||
\begin{cases}
|
||||
0 & \text{if } x \text{ is irrational,}\\
|
||||
1 & \text{if } x \text{ is rational.}
|
||||
0 &~ \text{if } x \text{ is irrational,}\\
|
||||
1 &~ \text{if } x \text{ is rational.}
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
@@ -192,8 +224,8 @@ Let a function be defined by cases:
|
||||
|
||||
$$
|
||||
f(x) = \begin{cases}
|
||||
3x^2 + c & x \geq 0,\\
|
||||
2x-3 & x < 0.
|
||||
3x^2 + c &~ x \geq 0,\\
|
||||
2x-3 &~ x < 0.
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
@@ -383,8 +415,8 @@ Let $f(x)$ be defined by
|
||||
|
||||
$$
|
||||
f(x) = \begin{cases}
|
||||
c + \sin(2x - \pi/2) & x > 0\\
|
||||
3x - 4 & x \leq 0.
|
||||
c + \sin(2x - \pi/2) &~ x > 0\\
|
||||
3x - 4 &~ x \leq 0.
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
@@ -423,12 +455,22 @@ Consider the function $f(x)$ given by the following graph
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
xs = range(0, stop=2, length=50)
|
||||
plot(xs, [sqrt(1 - (x-1)^2) for x in xs], legend=false, xlims=(0,4))
|
||||
plot!([2,3], [1,0])
|
||||
scatter!([3],[0], markersize=5)
|
||||
plot!([3,4],[1,0])
|
||||
scatter!([4],[0], markersize=5)
|
||||
let
|
||||
xs = range(0, stop=2, length=50)
|
||||
|
||||
plot(xs, [sqrt(1 - (x-1)^2) for x in xs];
|
||||
line=(:black,1),
|
||||
legend=false, xlims=(-0.1,4.1))
|
||||
plot!([2,3], [1,0]; line=(:black,1))
|
||||
plot!([3,4],[1,0]; line=(:black,1))
|
||||
|
||||
scatter!([(0,0)], markersize=5, markercolor=:black)
|
||||
scatter!([(2,0)], markersize=5, markercolor=:white)
|
||||
scatter!([(2, 1)], markersize=5; markercolor=:black)
|
||||
scatter!([(3,0)], markersize=5; markercolor=:black)
|
||||
scatter!([(3,1)], markersize=5; markercolor=:white)
|
||||
scatter!([(4,0)], markersize=5; markercolor=:black)
|
||||
end
|
||||
```
|
||||
|
||||
The function $f(x)$ is continuous at $x=1$?
|
||||
@@ -513,3 +555,29 @@ choices = ["Can't tell",
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
|
||||
A parametric equation is specified by a parameterization $(f(t), g(t)), a \leq t \leq b$. The parameterization will be continuous if and only if each function is continuous.
|
||||
|
||||
|
||||
Suppose $k_x$ and $k_y$ are positive integers and $a, b$ are positive numbers, will the [Lissajous](https://en.wikipedia.org/wiki/Parametric_equation#Lissajous_Curve) curve given by $(a\cos(k_x t), b\sin(k_y t))$ be continuous?
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
yesnoq(true)
|
||||
```
|
||||
|
||||
Here is a sample graph for $a=1, b=2, k_x=3, k_y=4$:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
a,b = 1, 2
|
||||
k_x, k_y = 3, 4
|
||||
plot(t -> a * cos(k_x *t), t-> b * sin(k_y * t), 0, 4pi)
|
||||
```
|
||||
|
||||
@@ -17,9 +17,9 @@ using SymPy
|
||||
---
|
||||
|
||||
|
||||
{width=40%}
|
||||
 figure 55.](figures/ivt.jpg){width=40%}
|
||||
|
||||
Continuity for functions is a valued property which carries implications. In this section we discuss two: the intermediate value theorem and the extreme value theorem. These two theorems speak to some fundamental applications of calculus: finding zeros of a function and finding extrema of a function. [L'Hospitals](https://ia801601.us.archive.org/26/items/infinimentpetits1716lhos00uoft/infinimentpetits1716lhos00uoft.pdf) figure 55, above, suggests why.
|
||||
Continuity for functions is a valued property which carries implications. In this section we discuss two: the intermediate value theorem and the extreme value theorem. These two theorems speak to some fundamental applications of calculus: finding zeros of a function and finding extrema of a function.
|
||||
|
||||
|
||||
## Intermediate Value Theorem
|
||||
@@ -38,7 +38,7 @@ If $f$ is continuous on $[a,b]$ with, say, $f(a) < f(b)$, then for any $y$ with
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
### {{{IVT}}}
|
||||
plt = let
|
||||
let
|
||||
gr()
|
||||
# IVT
|
||||
empty_style = (xaxis=([], false),
|
||||
@@ -68,7 +68,7 @@ plt = let
|
||||
plot!([(a,0),(a,f(a))]; line=(:black, 1, :dash))
|
||||
plot!([(b,0),(b,f(b))]; line=(:black, 1, :dash))
|
||||
|
||||
m = f(a/2 + b/2)
|
||||
m = f(a/2 + b/2) + 1.5
|
||||
plot!([a, b], [m,m]; line=(:black, 1, :dashdot))
|
||||
|
||||
δx = 0.03
|
||||
@@ -76,10 +76,10 @@ plt = let
|
||||
domain_style...)
|
||||
plot!(Shape((a-.1) .+ 2δx * [-1,1,1,-1], [f(a),f(a),f(b), f(b)]);
|
||||
range_style...)
|
||||
plot!(Shape((a-.1) .+ δx/2 * [-1,1,1,-1], [y0,y0,y1,y1]);
|
||||
plot!(Shape((a-.1) .+ 2δx/3 * [-1,1,1,-1], [y0,y0,y1,y1]);
|
||||
range_style...)
|
||||
|
||||
zs = find_zeros(f, (a,b))
|
||||
zs = find_zeros(x -> f(x) - m, (a,b))
|
||||
c = zs[2]
|
||||
plot!([(c,0), (c,f(c))]; line=(:black, 1, :dashdot))
|
||||
|
||||
@@ -89,52 +89,11 @@ plt = let
|
||||
(c, 0, text(L"c", 12, :top)),
|
||||
(a-.1, f(a), text(L"f(a)", 12, :right)),
|
||||
(a-.1, f(b), text(L"f(b)", 12, :right)),
|
||||
(b, m, text(L"y", 12, :left)),
|
||||
(a-0.2, m, text(L"y", 12, :right)),
|
||||
])
|
||||
end
|
||||
plt
|
||||
|
||||
#=
|
||||
function IVT_graph(n)
|
||||
f(x) = sin(pi*x) + 9x/10
|
||||
a,b = [0,3]
|
||||
|
||||
xs = range(a,stop=b, length=50)
|
||||
|
||||
|
||||
## cheat -- pick an x, then find a y
|
||||
Δ = .2
|
||||
x = range(a + Δ, stop=b - Δ, length=6)[n]
|
||||
y = f(x)
|
||||
|
||||
plt = plot(f, a, b, legend=false, size=fig_size)
|
||||
plot!(plt, [0,x,x], [f(x),f(x),0], color=:orange, linewidth=3)
|
||||
|
||||
plt
|
||||
|
||||
end
|
||||
|
||||
n = 6
|
||||
anim = @animate for i=1:n
|
||||
IVT_graph(i)
|
||||
end
|
||||
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 1)
|
||||
|
||||
|
||||
caption = L"""
|
||||
|
||||
Illustration of intermediate value theorem. The theorem implies that any randomly chosen $y$
|
||||
value between $f(a)$ and $f(b)$ will have at least one $x$ in $[a,b]$
|
||||
with $f(x)=y$.
|
||||
|
||||
"""
|
||||
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
=#
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly()
|
||||
@@ -145,7 +104,7 @@ Illustration of the intermediate value theorem. The theorem implies that any ran
|
||||
|
||||
:::
|
||||
|
||||
In the early years of calculus, the intermediate value theorem was intricately connected with the definition of continuity, now it is a consequence.
|
||||
In the early years of calculus, the intermediate value theorem was intricately connected with the definition of continuity, now it is an important consequence.
|
||||
|
||||
|
||||
The basic proof starts with a set of points in $[a,b]$: $C = \{x \text{ in } [a,b] \text{ with } f(x) \leq y\}$. The set is not empty (as $a$ is in $C$) so it *must* have a largest value, call it $c$ (this might seem obvious, but it requires the completeness property of the real numbers). By continuity of $f$, it can be shown that $\lim_{x \rightarrow c-} f(x) = f(c) \leq y$ and $\lim_{y \rightarrow c+}f(x) =f(c) \geq y$, which forces $f(c) = y$.
|
||||
@@ -157,18 +116,6 @@ The basic proof starts with a set of points in $[a,b]$: $C = \{x \text{ in } [a,
|
||||
Suppose we have a continuous function $f(x)$ on $[a,b]$ with $f(a) < 0$ and $f(b) > 0$. Then as $f(a) < 0 < f(b)$, the intermediate value theorem guarantees the existence of a $c$ in $[a,b]$ with $f(c) = 0$. This was a special case of the intermediate value theorem proved by Bolzano first. Such $c$ are called *zeros* of the function $f$.
|
||||
|
||||
|
||||
We use this fact when building a "sign chart" of a polynomial function. Between any two consecutive real zeros the polynomial can not change sign. (Why?) So a "test point" can be used to determine the sign of the function over an entire interval.
|
||||
|
||||
The `sign_chart` function from `CalculusWithJulia` uses this to indicate where an *assumed* continuous function changes sign:
|
||||
|
||||
```{julia}
|
||||
f(x) = sin(x + x^2) + x/2
|
||||
sign_chart(f, -3, 3)
|
||||
```
|
||||
|
||||
|
||||
The intermediate value theorem can find the sign of the function *between* adjacent zeros, but how are the zeros identified?
|
||||
|
||||
Here, we use the Bolzano theorem to give an algorithm - the *bisection method* - to locate a value $c$ in $[a,b]$ with $f(c) = 0$ under the assumptions:
|
||||
|
||||
* $f$ is continuous on $[a,b]$
|
||||
@@ -178,7 +125,7 @@ Here, we use the Bolzano theorem to give an algorithm - the *bisection method* -
|
||||
::: {.callout-note}
|
||||
#### Between
|
||||
|
||||
The bisection method is used to find a zero, $c$, of $f(x)$ *between* two values, $a$ and $b$. The method is guaranteed to work under assumptions, the most important being the continuous function having different signs at $a$ and $b$.
|
||||
The bisection method is used to find a zero, $c$, of $f(x)$ *between* two values, $a$ and $b$. The method is guaranteed to work under the assumption of a continuous function having different signs at $a$ and $b$.
|
||||
:::
|
||||
|
||||
|
||||
@@ -305,7 +252,7 @@ sin(c)
|
||||
(Even `1pi` itself is not a "zero" due to floating point issues.)
|
||||
|
||||
|
||||
### The `find_zero` function.
|
||||
### The `find_zero` function to solve `f(x) = 0`
|
||||
|
||||
|
||||
The `Roots` package has a function `find_zero` that implements the bisection method when called as `find_zero(f, (a,b))` where $[a,b]$ is a bracket. Its use is similar to `simple_bisection` above. This package is loaded when `CalculusWithJulia` is. We illlustrate the usage of `find_zero` in the following:
|
||||
@@ -315,8 +262,8 @@ The `Roots` package has a function `find_zero` that implements the bisection met
|
||||
xstar = find_zero(sin, (3, 4))
|
||||
```
|
||||
|
||||
:::{.callout-warning}
|
||||
## Warning
|
||||
:::{.callout-note}
|
||||
## Action template
|
||||
Notice, the call `find_zero(sin, (3, 4))` again fits the template `action(function, args...)` that we see repeatedly. The `find_zero` function can also be called through `fzero`. The use of `(3, 4)` to specify the interval is not necessary. For example `[3,4]` would work equally as well. (Anything where `extrema` is defined works.)
|
||||
|
||||
:::
|
||||
@@ -396,6 +343,10 @@ It appears (and a plot over $[0,1]$ verifies) that there is one zero between $-2
|
||||
find_zero(x^3 - x + 1, (-2, -1))
|
||||
```
|
||||
|
||||
#### The `find_zero` function to solve `f(x) = c`
|
||||
|
||||
Solving `f(x) = c` is related to solving `h(x) = 0`. The key is to make a new function using the difference of the two sides: `h(x) = f(x) - c`.
|
||||
|
||||
##### Example
|
||||
|
||||
Solve for a value of $x$ where `erfc(x)` is equal to `0.5`.
|
||||
@@ -415,6 +366,40 @@ find_zero(h, (-Inf, Inf)) # as wide as possible in this case
|
||||
```
|
||||
|
||||
|
||||
##### Example: Inverse functions
|
||||
|
||||
If $f(x)$ is *monotonic* and *continuous* over an interval $[a,b]$ then it has an *inverse function*. That is for any $y$ between $f(a)$ and $f(b)$ we can find an $x$ satisfying $y = f(x)$ with $a \leq x \leq b$. This is due, of course, to both the intermediate value theorem (which guarantees an $x$) and monotonicity (which guarantees just one $x$).
|
||||
|
||||
To see how we can *numerically* find an inverse function using `find_zero`, we have this function:
|
||||
|
||||
```{julia}
|
||||
function inverse_function(f, a, b, args...; kwargs...)
|
||||
fa, fb = f(a), f(b)
|
||||
m, M = fa < fb ? (fa, fb) : (fb, fa)
|
||||
y -> begin
|
||||
@assert m ≤ y ≤ M
|
||||
find_zero(x ->f(x) - y, (a,b), args...; kwargs...)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
The check on `fa < fb` is due to the possibility that $f$ is increasing (in which case `fa < fb`) or decreasing (in which case `fa > fb`).
|
||||
|
||||
To see this used, we consider the monotonic function $f(x) = x - \sin(x)$ over $[0, 5\pi]$. To graph, we have:
|
||||
|
||||
```{julia}
|
||||
f(x) = x - sin(x)
|
||||
a, b = 0, 5pi
|
||||
plot(inverse_function(f, a, b), f(a), f(b); aspect_ratio=:equal)
|
||||
```
|
||||
|
||||
(We plot over the range $[f(a), f(b)]$ here, as we can guess $f(x)$ is *increasing*.)
|
||||
|
||||
|
||||
#### The `find_zero` function to solve `f(x) = g(x)`
|
||||
|
||||
Solving `f(x) = g(x)` is related to solving `h(x) = 0`. The key is to make a new function using the difference of the two sides: `h(x) = f(x) - g(x)`.
|
||||
|
||||
|
||||
##### Example
|
||||
|
||||
@@ -455,36 +440,6 @@ find_zero(cos(x) ~ x, (0, 2))
|
||||
|
||||
[](https://www.gallery.ca/whats-on/touring-exhibitions-and-loans/around-the-world/canada-pavilion-at-the-venice-biennale/kapwani-kiwanga-trinket){width=40%}
|
||||
|
||||
##### Example: Inverse functions
|
||||
|
||||
If $f(x)$ is *monotonic* and *continuous* over an interval $[a,b]$ then it has an *inverse function*. That is for any $y$ between $f(a)$ and $f(b)$ we can find an $x$ satisfying $y = f(x)$ with $a \leq x \leq b$. This is due, of course, to both the intermediate value theorem (which guarantees an $x$) and monotonicity (which guarantees just one $x$).
|
||||
|
||||
To see how we can *numerically* find an inverse function using `find_zero`, we have this function:
|
||||
|
||||
```{julia}
|
||||
function inverse_function(f, a, b, args...; kwargs...)
|
||||
fa, fb = f(a), f(b)
|
||||
m, M = fa < fb ? (fa, fb) : (fb, fa)
|
||||
y -> begin
|
||||
@assert m ≤ y ≤ M
|
||||
find_zero(x ->f(x) - y, (a,b), args...; kwargs...)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
The check on `fa < fb` is due to the possibility that $f$ is increasing (in which case `fa < fb`) or decreasing (in which case `fa > fb`).
|
||||
|
||||
To see this used, we consider the monotonic function $f(x) = x - \sin(x)$ over $[0, 5\pi]$. To graph, we have:
|
||||
|
||||
```{julia}
|
||||
f(x) = x - sin(x)
|
||||
a, b = 0, 5pi
|
||||
plot(inverse_function(f, a, b), f(a), f(b); aspect_ratio=:equal)
|
||||
```
|
||||
|
||||
(We plot over the range $[f(a), f(b)]$ here, as we can guess $f(x)$ is *increasing*.)
|
||||
|
||||
|
||||
##### Example
|
||||
|
||||
|
||||
@@ -679,7 +634,7 @@ Geometry will tell us that $\cos(x) - x/p$ for *one* $x$ in $[0, \pi/2]$ wheneve
|
||||
#| hold: true
|
||||
f(x, p=1) = cos(x) - x/p
|
||||
I = (0, pi/2)
|
||||
find_zero(f, I), find_zero(f, I, p=2)
|
||||
find_zero(f, I), find_zero(f, I; p=2)
|
||||
```
|
||||
|
||||
The second number is the solution when `p=2`.
|
||||
@@ -752,7 +707,7 @@ f.(zs)
|
||||
The `find_zero` function in the `Roots` package is an interface to one of several methods. For now we focus on the *bracketing* methods, later we will see others. Bracketing methods, among others, include `Roots.Bisection()`, the basic bisection method though with a different sense of "middle" than $(a+b)/2$ and used by default above; `Roots.A42()`, which will typically converge much faster than simple bisection; `Roots.Brent()` for the classic method of Brent, and `FalsePosition()` for a family of *regula falsi* methods. These can all be used by specifying the method in a call to `find_zero`.
|
||||
|
||||
|
||||
Alternatively, `Roots` implements the `CommonSolve` interface popularized by its use in the `DifferentialEquations.jl` ecosystem, a wildly successful area for `Julia`. The basic setup involves two steps: setup a "problem;" solve the problem.
|
||||
Alternatively, `Roots` implements the `CommonSolve` interface popularized by its use in the `DifferentialEquations.jl` ecosystem, a wildly successful area for `Julia`. The basic setup involves two steps: setup a "problem"; solve the problem.
|
||||
|
||||
|
||||
To set up a problem we call `ZeroProblem` with the function and an initial interval, as in:
|
||||
@@ -822,6 +777,74 @@ nothing
|
||||
[](https://hardrock100.com){width=50%}
|
||||
|
||||
|
||||
This figure shows the two concepts as well.
|
||||
|
||||
::: {#fig-absolute-relative}
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plt = let
|
||||
|
||||
gr()
|
||||
empty_style = (xaxis=([], false),
|
||||
yaxis=([], false),
|
||||
framestyle=:origin,
|
||||
legend=false)
|
||||
axis_style = (arrow=true, side=:head, line=(:gray, 1))
|
||||
|
||||
|
||||
p(x) = (x-1)*(x-2)*(x-3)*(x-4) + x/2 + 2
|
||||
a, b = 0.25, 4.5
|
||||
z₁, z₂, z₃ = zs = find_zeros(x -> ForwardDiff.derivative(p,x), (a, b))
|
||||
|
||||
a′ = -0.0
|
||||
plot(; empty_style...)
|
||||
plot!(p, a, b; line=(:black, 2))
|
||||
plot!([a′,b+0.25], [0,0]; axis_style...)
|
||||
plot!([a′,a′] .+ .1, [-1, p(0)]; axis_style...)
|
||||
|
||||
δ = .5
|
||||
ts = range(0, 2pi, 100)
|
||||
|
||||
for z in zs
|
||||
plot!([z-δ,z+δ],[p(z),p(z)]; line=(:black, 1))
|
||||
C = Shape(z .+ 0.03 * sin.(ts), p(z) .+ 0.3 * cos.(ts))
|
||||
plot!(C; fill=(:periwinkle, 1), line=(:black, 1))
|
||||
end
|
||||
for z in (a,b)
|
||||
C = Shape(z .+ 0.03 * sin.(ts), p(z) .+ 0.3 * cos.(ts))
|
||||
plot!(C; fill=(:black, 1), line=(:black, 1))
|
||||
end
|
||||
|
||||
κ = 0.33
|
||||
annotate!([
|
||||
(a, 0, text(L"a", :top)),
|
||||
(b,0, text(L"b", :top)),
|
||||
(a + κ/5, p(a), text(raw"absolute max", 10, :left)),
|
||||
(z₁, p(z₁)-κ, text(raw"absolute min", 10, :top)),
|
||||
(z₂, p(z₂) + κ, text(raw"relative max", 10, :bottom)),
|
||||
(z₃, p(z₃) - κ, text(raw"relative min", 10, :top)),
|
||||
(b, p(b) + κ, text(raw"endpoint", 10, :bottom))
|
||||
|
||||
])
|
||||
|
||||
current()
|
||||
end
|
||||
plt
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly()
|
||||
nothing
|
||||
```
|
||||
|
||||
Figure illustrating absolute and relative minima for a function $f(x)$ over $I=[a,b]$. The leftmost point has a $y$ value, $f(a)$, which is an absolute maximum of $f(x)$ over $I$. The three points highlighted between $a$ and $b$ are all relative extrema. The first one is *also* the absolute minimum over $I$. The endpoint is not considered a relative maximum for technical reasons --- there is no interval around $b$, it being on the boundary of $I$.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
The extreme value theorem discusses an assumption that ensures absolute maximum and absolute minimum values exist.
|
||||
|
||||
::: {.callout-note icon=false}
|
||||
@@ -849,7 +872,7 @@ The function $f(x) = \sqrt{1-x^2}$ is continuous on the interval $[-1,1]$ (in th
|
||||
##### Example
|
||||
|
||||
|
||||
The function $f(x) = x \cdot e^{-x}$ on the closed interval $[0, 5]$ is continuous. Hence it has an absolute maximum, which a graph shows to be $0.4$. It has an absolute minimum, clearly the value $0$ occurring at the endpoint.
|
||||
The function $f(x) = x \cdot e^{-x}$ on the closed interval $[0, 5]$ is continuous. Hence it has an absolute maximum, which a graph shows to be about $0.4$ and occurring near $x=1$. It has an absolute minimum, clearly the value $0$ occurring at the endpoint.
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -886,7 +909,7 @@ A New York Times [article](https://www.nytimes.com/2016/07/30/world/europe/norwa
|
||||
## Continuity and closed and open sets
|
||||
|
||||
|
||||
We comment on two implications of continuity that can be generalized to more general settings.
|
||||
We comment on two implications of continuity that can be generalized.
|
||||
|
||||
|
||||
The two intervals $(a,b)$ and $[a,b]$ differ as the latter includes the endpoints. The extreme value theorem shows this distinction can make a big difference in what can be said regarding *images* of such interval.
|
||||
@@ -1212,7 +1235,7 @@ radioq(choices, answ, keep_order=true)
|
||||
###### Question
|
||||
|
||||
|
||||
The extreme value theorem has two assumptions: a continuous function and a *closed* interval. Which of the following examples fails to satisfy the consequence of the extreme value theorem because the function is not continuous?
|
||||
The extreme value theorem has two assumptions: a continuous function and a *closed* interval. Which of the following examples fails to satisfy the consequence of the extreme value theorem because the function is defined on $I$ but is not continuous on $I$?
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -1227,6 +1250,170 @@ answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
The extreme value theorem is true when $f$ is a continuous function on an interval $I$ *and* $I=[a,b]$ is a *closed* interval. Which of these illustrates why it doesn't apply as $f$ is not continuous on $I$ but is defined on $I$?
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
|
||||
let
|
||||
gr()
|
||||
empty_style = (xaxis=([], false),
|
||||
yaxis=([], false),
|
||||
framestyle=:origin,
|
||||
legend=false)
|
||||
axis_style = (arrow=true, side=:head, line=(:gray, 1))
|
||||
|
||||
ts = range(0, 2pi, 100)
|
||||
|
||||
# defined on I; not continuous on I
|
||||
p1 = plot(;empty_style..., aspect_ratio=:equal)
|
||||
title!(p1, "(a)")
|
||||
plot!(p1, x -> 1 - abs(2x), -1, 1, color=:black)
|
||||
plot!(p1, zero; line=(:black, 1), arrow=true, side=:head)
|
||||
C = Shape(0.03 .* sin.(ts), 1 .+ 0.03 .* cos.(ts))
|
||||
plot!(p1, C, fill=(:white, 1), line=(:black,1))
|
||||
C = Shape(0.03 .* sin.(ts), - 0.25 .+ 0.03 .* cos.(ts))
|
||||
plot!(p1, C, fill=(:black,1))
|
||||
annotate!(p1, [
|
||||
(-1,0,text(L"a", :top)),
|
||||
(1,0,text(L"b", :top))
|
||||
])
|
||||
|
||||
# not defined on I
|
||||
p2 = plot(;empty_style...)
|
||||
title!(p2, "(b)")
|
||||
plot!(p2, x -> 1/(1-x), 0, .95, color=:black)
|
||||
plot!(p2, x-> -1/(1-x), 1.05, 2, color=:black)
|
||||
plot!(p2, zero; axis_style...)
|
||||
annotate!(p2,[
|
||||
(0,0,text(L"a", :top)),
|
||||
(2, 0, text(L"b", :top))
|
||||
])
|
||||
|
||||
# not continuous on I
|
||||
p3 = plot(;empty_style...)
|
||||
title!(p3, "(c)")
|
||||
plot!(p3, x -> 1/(1-x), 0, .95, color=:black)
|
||||
ylims!((-0.25, 1/(1 - 0.96)))
|
||||
plot!(p3, [0,1.05],[0,0]; axis_style...)
|
||||
vline!(p3, [1]; line=(:black, 1, :dash))
|
||||
annotate!(p3,[
|
||||
(0,0,text(L"a", :top)),
|
||||
(1, 0, text(L"b", :top))
|
||||
])
|
||||
|
||||
# continuous
|
||||
p4 = plot(;empty_style...)
|
||||
title!(p4, "(d)")
|
||||
f(x) = x^x
|
||||
a, b = 0, 2
|
||||
plot!(p4, f, a, b; line=(:black,1))
|
||||
ylims!(p4, (-.25, f(b)))
|
||||
plot!(p4, [a-.1, b+.1], [0,0]; axis_style...)
|
||||
scatter!([0,2],[ f(0),f(2)]; marker=(:circle,:black))
|
||||
annotate!([
|
||||
(a, 0, text(L"a", :top)),
|
||||
(b, 0, text(L"b", :top))
|
||||
|
||||
])
|
||||
|
||||
l = @layout[a b; c d]
|
||||
p = plot(p1, p2, p3, p4, layout=l)
|
||||
imgfile = tempname() * ".png"
|
||||
savefig(p, imgfile)
|
||||
hotspotq(imgfile, (0,1/2), (1/2,1))
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
|
||||
The extreme value theorem is true when $f$ is a continuous function on an interval $I$ and $I=[a,b]$ is a *closed* interval. Which of these illustrates when the theorem's assumptions are true?
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
## come on; save this figure...
|
||||
let
|
||||
gr()
|
||||
empty_style = (xaxis=([], false),
|
||||
yaxis=([], false),
|
||||
framestyle=:origin,
|
||||
legend=false)
|
||||
axis_style = (arrow=true, side=:head, line=(:gray, 1))
|
||||
|
||||
ts = range(0, 2pi, 100)
|
||||
|
||||
# defined on I; not continuous on I
|
||||
p1 = plot(;empty_style..., aspect_ratio=:equal)
|
||||
title!(p1, "(a)")
|
||||
plot!(p1, x -> 1 - abs(2x), -1, 1, color=:black)
|
||||
plot!(p1, zero; line=(:black, 1), arrow=true, side=:head)
|
||||
C = Shape(0.03 .* sin.(ts), 1 .+ 0.03 .* cos.(ts))
|
||||
plot!(p1, C, fill=(:white, 1), line=(:black,1))
|
||||
C = Shape(0.03 .* sin.(ts), - 0.25 .+ 0.03 .* cos.(ts))
|
||||
plot!(p1, C, fill=(:black,1))
|
||||
annotate!(p1, [
|
||||
(-1,0,text(L"a", :top)),
|
||||
(1,0,text(L"b", :top))
|
||||
])
|
||||
|
||||
# not defined on I
|
||||
p2 = plot(;empty_style...)
|
||||
title!(p2, "(b)")
|
||||
plot!(p2, x -> 1/(1-x), 0, .95, color=:black)
|
||||
plot!(p2, x-> -1/(1-x), 1.05, 2, color=:black)
|
||||
plot!(p2, zero; axis_style...)
|
||||
annotate!(p2,[
|
||||
(0,0,text(L"a", :top)),
|
||||
(2, 0, text(L"b", :top))
|
||||
])
|
||||
|
||||
# not continuous on I
|
||||
p3 = plot(;empty_style...)
|
||||
title!(p3, "(c)")
|
||||
plot!(p3, x -> 1/(1-x), 0, .95, color=:black)
|
||||
ylims!((-0.1, 1/(1 - 0.96)))
|
||||
plot!(p3, [0,1.05],[0,0]; axis_style...)
|
||||
vline!(p3, [1]; line=(:black, 1, :dash))
|
||||
annotate!(p3,[
|
||||
(0,0,text(L"a", :top)),
|
||||
(1, 0, text(L"b", :top))
|
||||
])
|
||||
|
||||
# continuous
|
||||
p4 = plot(;empty_style...)
|
||||
title!(p4, "(d)")
|
||||
f(x) = x^x
|
||||
a, b = 0, 2
|
||||
ylims!(p4, (-.25, f(b)))
|
||||
plot!(p4, f, a, b; line=(:black,1))
|
||||
plot!(p4, [a-.1, b+.1], [0,0]; axis_style...)
|
||||
scatter!([0,2],[ f(0),f(2)]; marker=(:circle,:black))
|
||||
annotate!([
|
||||
(a, 0, text(L"a", :top)),
|
||||
(b, 0, text(L"b", :top))
|
||||
|
||||
])
|
||||
|
||||
l = @layout[a b; c d]
|
||||
p = plot(p1, p2, p3, p4, layout=l)
|
||||
imgfile = tempname() * ".png"
|
||||
savefig(p, imgfile)
|
||||
hotspotq(imgfile, (1/2,1), (0,1/2))
|
||||
end
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly();
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
|
||||
@@ -1318,28 +1505,3 @@ The zeros of the equation $\cos(x) \cdot \cosh(x) = 1$ are related to vibrations
|
||||
val = maximum(find_zeros(x -> cos(x) * cosh(x) - 1, (0, 6pi)))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
|
||||
A parametric equation is specified by a parameterization $(f(t), g(t)), a \leq t \leq b$. The parameterization will be continuous if and only if each function is continuous.
|
||||
|
||||
|
||||
Suppose $k_x$ and $k_y$ are positive integers and $a, b$ are positive numbers, will the [Lissajous](https://en.wikipedia.org/wiki/Parametric_equation#Lissajous_Curve) curve given by $(a\cos(k_x t), b\sin(k_y t))$ be continuous?
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
yesnoq(true)
|
||||
```
|
||||
|
||||
Here is a sample graph for $a=1, b=2, k_x=3, k_y=4$:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
a,b = 1, 2
|
||||
k_x, k_y = 3, 4
|
||||
plot(t -> a * cos(k_x *t), t-> b * sin(k_y * t), 0, 4pi)
|
||||
```
|
||||
|
||||
@@ -36,27 +36,38 @@ colors = [:black, :blue, :orange, :red, :green, :orange, :purple]
|
||||
## Area of parabola
|
||||
function make_triangle_graph(n)
|
||||
title = "Area of parabolic cup ..."
|
||||
n==1 && (title = "\${Area = }1/2\$")
|
||||
n==2 && (title = "\${Area = previous }+ 1/8\$")
|
||||
n==3 && (title = "\${Area = previous }+ 2\\cdot(1/8)^2\$")
|
||||
n==4 && (title = "\${Area = previous }+ 4\\cdot(1/8)^3\$")
|
||||
n==5 && (title = "\${Area = previous }+ 8\\cdot(1/8)^4\$")
|
||||
n==6 && (title = "\${Area = previous }+ 16\\cdot(1/8)^5\$")
|
||||
n==7 && (title = "\${Area = previous }+ 32\\cdot(1/8)^6\$")
|
||||
n==1 && (title = L"Area $= 1/2$")
|
||||
n==2 && (title = L"Area $=$ previous $+\; \frac{1}{8}$")
|
||||
n==3 && (title = L"Area $=$ previous $+\; 2\cdot\frac{1}{8^2}$")
|
||||
n==4 && (title = L"Area $=$ previous $+\; 4\cdot\frac{1}{8^3}$")
|
||||
n==5 && (title = L"Area $=$ previous $+\; 8\cdot\frac{1}{8^4}$")
|
||||
n==6 && (title = L"Area $=$ previous $+\; 16\cdot\frac{1}{8^5}$")
|
||||
n==7 && (title = L"Area $=$ previous $+\; 32\cdot\frac{1}{8^6}$")
|
||||
|
||||
|
||||
|
||||
plt = plot(f, 0, 1, legend=false, size = fig_size, linewidth=2)
|
||||
annotate!(plt, [(0.05, 0.9, text(title,:left))]) # if in title, it grows funny with gr
|
||||
n >= 1 && plot!(plt, [1,0,0,1, 0], [1,1,0,1,1], color=colors[1], linetype=:polygon, fill=colors[1], alpha=.2)
|
||||
n == 1 && plot!(plt, [1,0,0,1, 0], [1,1,0,1,1], color=colors[1], linewidth=2)
|
||||
plt = plot(f, 0, 1;
|
||||
legend=false,
|
||||
size = fig_size,
|
||||
linewidth=2)
|
||||
annotate!(plt, [
|
||||
(0.05, 0.9, text(title,:left))
|
||||
]) # if in title, it grows funny with gr
|
||||
n >= 1 && plot!(plt, [1,0,0,1, 0], [1,1,0,1,1];
|
||||
color=colors[1], linetype=:polygon,
|
||||
fill=colors[1], alpha=.2)
|
||||
n == 1 && plot!(plt, [1,0,0,1, 0], [1,1,0,1,1];
|
||||
color=colors[1], linewidth=2)
|
||||
for k in 2:n
|
||||
xs = range(0,stop=1, length=1+2^(k-1))
|
||||
ys = map(f, xs)
|
||||
k < n && plot!(plt, xs, ys, linetype=:polygon, fill=:black, alpha=.2)
|
||||
xs = range(0, stop=1, length=1+2^(k-1))
|
||||
ys = f.(xs)
|
||||
k < n && plot!(plt, xs, ys;
|
||||
linetype=:polygon, fill=:black, alpha=.2)
|
||||
if k == n
|
||||
plot!(plt, xs, ys, color=colors[k], linetype=:polygon, fill=:black, alpha=.2)
|
||||
plot!(plt, xs, ys, color=:black, linewidth=2)
|
||||
plot!(plt, xs, ys;
|
||||
color=colors[k], linetype=:polygon, fill=:black, alpha=.2)
|
||||
plot!(plt, xs, ys;
|
||||
color=:black, linewidth=2)
|
||||
end
|
||||
end
|
||||
plt
|
||||
@@ -1041,18 +1052,34 @@ $$
|
||||
Why? We can express the function $e^{\csc(x)}/e^{\cot(x)}$ as the above function plus the polynomial $1 + x/2 + x^2/8$. The above is then the sum of two functions whose limits exist and are finite, hence, we can conclude that $M = 0 + 1$.
|
||||
|
||||
|
||||
### The [squeeze](http://en.wikipedia.org/wiki/Squeeze_theorem) theorem
|
||||
### The squeeze theorem
|
||||
|
||||
Sometimes limits can be found by bounding more complicated functions by easier functions.
|
||||
|
||||
::: {.callout-note icon=false}
|
||||
## The [squeeze theorem](http://en.wikipedia.org/wiki/Squeeze_theorem)
|
||||
|
||||
Fix $c$ in $I=(a,b)$. Suppose for all $x$ in $I$, except possibly $c$, there are two functions $l$ and $u$, satisfying:
|
||||
|
||||
|
||||
We note one more limit law. Suppose we wish to compute $\lim_{x \rightarrow c}f(x)$ and we have two other functions, $l$ and $u$, satisfying:
|
||||
* $l(x) \leq f(x) \leq u(x)$.
|
||||
|
||||
* These limits exist and are equal:
|
||||
|
||||
$$
|
||||
L = \lim_{x \rightarrow c} l(x) = \lim_{x \rightarrow c} u(x).
|
||||
$$
|
||||
|
||||
|
||||
* for all $x$ near $c$ (possibly not including $c$) $l(x) \leq f(x) \leq u(x)$.
|
||||
* These limits exist and are equal: $L = \lim_{x \rightarrow c} l(x) = \lim_{x \rightarrow c} u(x)$.
|
||||
Then
|
||||
|
||||
$$
|
||||
\lim_{x\rightarrow c} f(x) = L.
|
||||
$$
|
||||
|
||||
Then the limit of $f$ must also be $L$.
|
||||
:::
|
||||
|
||||
The figure shows a usage of the squeeze theorem to show $\sin(x)/x \rightarrow 1$ as $\cos(x) \leq \sin(x)x \leq 1$ for $x$ close to $0$.
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
@@ -1088,8 +1115,71 @@ ImageFile(imgfile, caption)
|
||||
The formal definition of a limit involves clarifying what it means for $f(x)$ to be "close to $L$" when $x$ is "close to $c$". These are quantified by the inequalities $0 < \lvert x-c\rvert < \delta$ and the $\lvert f(x) - L\rvert < \epsilon$. The second does not have the restriction that it is greater than $0$, as indeed $f(x)$ can equal $L$. The order is important: it says for any idea of close for $f(x)$ to $L$, an idea of close must be found for $x$ to $c$.
|
||||
|
||||
|
||||
|
||||
The key is identifying a value for $\delta$ for a given value of $\epsilon$.
|
||||
|
||||
::: {#fig-limit-e-d}
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plt = let
|
||||
gr()
|
||||
f(x) = (x+1)^2 -1
|
||||
a, b = -1/4, 2
|
||||
c = 1
|
||||
L = f(c)
|
||||
δ = 0.2
|
||||
ϵ = 3sqrt(δ)
|
||||
|
||||
plot(; empty_style...)#, aspect_ratio=:equal)
|
||||
plot!(f, a, b; line=(:black, 2))
|
||||
plot!([a,b],[0,0]; axis_style...)
|
||||
plot!([0,0], [f(a), f(2)]; axis_style...)
|
||||
|
||||
plot!([c, c, 0], [0, f(c), f(c)]; line=(:black, 1, :dash))
|
||||
plot!([c-δ, c-δ, 0], [0, f(c-δ), f(c-δ)]; line=(:black, 1, :dashdot))
|
||||
plot!([c+δ, c+δ, 0], [0, f(c+δ), f(c+δ)]; line=(:black, 1, :dashdot))
|
||||
|
||||
S = Shape([0,b,b,0],[L-ϵ,L-ϵ,L+ϵ,L+ϵ])
|
||||
plot!(S; fill=(:lightblue, 0.25), line=(nothing,))
|
||||
|
||||
domain_color=:red
|
||||
range_color=:blue
|
||||
|
||||
|
||||
S = Shape([c-δ, c+δ, c+δ, c-δ], 0.05*[-1,-1,1,1])
|
||||
plot!(S, fill=(domain_color,0.4), line=nothing)
|
||||
m,M = f(c-δ), f(c+δ)
|
||||
T = Shape(0.015 * [-1,1,1,-1], [m,m,M,M])
|
||||
plot!(T, fill=(range_color, 0.4), line=nothing)
|
||||
|
||||
|
||||
C = Plots.scale(Shape(:circle), 0.02, 0.1)
|
||||
plot!(Plots.translate(C, c, L), fill=(:white,1,0), line=(:black, 1))
|
||||
plot!(Plots.translate(C, c, 0), fill=(:white,1,0), line=(domain_color, 1))
|
||||
plot!(Plots.translate(C, 0, L), fill=(:white,1,0), line=(range_color, 1))
|
||||
|
||||
annotate!([
|
||||
(c, 0, text(L"c", :top)),
|
||||
(c-δ, 0, text(L"c - \delta", 10, :top)),
|
||||
(c+δ, 0, text(L"c + \delta", 10, :top)),
|
||||
(0, L, text(L"L", :right)),
|
||||
(0, L+ϵ, text(L"L + \epsilon", 10, :right)),
|
||||
(0, L-ϵ, text(L"L - \epsilon", 10, :right)),
|
||||
|
||||
])
|
||||
|
||||
end
|
||||
plt
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly()
|
||||
nothing
|
||||
```
|
||||
|
||||
Figure illustrating requirements of $\epsilon-\delta$ definition of the limit. The image (shaded red on $y$ axis) of the $x$ within $\delta$ of $c$ (except for $c$ and shaded blue on the $x$ axis) must stay within the bounds of $L-\epsilon$ and $L+ \epsilon$, where $\delta$ may be chosen based on $\epsilon$ but needs to be chosen for every positive $\epsilon$, not just a fixed one as in this figure.
|
||||
:::
|
||||
|
||||
A simple case is the linear case. Consider the function $f(x) = 3x + 2$. Verify that the limit at $c=1$ is $5$.
|
||||
|
||||
@@ -1117,64 +1207,78 @@ These lines produce a random $\epsilon$, the resulting $\delta$, and then verify
|
||||
(The random numbers are technically in $[0,1)$, so in theory `epsilon` could be `0`. So the above approach would be more solid if some guard, such as `epsilon = max(eps(), rand())`, was used. As the formal definition is the domain of paper-and-pencil, we don't fuss.)
|
||||
|
||||
|
||||
In this case, $\delta$ is easy to guess, as the function is linear and has slope $3$. This basically says the $y$ scale is 3 times the $x$ scale. For non-linear functions, finding $\delta$ for a given $\epsilon$ can be a challenge. For the function $f(x) = x^3$, illustrated below, a value of $\delta=\epsilon^{1/3}$ is used for $c=0$:
|
||||
In this case, $\delta$ is easy to guess, as the function is linear and has slope $3$. This basically says the $y$ scale is 3 times the $x$ scale. For non-linear functions, finding $\delta$ for a given $\epsilon$ can be more of a challenge.
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
#| cache: true
|
||||
## {{{ limit_e_d }}}
|
||||
gr()
|
||||
function make_limit_e_d(n)
|
||||
f(x) = x^3
|
||||
##### Example
|
||||
|
||||
xs = range(-.9, stop=.9, length=50)
|
||||
ys = map(f, xs)
|
||||
We show using the definition that for any fixed $a$ and $n$:
|
||||
$$
|
||||
\lim_{x \rightarrow a} x^n = a^n.
|
||||
$$
|
||||
|
||||
This proof uses a bound based on properties of the absolute value.
|
||||
|
||||
|
||||
plt = plot(f, -.9, .9, legend=false, size=fig_size)
|
||||
if n == 0
|
||||
nothing
|
||||
else
|
||||
k = div(n+1,2)
|
||||
epsilon = 1/2^k
|
||||
delta = cbrt(epsilon)
|
||||
if isodd(n)
|
||||
plot!(plt, xs, 0*xs .+ epsilon, color=:orange)
|
||||
plot!(plt, xs, 0*xs .- epsilon, color=:orange)
|
||||
else
|
||||
plot!(delta * [-1, 1], epsilon * [ 1, 1], color=:orange)
|
||||
plot!(delta * [ 1, -1], epsilon * [-1,-1], color=:orange)
|
||||
plot!(delta * [-1, -1], epsilon * [-1, 1], color=:red)
|
||||
plot!(delta * [ 1, 1], epsilon * [-1, 1], color=:red)
|
||||
end
|
||||
end
|
||||
plt
|
||||
end
|
||||
We look at $f(x) - L = x^n - a^n = (x-a)(x^{n-1} + x^{n-2}a + \cdots + x^1a^{n-1} + a^n)$.
|
||||
|
||||
Taking absolute values gives an inequality by the triangle inequality:
|
||||
|
||||
n = 11
|
||||
anim = @animate for i=1:n
|
||||
make_limit_e_d(i-1)
|
||||
end
|
||||
$$
|
||||
\lvert x^n - a^n\rvert \leq \lvert x-a\rvert\cdot
|
||||
\left(
|
||||
\lvert x^{n-1}\rvert +
|
||||
\lvert x^{n-2}\rvert\lvert a\rvert +
|
||||
\cdots +
|
||||
\lvert x^1\rvert\lvert a^{n-1}\rvert +
|
||||
\lvert a^n\rvert
|
||||
\right).
|
||||
$$
|
||||
|
||||
imgfile = tempname() * ".gif"
|
||||
gif(anim, imgfile, fps = 1)
|
||||
Now, for a given $\epsilon>0$ we seek a $\delta>0$ satisfying the properties of the limit definition for $f(x) = x^n$ and $L=a^n$. For now, assume $\delta < 1$. Then we can assume $\lvert x-a\rvert < \delta$ and
|
||||
|
||||
$$
|
||||
\lvert x\rvert = \lvert x - a + a\rvert \leq \lvert x-a\rvert + \lvert a\rvert < 1 + \lvert a\rvert
|
||||
$$
|
||||
|
||||
caption = L"""
|
||||
This says then
|
||||
|
||||
Demonstration of $\epsilon$-$\delta$ proof of $\lim_{x \rightarrow 0}
|
||||
x^3 = 0$. For any $\epsilon>0$ (the orange lines) there exists a
|
||||
$\delta>0$ (the red lines of the box) for which the function $f(x)$
|
||||
does not leave the top or bottom of the box (except possibly at the
|
||||
edges). In this example $\delta^3=\epsilon$.
|
||||
$$
|
||||
\begin{align*}
|
||||
\lvert x^n - a^n\rvert
|
||||
&\leq
|
||||
\lvert x-a\rvert\cdot \left(
|
||||
\lvert x\rvert^{n-1} +
|
||||
\lvert x\rvert^{n-2}\lvert a\rvert +
|
||||
\cdots +
|
||||
\lvert x\rvert^1\lvert a^{n-1}\rvert +
|
||||
\lvert a^n\rvert
|
||||
\right)\\
|
||||
%%
|
||||
&\leq \lvert x - a\rvert
|
||||
\cdot \left(
|
||||
(\lvert a\rvert+1)^{n-1} +
|
||||
(\lvert a\rvert+1)^{n-2}\lvert a\rvert
|
||||
+ \cdots +
|
||||
(\lvert a\rvert+1)^1 \lvert a^{n-1}\rvert +
|
||||
\lvert a^n \rvert
|
||||
\right)\\
|
||||
&\leq \lvert x-a\rvert \cdot C,
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
where $C$ is just some constant not depending on $x$, just $a$ and $n$.
|
||||
|
||||
Now if $\delta < 1$ and $\delta < \epsilon/C$ and if
|
||||
$0 < \lvert x - a \rvert < \delta$ then
|
||||
|
||||
$$
|
||||
\lvert f(x) - L \rvert =
|
||||
\lvert x^n - a^n\rvert \leq \lvert x-a\rvert \cdot C \leq \delta\cdot C < \frac{\epsilon}{C} \cdot C = \epsilon.
|
||||
$$
|
||||
|
||||
With this result, the rules of limits can immediately extend this to any polynomial, $p(x),$ it follows that $\lim_{x \rightarrow c} p(x) = p(a)$. (Because $c_n x^n \rightarrow c_n a^n$ and the sum of two functions with a limit has the limit of the sums.) Based on this, we will say later that any polynomial is *continuous* for all $x$.
|
||||
|
||||
"""
|
||||
plotly()
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
## Questions
|
||||
|
||||
@@ -1290,26 +1394,26 @@ let
|
||||
title!(p1, "(a)")
|
||||
plot!(p1, x -> x^2, 0, 2, color=:black)
|
||||
plot!(p1, zero, linestyle=:dash)
|
||||
annotate!(p1,[(1,0,"a")])
|
||||
annotate!(p1,[(1,0,text(L"a",:top))])
|
||||
|
||||
p2 = plot(;axis=nothing, legend=false)
|
||||
title!(p2, "(b)")
|
||||
plot!(p2, x -> 1/(1-x), 0, .95, color=:black)
|
||||
plot!(p2, x-> -1/(1-x), 1.05, 2, color=:black)
|
||||
plot!(p2, zero, linestyle=:dash)
|
||||
annotate!(p2,[(1,0,"a")])
|
||||
annotate!(p2,[(1,0,text(L"a",:top))])
|
||||
|
||||
p3 = plot(;axis=nothing, legend=false)
|
||||
title!(p3, "(c)")
|
||||
plot!(p3, sinpi, 0, 2, color=:black)
|
||||
plot!(p3, zero, linestyle=:dash)
|
||||
annotate!(p3,[(1,0,"a")])
|
||||
annotate!(p3,[(1,0,text("a",:top))])
|
||||
|
||||
p4 = plot(;axis=nothing, legend=false)
|
||||
title!(p4, "(d)")
|
||||
plot!(p4, x -> x^x, 0, 2, color=:black)
|
||||
plot!(p4, zero, linestyle=:dash)
|
||||
annotate!(p4,[(1,0,"a")])
|
||||
annotate!(p4,[(1,0,text(L"a",:top))])
|
||||
|
||||
l = @layout[a b; c d]
|
||||
p = plot(p1, p2, p3, p4, layout=l)
|
||||
@@ -1520,8 +1624,8 @@ Take
|
||||
|
||||
$$
|
||||
f(x) = \begin{cases}
|
||||
0 & x \neq 0\\
|
||||
1 & x = 0
|
||||
0 &~ x \neq 0\\
|
||||
1 &~ x = 0
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
|
||||
@@ -32,22 +32,24 @@ Let's begin with a function that is just problematic. Consider
|
||||
|
||||
|
||||
$$
|
||||
f(x) = \sin(1/x)
|
||||
f(x) = \sin(\frac{1}{x})
|
||||
$$
|
||||
|
||||
As this is a composition of nice functions it will have a limit everywhere except possibly when $x=0$, as then $1/x$ may not have a limit. So rather than talk about where it is nice, let's consider the question of whether a limit exists at $c=0$.
|
||||
|
||||
@fig-sin-1-over-x shows the issue:
|
||||
|
||||
A graph shows the issue:
|
||||
|
||||
:::{#fig-sin-1-over-x}
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
f(x) = sin(1/x)
|
||||
plot(f, range(-1, stop=1, length=1000))
|
||||
```
|
||||
|
||||
Graph of the function $f(x) = \sin(1/x)$ near $0$. It oscillates infinitely many times around $0$.
|
||||
:::
|
||||
|
||||
The graph oscillates between $-1$ and $1$ infinitely many times on this interval - so many times, that no matter how close one zooms in, the graph on the screen will fail to capture them all. Graphically, there is no single value of $L$ that the function gets close to, as it varies between all the values in $[-1,1]$ as $x$ gets close to $0$. A simple proof that there is no limit, is to take any $\epsilon$ less than $1$, then with any $\delta > 0$, there are infinitely many $x$ values where $f(x)=1$ and infinitely many where $f(x) = -1$. That is, there is no $L$ with $|f(x) - L| < \epsilon$ when $\epsilon$ is less than $1$ for all $x$ near $0$.
|
||||
|
||||
|
||||
@@ -65,11 +67,10 @@ The following figure illustrates:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| hold: true
|
||||
f(x) = x * sin(1/x)
|
||||
plot(f, -1, 1)
|
||||
plot!(abs)
|
||||
plot!(x -> -abs(x))
|
||||
plot(f, -1, 1; label="f")
|
||||
plot!(abs; label="|.|")
|
||||
plot!(x -> -abs(x); label="-|.|")
|
||||
```
|
||||
|
||||
The [squeeze](http://en.wikipedia.org/wiki/Squeeze_theorem) theorem of calculus is the formal reason $f$ has a limit at $0$, as both the upper function, $|x|$, and the lower function, $-|x|$, have a limit of $0$ at $0$.
|
||||
@@ -181,21 +182,38 @@ Consider this funny graph:
|
||||
```{julia}
|
||||
#| hold: true
|
||||
#| echo: false
|
||||
xs = range(0,stop=1, length=50)
|
||||
|
||||
plot(x->x^2, -2, -1, legend=false)
|
||||
let
|
||||
xs = range(0,stop=1, length=50)
|
||||
plot(; legend=false, aspect_ratio=true,
|
||||
xticks = -4:4)
|
||||
plot!([(-4, -1.5),(-2,4)]; line=(:black,1))
|
||||
plot!(x->x^2, -2, -1; line=(:black,1))
|
||||
plot!(exp, -1,0)
|
||||
plot!(x -> 1-2x, 0, 1)
|
||||
plot!(sqrt, 1, 2)
|
||||
plot!(x -> 1-x, 2,3)
|
||||
S = Plots.scale(Shape(:circle), 0.05)
|
||||
|
||||
plot!(Plots.translate(S, -4, -1.5); fill=(:black,))
|
||||
plot!(Plots.translate(S, -1, (-1)^2); fill=(:white,))
|
||||
plot!(Plots.translate(S, -1, exp(-1)); fill=(:black,))
|
||||
plot!(Plots.translate(S, 1, 1 - 2(1)); fill=(:black,))
|
||||
plot!(Plots.translate(S, 1, sqrt(1)); fill=(:white,))
|
||||
plot!(Plots.translate(S, 2, sqrt(2)); fill=(:white,))
|
||||
plot!(Plots.translate(S, 2, 1 - (2)); fill=(:black,))
|
||||
plot!(Plots.translate(S, 3, 1 - (3)); fill=(:black,))
|
||||
|
||||
end
|
||||
```
|
||||
|
||||
Describe the limits at $-1$, $0$, and $1$.
|
||||
|
||||
|
||||
* At $-1$ we see a jump, there is no limit but instead a left limit of 1 and a right limit appearing to be $1/2$.
|
||||
* At $0$ we see a limit of $1$.
|
||||
* Finally, at $1$ again there is a jump, so no limit. Instead the left limit is about $-1$ and the right limit $1$.
|
||||
* At $-1$ we see a jump, there is no limit but instead a left limit of 1 and a right limit appearing to be $1/2$.
|
||||
|
||||
* At $0$ we see a limit of $1$.
|
||||
|
||||
* Finally, at $1$ again there is a jump, so no limit. Instead the left limit is about $-1$ and the right limit $1$.
|
||||
|
||||
|
||||
## Limits at infinity
|
||||
|
||||
Reference in New Issue
Block a user