initial
This commit is contained in:
10
CwJ/limits/Project.toml
Normal file
10
CwJ/limits/Project.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[deps]
|
||||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
||||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
|
||||
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
|
||||
IntervalRootFinding = "d2bf35a9-74e0-55ec-b149-d360ff49b807"
|
||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
|
||||
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
|
||||
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
|
||||
SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
|
||||
69
CwJ/limits/bisection.js
Normal file
69
CwJ/limits/bisection.js
Normal file
@@ -0,0 +1,69 @@
|
||||
var l = -1.5;
|
||||
var r = 1.75;
|
||||
var N = 8;
|
||||
|
||||
const b = JXG.JSXGraph.initBoard('jsxgraph', {
|
||||
boundingbox: [l, 6.0, r,-2.0], axis:true
|
||||
});
|
||||
|
||||
var f = function(x) {return Math.pow(x,5) - x - 1};
|
||||
|
||||
var graph = b.create('functiongraph', [f, l, r]);
|
||||
|
||||
slider = b.create('slider', [[0.25, 1], [1.0, 1], [0,0,N-1]],
|
||||
{snapWidth:1,
|
||||
suffixLabel:"n = "});
|
||||
|
||||
var intervals = [[0,1.5]];
|
||||
|
||||
for (i = 1; i < N; i++) {
|
||||
var old = intervals[i-1];
|
||||
var ai = old[0];
|
||||
var bi = old[1];
|
||||
var ci = (ai + bi)/2;
|
||||
var fa = f(ai);
|
||||
var fb = f(bi);
|
||||
var fc = f(ci);
|
||||
if (fc == 0) {
|
||||
var newint = [ci, ci];
|
||||
} else if (fa * fc < 0) {
|
||||
var newint = [ai, ci];
|
||||
} else {
|
||||
var newint = [ci, bi];
|
||||
}
|
||||
intervals.push(newint);
|
||||
};
|
||||
|
||||
b.create('functiongraph', [f,
|
||||
function() {
|
||||
var n = slider.Value();
|
||||
return intervals[n][0];
|
||||
},
|
||||
function() {
|
||||
var n = slider.Value();
|
||||
return intervals[n][1];
|
||||
}
|
||||
], {strokeWidth:5});
|
||||
|
||||
var seg = b.create("segment", [function() {
|
||||
var n = slider.Value();
|
||||
var ai = intervals[n][0];
|
||||
return [ai, 0];
|
||||
},
|
||||
function() {
|
||||
var n = slider.Value();
|
||||
var bi = intervals[n][1];
|
||||
return [bi, 0];
|
||||
}], {strokeWidth: 5});
|
||||
|
||||
b.create("point", [function() {
|
||||
var n = slider.Value();
|
||||
var ai = intervals[n][0]
|
||||
return ai;
|
||||
}, 0], {name:"a_n"});
|
||||
|
||||
b.create("point", [function() {
|
||||
var n = slider.Value();
|
||||
var bi = intervals[n][1]
|
||||
return bi;
|
||||
}, 0], {name: "b_n"});
|
||||
BIN
CwJ/limits/cache/continuity.cache
vendored
Normal file
BIN
CwJ/limits/cache/continuity.cache
vendored
Normal file
Binary file not shown.
BIN
CwJ/limits/cache/intermediate_value_theorem.cache
vendored
Normal file
BIN
CwJ/limits/cache/intermediate_value_theorem.cache
vendored
Normal file
Binary file not shown.
BIN
CwJ/limits/cache/limits.cache
vendored
Normal file
BIN
CwJ/limits/cache/limits.cache
vendored
Normal file
Binary file not shown.
BIN
CwJ/limits/cache/limits_extensions.cache
vendored
Normal file
BIN
CwJ/limits/cache/limits_extensions.cache
vendored
Normal file
Binary file not shown.
451
CwJ/limits/continuity.jmd
Normal file
451
CwJ/limits/continuity.jmd
Normal file
@@ -0,0 +1,451 @@
|
||||
# Continuity
|
||||
|
||||
This section uses these add-on packages:
|
||||
|
||||
```julia
|
||||
using CalculusWithJulia
|
||||
using Plots
|
||||
using SymPy
|
||||
```
|
||||
|
||||
```julia; echo=false; results="hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
|
||||
const frontmatter = (
|
||||
title = "Continuity",
|
||||
description = "Calculus with Julia: Continuity",
|
||||
tags = ["CalculusWithJulia", "limits", "continuity"],
|
||||
);
|
||||
|
||||
nothing
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
The definition Google finds for *continuous* is *forming an unbroken whole; without interruption*.
|
||||
|
||||
The concept in calculus, as transferred to functions, is
|
||||
similar. Roughly speaking, a continuous function is one whose graph
|
||||
could be drawn without having to lift (or interrupt) the pencil drawing it.
|
||||
|
||||
Consider these two graphs:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
plt = plot([-1,0], [-1,-1], color=:black, legend=false, linewidth=5)
|
||||
plot!(plt, [0, 1], [ 1, 1], color=:black, linewidth=5)
|
||||
plt
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
plot([-1,-.1, .1, 1], [-1,-1, 1, 1], color=:black, legend=false, linewidth=5)
|
||||
```
|
||||
|
||||
Though similar at some level - they agree at nearly every value of
|
||||
$x$ - the first has a "jump" from $-1$ to $1$ instead of the
|
||||
transition in the second one. The first is not continuous at $0$ - a
|
||||
break is needed to draw it - where as the second is continuous.
|
||||
|
||||
|
||||
|
||||
A formal definition of continuity was a bit harder to come about. At
|
||||
[first](http://en.wikipedia.org/wiki/Intermediate_value_theorem) the
|
||||
concept was that for any $y$ between any two values in the range for
|
||||
$f(x)$, the function should take on the value $y$ for some $x$. Clearly
|
||||
this could distinguish the two graphs above, as one takes no values in
|
||||
$(-1,1)$, whereas the other - the continuous one - takes on all values in that range.
|
||||
|
||||
|
||||
However, [Cauchy](http://en.wikipedia.org/wiki/Cours_d%27Analyse)
|
||||
defined continuity by $f(x + \alpha) - f(x)$ being small whenever
|
||||
$\alpha$ was small. This basically rules out "jumps" and proves more
|
||||
useful as a tool to describe continuity.
|
||||
|
||||
|
||||
The [modern](http://en.wikipedia.org/wiki/Continuous_function#History)
|
||||
definition simply pushes the details to the definition of the limit:
|
||||
|
||||
> A function $f(x)$ is continuous at $x=c$ if $\lim_{x \rightarrow c}f(x) = f(c)$.
|
||||
|
||||
This says three things
|
||||
|
||||
* The limit exists at $c$.
|
||||
|
||||
* The function is defined at $c$ ($c$ is in the domain).
|
||||
|
||||
* The value of the limit is the same as $f(c)$.
|
||||
|
||||
|
||||
This speaks to continuity at a point, we can extend this to continuity over an interval $(a,b)$ by saying:
|
||||
|
||||
> A function $f(x)$ is continuous over $(a,b)$ if at each point $c$ with $a < c < b$, $f(x)$ is continuous at $c$.
|
||||
|
||||
Finally, as with limits, it can be convenient to speak of *right*
|
||||
continuity and *left* continuity at a point, where the limit in the
|
||||
defintion is replaced by a right or left limit, as appropriate.
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
alert("""
|
||||
The limit in the definition of continuity is the basic limit and not an extended sense where
|
||||
infinities are accounted for.
|
||||
""")
|
||||
```
|
||||
##### Examples of continuity
|
||||
|
||||
Most familiar functions are continuous everywhere.
|
||||
|
||||
* For example, a monomial function $f(x) = ax^n$ for non-negative, integer $n$ will be continuous. This is because the limit exists everywhere, the domain of $f$ is all $x$ and there are no jumps.
|
||||
|
||||
* Similarly, the basic trigonometric functions $\sin(x)$, $\cos(x)$ are continuous everywhere.
|
||||
|
||||
* So are the exponential functions $f(x) = a^x, a > 0$.
|
||||
|
||||
* The hyperbolic sine ($(e^x - e^{-x})/2$) and cosine ($(e^x + e^{-x})/2$) are, as $e^x$ is.
|
||||
|
||||
* The hyperbolic tangent is, as $\cosh(x) > 0$ for all $x$.
|
||||
|
||||
Some familiar functions are *mostly* continuous but not everywhere.
|
||||
|
||||
* For example, $f(x) = \sqrt{x}$ is continuous on $(0,\infty)$ and right continuous at $0$, but it is not defined for negative $x$, so can't possibly be continuous there.
|
||||
|
||||
* Similarly, $f(x) = \log(x)$ is continuous on $(0,\infty)$, but it is not defined at $x=0$, so is not right continuous at $0$.
|
||||
|
||||
* The tangent function $\tan(x) = \sin(x)/\cos(x)$ is continuous everywhere *except* the points $x$ with $\cos(x) = 0$ ($\pi/2 + k\pi, k$ an integer).
|
||||
|
||||
* The hyperbolic co-tangent is not continuous at $x=0$ -- when $\sinh$ is $0$,
|
||||
|
||||
* The semicircle $f(x) = \sqrt{1 - x^2}$ is *continuous* on $(-1, 1)$. It is not continuous at $-1$ and $1$, though it is right continuous at $-1$ and left continuous at $1$.
|
||||
|
||||
##### Examples of discontinuity
|
||||
|
||||
There are various reasons why a function may not be continuous.
|
||||
|
||||
* The function $f(x) = \sin(x)/x$ has a limit at $0$ but is not defined at $0$, so is not continuous at $0$. The function can be redefined to make it continuous.
|
||||
|
||||
* The function $f(x) = 1/x$ is continuous everywhere *except* $x=0$ where *no* limit exists.
|
||||
|
||||
* A rational function $f(x) = p(x)/q(x)$ will be continuous everywhere except where $q(x)=0$. (The function ``f`` may still have a limit where ``q`` is ``0``, should factors cancel, but ``f`` won't be defined at such values.)
|
||||
|
||||
* The function
|
||||
|
||||
```math
|
||||
f(x) = \begin{cases}
|
||||
-1 & x < 0 \\
|
||||
0 & x = 0 \\
|
||||
1 & x > 0
|
||||
\end{cases}
|
||||
```
|
||||
|
||||
is implemented by `Julia`'s `sign` function. It has a value at $0$,
|
||||
but no limit at $0$, so is not continuous at $0$. Furthermore, the
|
||||
left and right limits exist at $0$ but are not equal to $f(0)$ so the
|
||||
function is not left or right continuous at $0$. It is continuous everywhere except at $x=0$.
|
||||
|
||||
* Similarly, the function defined by this graph
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
plot([-1,-.01], [-1,-.01], legend=false, color=:black)
|
||||
plot!([.01, 1], [.01, 1], color=:black)
|
||||
scatter!([0], [1/2], markersize=5, markershape=:circle)
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
|
||||
* 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).
|
||||
|
||||
* On the Wikipedia page for [continuity](https://en.wikipedia.org/wiki/Continuous_function) the example of Dirichlet's function is given:
|
||||
|
||||
```math
|
||||
f(x) =
|
||||
\begin{cases}
|
||||
0 & \text{if } x \text{ is irrational,}\\
|
||||
1 & \text{if } x \text{ is rational.}
|
||||
\end{cases}
|
||||
```
|
||||
|
||||
|
||||
The limit for any $c$ is discontinuous, as any interval about $c$ will
|
||||
contain *both* rational and irrational numbers so the function will
|
||||
not take values in a small neighborhood around any potential $L$.
|
||||
|
||||
##### Example
|
||||
|
||||
Let a function be defined by cases:
|
||||
|
||||
```math
|
||||
f(x) = \begin{cases}
|
||||
3x^2 + c & x \geq 0,\\
|
||||
2x-3 & x < 0.
|
||||
\end{cases}
|
||||
```
|
||||
|
||||
What value of $c$ will make $f(x)$ a continuous function?
|
||||
|
||||
We note that for $x < 0$ and for $x > 0$ the function is a simple polynomial, so is continuous. At $x=0$ to be continuous we need a limit to exists and be equal to $f(0)$, which is $c$. A limit exists if the left and right limits are equal. This means we need to solve for $c$ to make the left and right limits equal. We do this next with a bit of overkill in this case:
|
||||
|
||||
```julia;
|
||||
@syms x c
|
||||
ex1 = 3x^2 + c
|
||||
ex2 = 2x-3
|
||||
del = limit(ex1, x=>0, dir="+") - limit(ex2, x=>0, dir="-")
|
||||
```
|
||||
|
||||
We need to solve for $c$ to make `del` zero:
|
||||
|
||||
```julia;
|
||||
solve(del, c)
|
||||
```
|
||||
|
||||
This gives the value of $c$.
|
||||
|
||||
## Rules for continuity
|
||||
|
||||
As we've seen, functions can be combined in several ways. How do these relate with continuity?
|
||||
|
||||
Suppose $f(x)$ and $g(x)$ are both continuous on $I$. Then
|
||||
|
||||
* The function $h(x) = a f(x) + b g(x)$ is continuous on $I$ for any real numbers $a$ and $b$;
|
||||
|
||||
* The function $h(x) = f(x) \cdot g(x)$ is continuous on $I$; and
|
||||
|
||||
* The function $h(x) = f(x) / g(x)$ is continuous at all points $c$ in $I$ **where** $g(c) \neq 0$.
|
||||
|
||||
* The function $h(x) = f(g(x))$ is continuous at $x=c$ *if* $g(x)$ is continuous at $c$ *and* $f(x)$ is continuous at $g(c)$.
|
||||
|
||||
So, continuity is preserved for all of the basic operations except when dividing by $0$.
|
||||
|
||||
##### Examples
|
||||
|
||||
* Since a monomial $f(x) = ax^n$ ($n$ a non-negative integer) is continuous, by the first rule, any polynomial will be continuous.
|
||||
|
||||
* Since both $f(x) = e^x$ and $g(x)=\sin(x)$ are continuous everywhere, so will be $h(x) = e^x \cdot \sin(x)$.
|
||||
|
||||
* Since $f(x) = e^x$ is continuous everywhere and $g(x) = -x$ is continuous everywhere, the composition $h(x) = e^{-x}$ will be continuous everywhere.
|
||||
|
||||
* Since $f(x) = x$ is continuous everywhere, the function $h(x) = 1/x$ - a ratio of continuous functions - will be continuous everywhere *except* possibly at $x=0$ (where it is not continuous).
|
||||
|
||||
* The function $h(x) = e^{x\log(x)}$ will be continuous on $(0,\infty)$, the same domain that $g(x) = x\log(x)$ is continuous. This function (also written as $x^x$) has a right limit at $0$ (of $1$), but is not right continuous, as $h(0)$ is not defined.
|
||||
|
||||
|
||||
## Questions
|
||||
|
||||
###### Question
|
||||
|
||||
Let $f(x) = \sin(x)$ and $g(x) = \cos(x)$. Which of these is not continuous everywhere?
|
||||
|
||||
```math
|
||||
f+g,~ f-g,~ f\cdot g,~ f\circ g,~ f/g
|
||||
```
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["``f+g``", "``f-g``", "``f\\cdot g``", "``f\\circ g``", "``f/g``"]
|
||||
ans = length(choices)
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Let $f(x) = \sin(x)$, $g(x) = \sqrt{x}$.
|
||||
|
||||
When will $f\circ g$ be continuous?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [L"For all $x$", L"For all $x > 0$", L"For all $x$ where $\sin(x) > 0$"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
When will $g \circ f$ be continuous?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [L"For all $x$", L"For all $x > 0$", L"For all $x$ where $\sin(x) > 0$"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
The composition $f\circ g$ will be continuous everywhere provided:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [
|
||||
L"The function $g$ is continuous everywhere",
|
||||
L"The function $f$ is continuous everywhere",
|
||||
L"The function $g$ is continuous everywhere and $f$ is continuous on the range of $g$",
|
||||
L"The function $f$ is continuous everywhere and $g$ is continuous on the range of $f$"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
At which values is $f(x) = 1/\sqrt{x-2}$ not continuous?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=[
|
||||
L"When $x > 2$",
|
||||
L"When $x \geq 2$",
|
||||
L"When $x \leq 2$",
|
||||
L"For $x \geq 0$"]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
A value $x=c$ is a *removable singularity* for $f(x)$ if $f(x)$ is not
|
||||
continuous at $c$ but will be if $f(c)$ is redefined to be $\lim_{x
|
||||
\rightarrow c} f(x)$.
|
||||
|
||||
|
||||
The function $f(x) = (x^2 - 4)/(x-2)$ has a removable singularity at
|
||||
$x=2$. What value would we redefine $f(2)$ to be, to make $f$ a
|
||||
continuous function?
|
||||
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
f(x) = (x^2 -4)/(x-2);
|
||||
numericq(f(2.00001), .001)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
The highly oscillatory function
|
||||
|
||||
```math
|
||||
f(x) = x^2 (\cos(1/x) - 1)
|
||||
```
|
||||
|
||||
has a removable singularity at $x=0$. What value would we redefine
|
||||
$f(0)$ to be, to make $f$ a continuous function?
|
||||
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(0, .001)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Let $f(x)$ be defined by
|
||||
|
||||
```math
|
||||
f(x) = \begin{cases}
|
||||
c + \sin(2x - \pi/2) & x > 0\\
|
||||
3x - 4 & x \leq 0.
|
||||
\end{cases}
|
||||
```
|
||||
|
||||
What value of $c$ will make $f(x)$ continuous?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
val = (3*0 - 4) - (sin(2*0 - pi/2))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Suppose $f(x)$, $g(x)$, and $h(x)$ are continuous functions on $(a,b)$. If $a < c < b$, are you sure that $lim_{x \rightarrow c} f(g(x))$ is $f(g(c))$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [L"No, as $g(c)$ may not be in the interval $(a,b)$",
|
||||
"Yes, composition of continuous functions results in a continuous function, so the limit is just the function value."
|
||||
]
|
||||
ans=1
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
The function $f(x)$ is continuous at $x=1$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
yesnoq(true)
|
||||
```
|
||||
|
||||
The function $f(x)$ is continuous at $x=2$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
yesnoq(false)
|
||||
```
|
||||
|
||||
The function $f(x)$ is right continuous at $x=3$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
yesnoq(false)
|
||||
```
|
||||
|
||||
The function $f(x)$ is left continuous at $x=4$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
yesnoq(true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Let $f(x)$ and $g(x)$ be continuous functions whose graph of $[0,1]$ is given by:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
xs = range(0, 1, length=251)
|
||||
plot(xs, [sin.(2pi*xs) cos.(2pi*xs)], layout=2, title=["f" "g"], legend=false)
|
||||
```
|
||||
|
||||
What is $\lim_{x \rightarrow 0.25} f(g(x))$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
val = sin(2pi * cos(2pi * 1/4))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
What is $\lim{x \rightarrow 0.25} g(f(x))$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
val = cos(2pi * sin(2pi * 1/4))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
What is $\lim_{x \rightarrow 0.5} f(g(x))$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["Can't tell",
|
||||
"``-1.0``",
|
||||
"``0.0``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
```
|
||||
BIN
CwJ/limits/figures/cannonball.jpg
Normal file
BIN
CwJ/limits/figures/cannonball.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
BIN
CwJ/limits/figures/hardrock-100.png
Normal file
BIN
CwJ/limits/figures/hardrock-100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 152 KiB |
1183
CwJ/limits/intermediate_value_theorem.jmd
Normal file
1183
CwJ/limits/intermediate_value_theorem.jmd
Normal file
File diff suppressed because it is too large
Load Diff
19
CwJ/limits/limit-example.js
Normal file
19
CwJ/limits/limit-example.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const b = JXG.JSXGraph.initBoard('jsxgraph', {
|
||||
boundingbox: [-6, 1.2, 6,-1.2], axis:true
|
||||
});
|
||||
|
||||
var f = function(x) {return Math.sin(x) / x;};
|
||||
var graph = b.create("functiongraph", [f, -6, 6])
|
||||
var seg = b.create("line", [[-6,0], [6,0]], {fixed:true});
|
||||
|
||||
var X = b.create("glider", [2, 0, seg], {name:"x", size:4});
|
||||
var P = b.create("point", [function() {return X.X()}, function() {return f(X.X())}], {name:""});
|
||||
var Q = b.create("point", [0, function() {return P.Y();}], {name:"f(x)"});
|
||||
|
||||
var segup = b.create("segment", [P,X], {dash:2});
|
||||
var segover = b.create("segment", [P, [0, function() {return P.Y()}]], {dash:2});
|
||||
|
||||
|
||||
txt = b.create('text', [2, 1, function() {
|
||||
return "x = " + X.X().toFixed(4) + ", f(x) = " + P.Y().toFixed(4);
|
||||
}]);
|
||||
1555
CwJ/limits/limits.jmd
Normal file
1555
CwJ/limits/limits.jmd
Normal file
File diff suppressed because it is too large
Load Diff
981
CwJ/limits/limits_extensions.jmd
Normal file
981
CwJ/limits/limits_extensions.jmd
Normal file
@@ -0,0 +1,981 @@
|
||||
# Limits, issues, extensions of the concept
|
||||
|
||||
This section uses the following add-on packages:
|
||||
|
||||
```julia
|
||||
using CalculusWithJulia
|
||||
using Plots
|
||||
using SymPy
|
||||
```
|
||||
|
||||
|
||||
```julia; echo=false; results="hidden"
|
||||
using CalculusWithJulia.WeaveSupport
|
||||
using DataFrames
|
||||
|
||||
const frontmatter = (
|
||||
title = "Limits, issues, extensions of the concept",
|
||||
description = "Calculus with Julia: Limits, issues, extensions of the concept",
|
||||
tags = ["CalculusWithJulia", "limits", "limits, issues, extensions of the concept"],
|
||||
);
|
||||
nothing
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
The limit of a function at $c$ need not exist for one of many
|
||||
different reasons. Some of these reasons can be handled with
|
||||
extensions to the concept of the limit, others are just problematic in
|
||||
terms of limits. This section covers examples of each.
|
||||
|
||||
|
||||
Let's begin with a function that is just problematic. Consider
|
||||
|
||||
```math
|
||||
f(x) = \sin(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$.
|
||||
|
||||
|
||||
A graph shows the issue:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
f(x) = sin(1/x)
|
||||
plot(f, range(-1, stop=1, length=1000))
|
||||
```
|
||||
|
||||
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$.
|
||||
|
||||
This function basically has too many values it gets close to. Another
|
||||
favorite example of such a function is the function that is $0$ if $x$
|
||||
is rational and $1$ if not. This function will have no limit anywhere,
|
||||
not just at $0$, and for basically the same reason as above.
|
||||
|
||||
|
||||
The issue isn't oscillation though. Take, for example, the function
|
||||
$f(x) = x \cdot \sin(1/x)$. This function again has a limit everywhere
|
||||
save possibly $0$. But in this case, there is a limit at $0$ of
|
||||
$0$. This is because, the following is true:
|
||||
|
||||
```math
|
||||
-|x| \leq x \sin(1/x) \leq |x|.
|
||||
```
|
||||
|
||||
The following figure illustrates:
|
||||
|
||||
```julia; hold=true;
|
||||
f(x) = x * sin(1/x)
|
||||
plot(f, -1, 1)
|
||||
plot!(abs)
|
||||
plot!(x -> -abs(x))
|
||||
```
|
||||
|
||||
|
||||
The [squeeze](http://en.wikipedia.org/wiki/Squeeze_theorem) theorem of
|
||||
calculus is the formal reason $f$ has a limit at $0$, as as both the
|
||||
upper function, $|x|$, and the lower function, $-|x|$, have a limit of
|
||||
$0$ at $0$.
|
||||
|
||||
## Right and left limits
|
||||
|
||||
Another example where $f(x)$ has no limit is the function $f(x) = x /|x|, x \neq 0$. This
|
||||
function is $-1$ for negative $x$ and $1$ for positive $x$. Again,
|
||||
this function will have a limit everywhere except possibly at $x=0$,
|
||||
where division by $0$ is possible.
|
||||
|
||||
It's graph is
|
||||
|
||||
```julia; hold=true;
|
||||
f(x) = abs(x)/x
|
||||
plot(f, -2, 2)
|
||||
```
|
||||
|
||||
The sharp jump at $0$ is misleading - again, the plotting algorithm
|
||||
just connects the points, it doesn't handle what is a fundamental
|
||||
discontinuity well - the function is not defined at $0$ and jumps
|
||||
from $-1$ to $1$ there. Similarly to our example of $\sin(1/x)$, near
|
||||
$0$ the function get's close to both $1$ and $-1$, so will have no
|
||||
limit. (Again, just take $\epsilon$ smaller than $1$.)
|
||||
|
||||
But unlike the previous example, this function *would* have a limit if
|
||||
the definition didn't consider values of $x$ on both sides of $c$. The
|
||||
limit on the right side would be $1$, the limit on the left side would
|
||||
be $-1$. This distinction is useful, so there is an extension of the idea of a
|
||||
limit to *one-sided limits*.
|
||||
|
||||
|
||||
Let's loosen up the language in the definition of a limit to read:
|
||||
|
||||
> The limit of $f(x)$ as $x$ approaches $c$ is $L$ if for every
|
||||
> neighborhood, $V$, of $L$ there is a neighborhood, $U$, of $c$ for
|
||||
> which $f(x)$ is in $V$ for every $x$ in $U$, except possibly $x=c$.
|
||||
|
||||
The $\epsilon-\delta$ definition has $V = (L-\epsilon, L + \epsilon)$
|
||||
and $U=(c-\delta, c+\delta)$. This is a rewriting of $L-\epsilon <
|
||||
f(x) < L + \epsilon$ as $|f(x) - L| < \epsilon$.
|
||||
|
||||
Now for the defintion:
|
||||
|
||||
|
||||
> A function $f(x)$ has a limit on the right of $c$, written $\lim_{x
|
||||
> \rightarrow c+}f(x) = L$ if for every $\epsilon > 0$, there exists a
|
||||
> $\delta > 0$ such that whenever $0 < x - c < \delta$ it holds that
|
||||
> $|f(x) - L| < \epsilon$. That is, $U$ is $(c, c+\delta)$
|
||||
|
||||
Similarly, a limit on the left is defined where $U=(c-\delta, c)$.
|
||||
|
||||
The `SymPy` function `limit` has a keyword argument `dir="+"` or
|
||||
`dir="-"` to request that a one-sided limit be formed. The default is `dir="+"`. Passing `dir="+-"` will compute both one side limits, and throw an error if the two are not equal, in agreement with no limit existing.
|
||||
|
||||
```julia;
|
||||
@syms x
|
||||
```
|
||||
|
||||
```julia;hold=true
|
||||
f(x) = abs(x)/x
|
||||
limit(f(x), x=>0, dir="+"), limit(f(x), x=>0, dir="-")
|
||||
```
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
alert("""
|
||||
That means the mathematical limit need not exist when `SymPy`'s `limit` returns an answer, as `SymPy` is only carrying out a one sided limit. Explicitly passing `dir="+-"` or checking that both `limit(ex, x=>c)` and `limit(ex, x=>c, dir="-")` are equal would be needed to confirm a limit exists mathematically.
|
||||
""")
|
||||
```
|
||||
|
||||
The relation between the two concepts is that a function has a limit at $c$ if
|
||||
an only if the left and right limits exist and are equal. This
|
||||
function $f$ has both existing, but the two limits are not equal.
|
||||
|
||||
|
||||
There are other such functions that jump. Another useful one is the
|
||||
floor function, which just rounds down to the nearest integer. A graph shows the basic shape:
|
||||
|
||||
```julia;
|
||||
plot(floor, -5,5)
|
||||
```
|
||||
|
||||
Again, the (nearly) vertical lines are an artifact of the graphing
|
||||
algorithm and not actual points that solve $y=f(x)$. The floor
|
||||
function has limits except at the integers. There the left and right
|
||||
limits differ.
|
||||
|
||||
Consider the limit at $c=0$. If $0 < x < 1/2$, say, then $f(x) = 0$ as
|
||||
we round down, so the right limit will be $0$. However, if $-1/2 < x <
|
||||
0$, then the $f(x) = -1$, again as we round down, so the left limit
|
||||
will be $-1$. Again, with this example both the left and right limits
|
||||
exists, but at the integer values they are not equal, as they differ
|
||||
by 1.
|
||||
|
||||
|
||||
Some functions only have one-sided limits as they are not defined in
|
||||
an interval around $c$. There are many examples, but we will take
|
||||
$f(x) = x^x$ and consider ``c=0``. This function is not well defined for all $x <
|
||||
0$, so it is typical to just take the domain to be $x > 0$. Still it
|
||||
has a right limit $\lim_{x \rightarrow 0+} x^x = 1$. `SymPy` can verify:
|
||||
|
||||
```julia;
|
||||
limit(x^x, x, 0, dir="+")
|
||||
```
|
||||
|
||||
This agrees with the IEEE convention of assigning `0^0` to be `1`.
|
||||
|
||||
However, not all such functions with indeterminate forms of $0^0$ will
|
||||
have a limit of $1$.
|
||||
|
||||
##### Example
|
||||
|
||||
Consider this funny graph:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
xs = range(0,stop=1, length=50)
|
||||
|
||||
plot(x->x^2, -2, -1, legend=false)
|
||||
plot!(exp, -1,0)
|
||||
plot!(x -> 1-2x, 0, 1)
|
||||
plot!(sqrt, 1, 2)
|
||||
plot!(x -> 1-x, 2,3)
|
||||
```
|
||||
|
||||
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$.
|
||||
|
||||
|
||||
|
||||
|
||||
## Limits at infinity
|
||||
|
||||
The loose definition of a horizontal asymptote is "a line such that
|
||||
the distance between the curve and the line approaches $0$ as they
|
||||
tend to infinity." This sounds like it should be defined by a
|
||||
limit. The issue is, that the limit would be at $\pm\infty$ and not
|
||||
some finite $c$. This requires the idea of a neighborhood of $c$, $0 < |x-c| < \delta$ to be
|
||||
reworked.
|
||||
|
||||
The basic idea for a limit at $+\infty$ is that for any $\epsilon$,
|
||||
there exists an $M$ such that when $x > M$ it must be that $|f(x) - L|
|
||||
< \epsilon$. For a horizontal asymptote, the line would be
|
||||
$y=L$. Similarly a limit at $-\infty$ can be defined with $x < M$
|
||||
being the condition.
|
||||
|
||||
|
||||
Let's consider some cases.
|
||||
|
||||
The function $f(x) = \sin(x)$ will not have a limit at $+\infty$ for
|
||||
exactly the same reason that $f(x) = \sin(1/x)$ does not have a limit
|
||||
at $c=0$ - it just oscillates between $-1$ and $1$ so never
|
||||
eventually gets close to a single value.
|
||||
|
||||
`SymPy` gives an odd answer here indicating the range of values:
|
||||
|
||||
```julia;
|
||||
limit(sin(x), x => oo)
|
||||
```
|
||||
|
||||
(We used `SymPy`'s `oo` for $\infty$ and not `Inf`.)
|
||||
|
||||
----
|
||||
|
||||
|
||||
However, a damped oscillation, such as $f(x) = e^{-x} \sin(x)$ will have a limit:
|
||||
|
||||
```julia;
|
||||
limit(exp(-x)*sin(x), x => oo)
|
||||
```
|
||||
|
||||
|
||||
----
|
||||
|
||||
We have rational functions will have the expected limit. In this
|
||||
example $m = n$, so we get a horizontal asymptote that is not $y=0$:
|
||||
|
||||
```julia;
|
||||
limit((x^2 - 2x +2)/(4x^2 + 3x - 2), x=>oo)
|
||||
```
|
||||
----
|
||||
|
||||
Though rational functions can have only one (at most) horizontal asymptote, this isn't true for all functions. Consider the following $f(x) = x / \sqrt{x^2 + 4}$. It has different limits depending if ``x`` goes to ``\infty`` or negative ``\infty``:
|
||||
|
||||
```julia;hold=true;
|
||||
f(x) = x / sqrt(x^2 + 4)
|
||||
limit(f(x), x=>oo), limit(f(x), x=>-oo)
|
||||
```
|
||||
|
||||
(A simpler example showing this behavior is just the function $x/|x|$ considered earlier.)
|
||||
|
||||
##### Example: Limits at infinity and right limits at ``0``
|
||||
|
||||
Given a function ``f`` the question of whether this exists:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow \infty} f(x)
|
||||
```
|
||||
|
||||
can be reduced to the question of whether this limit exists:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0+} f(1/x)
|
||||
```
|
||||
|
||||
So whether ``\lim_{x \rightarrow 0+} \sin(1/x)`` exists is equivalent to whether ``\lim_{x\rightarrow \infty} \sin(x)`` exists, which clearly does not due to the oscillatory nature of ``\sin(x)``.
|
||||
|
||||
|
||||
Similarly, one can make this reduction
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow c+} f(x) =
|
||||
\lim_{x \rightarrow 0+} f(c + x) =
|
||||
\lim_{x \rightarrow \infty} f(c + \frac{1}{x}).
|
||||
```
|
||||
|
||||
That is, right limits can be analyzed as limits at ``\infty`` or right limits at ``0``, should that prove more convenient.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Limits of infinity
|
||||
|
||||
Vertical asymptotes are nicely defined with horizontal asymptotes by
|
||||
the graph getting close to some line. However, the formal definition
|
||||
of a limit won't be the same. For a vertical asymptote, the value of
|
||||
$f(x)$ heads towards positive or negative infinity, not some finite
|
||||
$L$. As such, a neighborhood like $(L-\epsilon, L+\epsilon)$ will no
|
||||
longer make sense, rather we replace it with an expression like $(M,
|
||||
\infty)$ or $(-\infty, M)$. As in: the limit of $f(x)$ as $x$
|
||||
approaches $c$ is *infinity* if for every $M > 0$ there exists a
|
||||
$\delta>0$ such that if $0 < |x-c| < \delta$ then $f(x) > M$. Approaching $-\infty$ would conclude with $f(x) < -M$ for all $M>0$.
|
||||
|
||||
##### Examples
|
||||
|
||||
Consider the function $f(x) = 1/x^2$. This will have a limit at every
|
||||
point except possibly $0$, where division by $0$ is possible. In this
|
||||
case, there is a vertical asymptote, as seen in the following graph. The limit at $0$ is $\infty$, in
|
||||
the extended sense above. For $M>0$, we can take any $0 < \delta <
|
||||
1/\sqrt{M}$. The following graph shows $M=25$ where the function
|
||||
values are outside of the box, as $f(x) > M$ for those $x$ values with $0 < |x-0| < 1/\sqrt{M}$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
f(x) = 1/x^2
|
||||
M = 25
|
||||
delta = 1/sqrt(M)
|
||||
|
||||
f(x) = 1/x^2 > 50 ? NaN : 1/x^2
|
||||
plot(f, -1, 1, legend=false)
|
||||
plot!([-delta, delta], [M,M], color=colorant"orange")
|
||||
plot!([-delta, -delta], [0,M], color=colorant"red")
|
||||
plot!([delta, delta], [0,M], color=colorant"red")
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
The function $f(x)=1/x$ requires us to talk about left and right limits of infinity, with the natural generalization. We can see that the left limit at $0$ is $-\infty$ and the right limit $\infty$:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
f(x) = 1/x
|
||||
plot(f, 1/50, 1, color=:blue, legend=false)
|
||||
plot!(f, -1, -1/50, color=:blue)
|
||||
```
|
||||
|
||||
`SymPy` agrees:
|
||||
|
||||
```julia; hold=true;
|
||||
f(x) = 1/x
|
||||
limit(f(x), x=>0, dir="-"), limit(f(x), x=>0, dir="+")
|
||||
```
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
Consider the function $g(x) = x^x(1 + \log(x)), x > 0$. Does this have a *right* limit at $0$?
|
||||
|
||||
A quick graph shows that a limit may be $-\infty$:
|
||||
|
||||
```julia;
|
||||
g(x) = x^x * (1 + log(x))
|
||||
plot(g, 1/100, 1)
|
||||
```
|
||||
|
||||
We can check with `SymPy`:
|
||||
|
||||
```julia;
|
||||
limit(g(x), x=>0, dir="+")
|
||||
```
|
||||
## Limits of sequences
|
||||
|
||||
After all this, we still can't formalize the basic question asked in
|
||||
the introduction to limits: what is the area contained in a parabola. For that
|
||||
we developed a sequence of sums: $s_n = 1/2 \dot((1/4)^0 + (1/4)^1 + (1/4)^2 +
|
||||
\cdots + (1/4)^n)$. This isn't a function of $x$, but rather depends
|
||||
only on non-negative integer values of $n$. However, the same idea as
|
||||
a limit at infinity can be used to define a limit.
|
||||
|
||||
> Let $a_0,a_1, a_2, \dots, a_n, \dots$ be a sequence of values indexed by $n$.
|
||||
> We have $\lim_{n \rightarrow \infty} a_n = L$ if for every $\epsilon > 0$ there exists an $M>0$ where if $n > M$ then $|a_n - L| < \epsilon$.
|
||||
|
||||
Common language is the sequence *converges* when the limit exists and otherwise *diverges*.
|
||||
|
||||
The above is essentially the same as a limit *at* infinity for a function,
|
||||
but in this case the function's domain is only the non-negative
|
||||
integers.
|
||||
|
||||
`SymPy` is happy to compute limits of sequences. Defining this one involving a sum is best done with the `summation` function:
|
||||
|
||||
```julia;
|
||||
@syms i::integer n::(integer, positive)
|
||||
s(n) = 1//2 * summation((1//4)^i, (i, 0, n)) # rationals make for an exact answer
|
||||
limit(s(n), n=>oo)
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
The limit
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0} \frac{e^x - 1}{x} = 1,
|
||||
```
|
||||
|
||||
is an important limit. Using the definition of ``e^x`` by an infinite sequence:
|
||||
|
||||
```math
|
||||
e^x = \lim_{n \rightarrow \infty} (1 + \frac{x}{n})^n,
|
||||
```
|
||||
|
||||
we can establish the limit using the squeeze theorem. First,
|
||||
|
||||
```math
|
||||
A = |(1 + \frac{x}{n})^n - 1 - x| = |\Sigma_{k=0}^n {n \choose k}(\frac{x}{n})^k - 1 - x| = |\Sigma_{k=2}^n {n \choose k}(\frac{x}{n})^k|,
|
||||
```
|
||||
|
||||
the first two sums cancelling off. The above comes from the binomial expansion theorem for a polynomial. Now ``{n \choose k} \leq n^k``so we have
|
||||
|
||||
```math
|
||||
A \leq \Sigma_{k=2}^n |x|^k = |x|^2 \frac{1 - |x|^{n+1}}{1 - |x|} \leq
|
||||
\frac{|x|^2}{1 - |x|}.
|
||||
```
|
||||
|
||||
using the *geometric* sum formula with ``x \approx 0`` (and not ``1``):
|
||||
|
||||
```julia; hold=true
|
||||
@syms x n i
|
||||
summation(x^i, (i,0,n))
|
||||
```
|
||||
|
||||
|
||||
As this holds for all ``n``, as ``n`` goes to ``\infty`` we have:
|
||||
|
||||
```math
|
||||
|e^x - 1 - x| \leq \frac{|x|^2}{1 - |x|}
|
||||
```
|
||||
|
||||
Dividing both sides by ``x`` and noting that as ``x \rightarrow 0``, ``|x|/(1-|x|)`` goes to ``0`` by continuity, the squeeze theorem gives the limit:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0} \frac{e^x -1}{x} - 1 = 0.
|
||||
```
|
||||
|
||||
|
||||
That ``{n \choose k} \leq n^k`` can be viewed as the left side counts the number of combinations of ``k`` choices from ``n`` distinct items, which is less than the number of permutations of ``k`` choices, which is less than the number of choices of ``k`` items from ``n`` distinct ones without replacement -- what ``n^k`` counts.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Some limit theorems for sequences
|
||||
|
||||
The limit discussion first defined limits of scalar univariate functions at a point ``c`` and then added generalizations. The pedagogical approach can be reversed by starting the discussion with limits of sequences and then generalizing from there. This approach relies on a few theorems to be gathered along the way that are mentioned here for the curious reader:
|
||||
|
||||
* Convergent sequences are bounded.
|
||||
* All *bounded* monotone sequences converge.
|
||||
* Every bounded sequence has a convergent subsequence. (Bolzano-Weirstrass)
|
||||
* The limit of ``f`` at ``c`` exists and equals ``L`` if and only if for *every* sequence ``x_n`` in the domain of ``f`` converging to ``c`` the sequence ``s_n = f(x_n)`` converges to ``L``.
|
||||
|
||||
|
||||
## Summary
|
||||
|
||||
The following table captures the various changes to the definition of
|
||||
the limit to accommodate some of the possible behaviors.
|
||||
|
||||
```julia; echo=false
|
||||
limit_type=[
|
||||
"limit",
|
||||
"right limit",
|
||||
"left limit",
|
||||
L"limit at $\infty$",
|
||||
L"limit at $-\infty$",
|
||||
L"limit of $\infty$",
|
||||
L"limit of $-\infty$",
|
||||
"limit of a sequence"
|
||||
]
|
||||
|
||||
Notation=[
|
||||
L"\lim_{x\rightarrow c}f(x) = L",
|
||||
L"\lim_{x\rightarrow c+}f(x) = L",
|
||||
L"\lim_{x\rightarrow c-}f(x) = L",
|
||||
L"\lim_{x\rightarrow \infty}f(x) = L",
|
||||
L"\lim_{x\rightarrow -\infty}f(x) = L",
|
||||
L"\lim_{x\rightarrow c}f(x) = \infty",
|
||||
L"\lim_{x\rightarrow c}f(x) = -\infty",
|
||||
L"\lim_{n \rightarrow \infty} a_n = L"
|
||||
]
|
||||
|
||||
Vs = [
|
||||
L"(L-\epsilon, L+\epsilon)",
|
||||
L"(L-\epsilon, L+\epsilon)",
|
||||
L"(L-\epsilon, L+\epsilon)",
|
||||
L"(L-\epsilon, L+\epsilon)",
|
||||
L"(L-\epsilon, L+\epsilon)",
|
||||
L"(M, \infty)",
|
||||
L"(-\infty, M)",
|
||||
L"(L-\epsilon, L+\epsilon)"
|
||||
]
|
||||
|
||||
Us = [
|
||||
L"(c - \delta, c+\delta)",
|
||||
L"(c, c+\delta)",
|
||||
L"(c - \delta, c)",
|
||||
L"(M, \infty)",
|
||||
L"(-\infty, M)",
|
||||
L"(c - \delta, c+\delta)",
|
||||
L"(c - \delta, c+\delta)",
|
||||
L"(M, \infty)"
|
||||
]
|
||||
|
||||
d = DataFrame(Type=limit_type, Notation=Notation, V=Vs, U=Us)
|
||||
table(d)
|
||||
```
|
||||
|
||||
[Ross](https://doi.org/10.1007/978-1-4614-6271-2) summarizes this by enumerating the 15 different *related* definitions for ``\lim_{x \rightarrow a} f(x) = L`` that arise from ``L`` being either finite, ``-\infty``, or ``+\infty`` and ``a`` being any of ``c``, ``c-``, ``c+``, ``-\infty``, or ``+\infty``.
|
||||
|
||||
## Rates of growth
|
||||
|
||||
Consider two functions ``f`` and ``g`` to be *comparable* if there are positive integers ``m`` and ``n`` with *both*
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow \infty} \frac{f(x)^m}{g(x)} = \infty \quad\text{and }
|
||||
\lim_{x \rightarrow \infty} \frac{g(x)^n}{f(x)} = \infty.
|
||||
```
|
||||
|
||||
The first says ``g`` is eventually bounded by a power of ``f``, the second that ``f`` is eventually bounded by a power of ``g``.
|
||||
|
||||
Here we consider which families of functions are *comparable*.
|
||||
|
||||
|
||||
First consider ``f(x) = x^3`` and ``g(x) = x^4``. We can take ``m=2`` and ``n=1`` to verify ``f`` and ``g`` are comparable:
|
||||
|
||||
```julia
|
||||
fx, gx = x^3, x^4
|
||||
limit(fx^2/gx, x=>oo), limit(gx^1 / fx, x=>oo)
|
||||
```
|
||||
|
||||
Similarly for any pairs of powers, so we could conclude ``f(x) = x^n`` and ``g(x) =x^m`` are comparable. (However, as is easily observed, for ``m`` and ``n`` both positive integers ``\lim_{x \rightarrow \infty} x^{m+n}/x^m = \infty`` and ``\lim_{x \rightarrow \infty} x^{m}/x^{m+n} = 0``, consistent with our discussion on rational functions that higher-order polynomials dominate lower-order polynomials.)
|
||||
|
||||
|
||||
Now consider ``f(x) = x`` and ``g(x) = \log(x)``. These are not compatible as there will be no ``n`` large enough. We might say ``x`` dominates ``\log(x)``.
|
||||
|
||||
```julia
|
||||
limit(log(x)^n / x, x => oo)
|
||||
```
|
||||
|
||||
As ``x`` could be replaced by any monomial ``x^k``, we can say "powers" grow faster than "logarithms".
|
||||
|
||||
|
||||
Now consider ``f(x)=x`` and ``g(x) = e^x``. These are not compatible as there will be no ``m`` large enough:
|
||||
|
||||
```julia
|
||||
@syms m::(positive, integer)
|
||||
limit(x^m / exp(x), x => oo)
|
||||
```
|
||||
|
||||
That is ``e^x`` grows faster than any power of ``x``.
|
||||
|
||||
|
||||
Now, if ``a, b > 1`` then ``f(x) = a^x`` and ``g(x) = b^x`` will be comparable.
|
||||
Take ``m`` so that ``a^m > b`` and ``n`` so that ``b^n > x`` as then, say,
|
||||
|
||||
```math
|
||||
\frac{(a^x)^m}{b^x} = \frac{a^{xm}}{b^x} = \frac{(a^m)^x}{b^x} = (\frac{a^m}{b})^x,
|
||||
```
|
||||
|
||||
which will go to ``\infty`` as ``x \rightarrow \infty`` as ``a^m/b > 1``.
|
||||
|
||||
|
||||
Finally, consider ``f(x) = \exp(x^2)`` and ``g(x) = \exp(x)^2``. Are these comparable? No, as no ``n`` is large enough:
|
||||
|
||||
```julia; hold=true;
|
||||
@syms x n::(positive, integer)
|
||||
fx, gx = exp(x^2), exp(x)^2
|
||||
limit(gx^n / fx, x => oo)
|
||||
```
|
||||
|
||||
A negative test for compatability is the following: if
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow \infty} \frac{\log(|f(x)|)}{\log(|g(x)|)} = 0,
|
||||
```
|
||||
|
||||
Then ``f`` and ``g`` are not compatible (and ``g`` grows faster than ``f``). Applying this to the last two values of ``f`` and ``g``, we have
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow \infty}\frac{\log(\exp(x)^2)}{\log(\exp(x^2))} =
|
||||
\lim_{x \rightarrow \infty}\frac{2\log(\exp(x))}{x^2} =
|
||||
\lim_{x \rightarrow \infty}\frac{2x}{x^2} = 0,
|
||||
```
|
||||
|
||||
so ``f(x) = \exp(x^2)`` grows faster than ``g(x) = \exp(x)^2``.
|
||||
|
||||
|
||||
----
|
||||
|
||||
Keeping in mind that logarithms grow slower than powers which grow slower than exponentials (``a > 1``) can help understand growth at ``\infty`` as a comparison of leading terms does for rational functions.
|
||||
|
||||
|
||||
We can immediately put this to use to compute ``\lim_{x\rightarrow 0+} x^x``. We first express this problem using ``x^x = (\exp(\ln(x)))^x = e^{x\ln(x)}``. Rewriting ``u(x) = \exp(\ln(u(x)))``, which only uses the basic inverse relation between the two functions, can often be a useful step.
|
||||
|
||||
|
||||
As ``f(x) = e^x`` is a suitably nice function (continuous) so that the limit of a composition can be computed through the limit of the inside function, ``x\ln(x)``, it is enough to see what ``\lim_{x\rightarrow 0+} x\ln(x)`` is. We *re-express* this as a limit at ``\infty``
|
||||
|
||||
```math
|
||||
\lim_{x\rightarrow 0+} x\ln(x) = \lim_{x \rightarrow \infty} (1/x)\ln(1/x) =
|
||||
\lim_{x \rightarrow \infty} \frac{-\ln(x)}{x} = 0
|
||||
```
|
||||
|
||||
The last equality follows, as the function ``x`` dominates the function ``\ln(x)``. So by the limit rule involving compositions we have: ``\lim_{x\rightarrow 0+} x^x = e^0 = 1``.
|
||||
|
||||
## Questions
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Select the graph for which the limit at ``a`` is infinite.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
p1 = plot(;axis=nothing, legend=false)
|
||||
title!(p1, "(a)")
|
||||
plot!(p1, x -> x^2, 0, 2, color=:black)
|
||||
plot!(p1, zero, linestyle=:dash)
|
||||
annotate!(p1,[(1,0,"a")])
|
||||
|
||||
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")])
|
||||
|
||||
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")])
|
||||
|
||||
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")])
|
||||
|
||||
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), (1/2,1))
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Select the graph for which the limit at ``\infty`` appears to be defined.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
p1 = plot(;axis=nothing, legend=false)
|
||||
title!(p1, "(a)")
|
||||
plot!(p1, x -> x^2, 0, 2, color=:black)
|
||||
plot!(p1, zero, linestyle=:dash)
|
||||
|
||||
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)
|
||||
|
||||
p3 = plot(;axis=nothing, legend=false)
|
||||
title!(p3, "(c)")
|
||||
plot!(p3, sinpi, 0, 2, color=:black)
|
||||
plot!(p3, zero, linestyle=:dash)
|
||||
|
||||
p4 = plot(;axis=nothing, legend=false)
|
||||
title!(p4, "(d)")
|
||||
plot!(p4, x -> x^x, 0, 2, color=:black)
|
||||
plot!(p4, zero, linestyle=:dash)
|
||||
|
||||
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), (1/2,1))
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Consider the function $f(x) = \sqrt{x}$.
|
||||
|
||||
Does this function have a limit at every $c > 0$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
booleanq(true, labels=["Yes", "No"])
|
||||
```
|
||||
|
||||
Does this function have a limit at $c=0$?
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
booleanq(false, labels=["Yes", "No"])
|
||||
```
|
||||
|
||||
|
||||
Does this function have a right limit at $c=0$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
booleanq(true, labels=["Yes", "No"])
|
||||
```
|
||||
|
||||
Does this function have a left limit at $c=0$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
booleanq(false, labels=["Yes", "No"])
|
||||
```
|
||||
|
||||
##### Question
|
||||
|
||||
Find $\lim_{x \rightarrow \infty} \sin(x)/x$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(0)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Find $\lim_{x \rightarrow \infty} (1-\cos(x))/x^2$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(0)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Find $\lim_{x \rightarrow \infty} \log(x)/x$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
Find $\lim_{x \rightarrow 2+} (x-3)/(x-2)$.
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=["``L=-\\infty``", "``L=-1``", "``L=0``", "``L=\\infty``"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
Find $\lim_{x \rightarrow -3-} (x-3)/(x+3)$.
|
||||
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=["``L=-\\infty``", "``L=-1``", "``L=0``", "``L=\\infty``"]
|
||||
ans = 4
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Let ``f(x) = \exp(x + \exp(-x^2))`` and ``g(x) = \exp(-x^2)``. Compute:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow \infty} \frac{\ln(f(x))}{\ln(g(x))}.
|
||||
```
|
||||
|
||||
```julia; hold=true;echo=false
|
||||
@syms x
|
||||
ex = log(exp(x + exp(-x^2))) / log(exp(-x^2))
|
||||
val = N(limit(ex, x => oo))
|
||||
numericq(val)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Consider the following expression:
|
||||
|
||||
```julia;
|
||||
ex = 1/(exp(-x + exp(-x))) - exp(x)
|
||||
```
|
||||
|
||||
We want to find the limit, ``L``, as ``x \rightarrow \infty``, which we assume exists below.
|
||||
|
||||
We first rewrite `ex` using `w` as `exp(-x)`:
|
||||
|
||||
```julia
|
||||
@syms w
|
||||
ex1 = ex(exp(-x) => w)
|
||||
```
|
||||
|
||||
As ``x \rightarrow \infty``, ``w \rightarrow 0+``, so the limit at ``0+`` of `ex1` is of interest.
|
||||
|
||||
Use this fact, to find ``L``
|
||||
|
||||
```julia
|
||||
limit(ex1 - (w/2 - 1), w=>0)
|
||||
```
|
||||
|
||||
``L`` is:
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(-1)
|
||||
```
|
||||
|
||||
(This awkward approach is generalizable: replacing the limit as ``w \rightarrow 0`` of an expression with the limit of a polynomial in `w` that is easy to identify.)
|
||||
|
||||
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
As mentioned, for limits that depend on specific values of parameters `SymPy` may have issues.
|
||||
As an example, `SymPy` has an issue with this limit, whose answer depends on the value of ``k``"
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0+} \frac{\sin(\sin(x^2))}{x^k}.
|
||||
```
|
||||
|
||||
|
||||
|
||||
Note, regardless of ``k`` you find:
|
||||
|
||||
```julia; hold=true;
|
||||
@syms x::real k::integer
|
||||
limit(sin(sin(x^2))/x^k, x=>0)
|
||||
```
|
||||
|
||||
For which value(s) of ``k`` in ``1,2,3`` is this actually the correct answer? (Do the above ``3`` times using a specific value of `k`, not a numeric one.
|
||||
|
||||
```julia, echo=false
|
||||
choices = ["``1``", "``2``", "``3``", "``1,2``", "``1,3``", "``2,3``", "``1,2,3``"]
|
||||
radioq(choices, 1, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
###### Question: No limit
|
||||
|
||||
Some functions do not have a limit. Make a graph of $\sin(1/x)$ from $0.0001$ to $1$ and look at the output. Why does a limit not exist?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=["The limit does exist - it is any number from -1 to 1",
|
||||
"Err, the limit does exists and is 1",
|
||||
"The function oscillates too much and its y values do not get close to any one value",
|
||||
"Any function that oscillates does not have a limit."]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
|
||||
|
||||
###### Question ``0^0`` is not *always* ``1``
|
||||
|
||||
Is the form $0^0$ really indeterminate? As mentioned `0^0` evaluates to `1`.
|
||||
|
||||
|
||||
Consider this limit:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0+} x^{k\cdot x} = L.
|
||||
```
|
||||
|
||||
Consider different values of $k$ to see if this limit depends on $k$ or not. What is $L$?
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["``1``", "``k``", "``\\log(k)``", "The limit does not exist"]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
|
||||
Now, consider this limit:
|
||||
|
||||
```math
|
||||
\lim_{x \rightarrow 0+} x^{1/\log_k(x)} = L.
|
||||
```
|
||||
|
||||
In `julia`, $\log_k(x)$ is found with `log(k,x)`. The default, `log(x)` takes $k=e$ so gives the natural log. So, we would define `h`, for a given `k`, with
|
||||
|
||||
```julia; echo=false
|
||||
k = 10 # say. Replace with actual value
|
||||
h(x) = x^(1/log(k, x))
|
||||
```
|
||||
|
||||
|
||||
|
||||
Consider different values of $k$ to see if the limit depends on $k$ or not. What is $L$?
|
||||
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = ["``1``", "``k``", "``\\log(k)``", "The limit does not exist"]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Limits *of* infinity *at* infinity. We could define this concept quite
|
||||
easily mashing together the two definitions. Suppose we did. Which of
|
||||
these ratios would have a limit of infinity at infinity:
|
||||
|
||||
```math
|
||||
x^4/x^3,\quad x^{100+1}/x^{100}, \quad x/\log(x), \quad 3^x / 2^x, \quad e^x/x^{100}
|
||||
```
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices=[
|
||||
"the first one",
|
||||
"the first and second ones",
|
||||
"the first, second and third ones",
|
||||
"the first, second, third, and fourth ones",
|
||||
"all of them"]
|
||||
ans = 5
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
###### Question
|
||||
|
||||
A slant asymptote is a line $mx + b$ for which the graph of $f(x)$
|
||||
gets close to as $x$ gets large. We can't express this directly as a
|
||||
limit, as "$L$" is not a number. How might we?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [
|
||||
L"We can talk about the limit at $\infty$ of $f(x) - (mx + b)$ being $0$",
|
||||
L"We can talk about the limit at $\infty$ of $f(x) - mx$ being $b$",
|
||||
L"We can say $f(x) - (mx+b)$ has a horizontal asymptote $y=0$",
|
||||
L"We can say $f(x) - mx$ has a horizontal asymptote $y=b$",
|
||||
"Any of the above"]
|
||||
ans = 5
|
||||
radioq(choices, ans, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
|
||||
Suppose a sequence of points $x_n$ converges to $a$ in the limiting sense. For a function $f(x)$, the sequence of points $f(x_n)$ may or may not converge. One alternative definition of a [limit](https://en.wikipedia.org/wiki/Limit_of_a_function#In_terms_of_sequences) due to Heine is that $\lim_{x \rightarrow a}f(x) = L$ if *and* only if **all** sequences $x_n \rightarrow a$ have $f(x_n) \rightarrow L$.
|
||||
|
||||
Consider the function $f(x) = \sin(1/x)$, $a=0$, and the two sequences implicitly defined by $1/x_n = \pi/2 + n \cdot (2\pi)$ and $y_n = 3\pi/2 + n \cdot(2\pi)$, $n = 0, 1, 2, \dots$.
|
||||
|
||||
What is $\lim_{x_n \rightarrow 0} f(x_n)$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(1)
|
||||
```
|
||||
|
||||
What is $\lim_{y_n \rightarrow 0} f(y_n)$?
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
numericq(-1)
|
||||
```
|
||||
|
||||
This shows that
|
||||
|
||||
```julia; hold=true; echo=false
|
||||
choices = [L" $f(x)$ has a limit of $1$ as $x \rightarrow 0$",
|
||||
L" $f(x)$ has a limit of $-1$ as $x \rightarrow 0$",
|
||||
L" $f(x)$ does not have a limit as $x \rightarrow 0$"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
```
|
||||
26
CwJ/limits/process.jl
Normal file
26
CwJ/limits/process.jl
Normal file
@@ -0,0 +1,26 @@
|
||||
using CwJWeaveTpl
|
||||
|
||||
fnames = [
|
||||
"limits",
|
||||
"limits_extensions",
|
||||
#
|
||||
"continuity",
|
||||
"intermediate_value_theorem"
|
||||
]
|
||||
|
||||
|
||||
process_file(nm; cache=:off) = CwJWeaveTpl.mmd(nm * ".jmd", cache=cache)
|
||||
|
||||
function process_files(;cache=:user)
|
||||
for f in fnames
|
||||
@show f
|
||||
process_file(f, cache=cache)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
"""
|
||||
## TODO limits
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user