diff --git a/quarto/ODEs/euler.qmd b/quarto/ODEs/euler.qmd index 493ca31..356aab4 100644 --- a/quarto/ODEs/euler.qmd +++ b/quarto/ODEs/euler.qmd @@ -297,10 +297,10 @@ plot!(f, x0, xn) From the graph it appears our value for `f(xn)` will underestimate the actual value of the solution slightly. -##### Example +##### Example: the power series method and Euler -The equation $y'(x) = \sin(x \cdot y)$ is not separable, so need not have an easy solution. The default method will fail. Looking at the available methods with `sympy.classify_ode(𝐞qn, u(x))` shows a power series method which can return a power series *approximation* (a Taylor polynomial). Let's look at comparing an approximate answer given by the Euler method to that one returned by `SymPy`. +The equation $y'(x) = \sin(x \cdot y)$ is not separable, so need not have an easy solution. The default method will fail. Looking at the available methods with `sympy.classify_ode(𝐞qn, u(x))` shows a power series method which can return a power series *approximation* (a polynomial). Let's look at comparing an approximate answer given by the Euler method to that one returned by `SymPy`. First, the `SymPy` solution: @@ -335,6 +335,71 @@ plot!(u, linewidth=5) We see that the answer found from using a polynomial series matches that of Euler's method for a bit, but as time evolves, the approximate solution given by Euler's method more closely tracks the slope field. +---- + +The [power series method](https://en.wikipedia.org/wiki/Power_series_solution_of_differential_equations) to solve a differential equation starts with an assumption that the solution can be represented as a power series with some positive radius of convergence. This is formally substituted into the differential equation and derivatives may be taken term by term. The resulting coefficients are equated for like powers giving a system of equations to be solved. + +An example of the method applied to the ODE $f''(x) - 2xf'(x) + \lambda f(x)=0$ is given in the reference above and follows below. Assume $f(x) = \sum_{n=0}^\infty a_n x^n$. Then + +$$ +\begin{align*} +f(x) &= \sum_{n=0} a_n x^n\\ +f'(x) &= \sum_{n=1} a_n nx^{n-1}\\ +f''(x) &= \sum_{n=2} a_n n (n-1) x^{n-2}\\ +\end{align*} +$$ + +Putting these into the differential equation gives + +$$ +\begin{align*} +0 &=\sum_{n=2} a_n n (n-1) x^{n-2} +- 2x \cdot \sum_{n=1} a_n n x^{n-1} ++ \lambda \sum_{n=0} a_n x^n\\ +&=\sum_{n=0} a_{n+2} (n+2) (n+1) x^{n} +- \sum_{n=1} 2 n a_n x^{n} ++ \sum_{n=0} \lambda a_n x^n\\ +&= a_2 (1)(2) + \sum_{n=1} a_{n+2} (n+2) (n+1) x^{n} +- \sum_{n=1} 2 a_n n x^n ++ \lambda a_0 + \sum_{n=1} \lambda a_n x^n\\ +&= (\lambda a_0 + 2a_2)\cdot x^0 ++ \sum_{n=1} \left((n+2)(n+1)a_{n+2} + (-2n+\lambda)a_n\right) x^n +\end{align*} +$$ + +For a power series to be $0$ all its coefficients must be zero. This mandates: + +$$ +\begin{align*} +0 &= \lambda a_0 + 2a_2,\quad \text{and} \\ +0 &= ((n+2)(n+1)a_{n+2} + (-2n+\lambda)a_n), \quad \text{for } n \geq 1 +\end{align*} +$$ + +The last equation allows one to compute $a_{n+2}$ based on $a_n$. With $a_0$ and $a_1$ parameters we can create the first few values for the terms in the series for the solution: + +```{julia} +@syms a_0::real a_1::real λ::real +a_2 = -λ/2 * a_0 +recurse(n) = (2n-λ)/((n+2)*(n+1)) +a_3 = expand(recurse(1)*a_1) +a_4 = expand(recurse(2)*a_2) +[a_2, a_3, a_4] +``` + +We can see these terms in the `SymPy` solution which uses the power series method for this differential equation: + +```{julia} +@syms x::real u() +∂ = Differential(x) +eqn = (∂∘∂)(u(x)) - 2*x*∂(u(x)) + λ*u(x) ~ 0 +inits = Dict(u(0) => a_0, ∂(u(x))(0) => a_1) +dsolve(eqn, u(x); ics=inits) +``` + + + + ##### Example @@ -801,3 +866,57 @@ choices = [ answ = 4 radioq(choices, answ, keep_order=true) ``` + +###### Question + +In the above, we noted that a power series that is always zero must have zero coefficients. Why? + +Suppose we have a series $u(x) = \sum_{n=0} a_n x^n$ with a radius of convergence $r > 0$ such that $u(x) = 0$ for $|x| < r$. + +Why is $u^{n}(x) = 0$ for any $n \geq 0$ and $|x| < r$? + +```{julia} +#| echo: false +choices = ["A constant function has derivatives which are constantly zero.", + "A power series is just a number, hence has derivatives which are always zero."] +radioq(choices, 1) +``` + +Answer the following as specifically as possible. + + + +What is the value of $u(0)$? + +```{julia} +#| echo: false +choices = [L"0", L"a_0", L"both $0$ and $a_0$"] +radioq(choices, 3; keep_order=true) +``` + +What is the value of $u'(0)$? + + +```{julia} +#| echo: false +choices = [L"0", L"a_1", L"both $0$ and $a_1$"] +radioq(choices, 3; keep_order=true) +``` + + +What is the value of $u''(0)$? + + +```{julia} +#| echo: false +choices = [L"0", L"2a_2", L"both $0$ and $2a_2$"] +radioq(choices, 3; keep_order=true) +``` + +What is the value of $u^{n}(0)$? + +```{julia} +#| echo: false +choices = [L"0", L"n!\cdot a_n", L"both $0$ and $n!\cdot a_n$"] +radioq(choices, 3; keep_order=true) +``` diff --git a/quarto/_quarto.yml b/quarto/_quarto.yml index 3e2df4c..504bb33 100644 --- a/quarto/_quarto.yml +++ b/quarto/_quarto.yml @@ -1,4 +1,4 @@ -version: "0.24" +version: "0.25" engines: ['julia'] project: @@ -51,6 +51,7 @@ book: chapters: - limits/limits.qmd - limits/limits_extensions.qmd + - limits/sequences_series.qmd - limits/continuity.qmd - limits/intermediate_value_theorem.qmd diff --git a/quarto/derivatives/taylor_series_polynomials.qmd b/quarto/derivatives/taylor_series_polynomials.qmd index 4fed196..3c3c23d 100644 --- a/quarto/derivatives/taylor_series_polynomials.qmd +++ b/quarto/derivatives/taylor_series_polynomials.qmd @@ -1,4 +1,4 @@ -# Taylor polynomials and other approximating polynomials +# Taylor polynomials, series, and approximating polynomials {{< include ../_common_code.qmd >}} @@ -242,7 +242,6 @@ This immediately applies to the above, where we parameterized by $h$: $x_0=c, x_ A proof based on Rolle's theorem appears in the appendix. - ## Quadratic approximations; interpolating polynomials @@ -554,7 +553,7 @@ The output of `series` includes a big "Oh" term, which identifies the scale of t :::{.callout-note} ## Note -A Taylor polynomial of degree $n$ consists of $n+1$ terms and an error term. The "Taylor series" is an *infinite* collection of terms, the first $n+1$ matching the Taylor polynomial of degree $n$. The fact that series are *infinite* means care must be taken when even talking about their existence, unlike a Tyalor polynomial, which is just a polynomial and exists as long as a sufficient number of derivatives are available. +A Taylor polynomial of degree $n$ consists of $n+1$ terms and an error term. The "Taylor series" (below) is an *infinite* collection of terms, the first $n+1$ matching the Taylor polynomial of degree $n$. The fact that series are *infinite* means care must be taken when even talking about their existence, unlike a Taylor polynomial, which is just a polynomial and exists as long as a sufficient number of derivatives are available. ::: @@ -936,6 +935,46 @@ eqns[2] The `solve` function is used to identify $g^{(n)}$ represented in terms of lower-order derivatives of $g$. These values have been computed and stored and are then substituted into `ϕ`. Afterwards a limit is taken and the answer recorded. +## Taylor series + +Recall a *power series* has the form $\sum_{n=0}^\infty a_n (x-c)^n$. Power series have a radius of convergence ($|x - c| < r$) for which the series converges and diverges when $|x-c| > r$. + +The Taylor polynomial formula can be extended to a formal power series with through + +$$ +a_n = \frac{f^{n}(c)}{n!}. +$$ + +If $f(x)$ is equal to the power series within the radius of convergence derivatives of $f(x)$ can be computed by term-by-term differentiation of the power series. The resulting power series will have the same radius of convergence. + +Consider the Taylor series for $\sin(x)$ and $\cos(x)$ about $0$: + +$$ +\begin{align*} +\sin(x) &= x - \frac{x^3}{3!} + \frac{x^5}{5!} + \cdots + (-1)^k\frac{x^{2k+1}}{(2k+1)!} + \cdots ...\\ +\cos(x) &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} + \cdots + (-1)^k\frac{x^{2k}}{(2k)!} + \cdots ...\\ +\end{align*} +$$ + +These both have infinite radius of convergence. Differentiating the power series of $\sin(x)$ term by term gives the power series for $\cos(x)$ as + +$$ +\left[(-1)^k \frac{x^{2k+1}}{(2k+1)!} \right]' = +(-1)^k \frac{(2k+1) x^{2k}}{(2k+1)!} = +(-1)^k \frac{x^{2k}}{(2k)!}. +$$ + +Similarly, as the power series for $\sinh(x)$ and $\cosh(x)$ are the same as the above without the alternating signs produced by the $(-1)^k$ term, the term-by-term differentiation of the power series of $\sinh(x)$ produces $\cosh(x)$ and, in this case, vice versa. + + +The power series for $e^x$ about $0$ has terms $a_k=x^k/k!$. Differentating gives $kx^{k-1}/k! = x^{k-1}/(k-1)!$. The equivalence of the power series for $e^x$ with its term-by-term differentiation requires a simple shift of indices. + +The power series for $1/(1-x)$ has terms $a_i = x^i$ for $i \geq 0$. The radius of convergence is $1$. Differentiating term-by-term yields a power series for $1/(1-x)^2$ is $a_i = (i+1)x^i$ for $i \geq 0$, which will have a radius of convergence of $1$ as well. + +There are examples (the typical one being $f(x) = e^{-1/x^2}$, defined at $0$ to be $0$) where the function has infinitely many derivatives but the power series and the function are not equal beyond a point. In this example, the function is so flat at $0$ that all its derivatives at $0$ are $0$. + + + ## Questions diff --git a/quarto/differentiable_vector_calculus/vector_valued_functions.qmd b/quarto/differentiable_vector_calculus/vector_valued_functions.qmd index ba9650d..035be43 100644 --- a/quarto/differentiable_vector_calculus/vector_valued_functions.qmd +++ b/quarto/differentiable_vector_calculus/vector_valued_functions.qmd @@ -38,9 +38,11 @@ A function $\vec{f}: R \rightarrow R^n$, $n > 1$ is called a vector-valued funct $$ -\vec{f}(t) = \langle \sin(t), 2\cos(t) \rangle, \quad -\vec{g}(t) = \langle \sin(t), \cos(t), t \rangle, \quad -\vec{h}(t) = \langle 2, 3 \rangle + t \cdot \langle 1, 2 \rangle. +\begin{align*} +\vec{f}(t) &= \langle \sin(t), 2\cos(t) \rangle, \\ +\vec{g}(t) &= \langle \sin(t), \cos(t), t \rangle, \\ +\vec{h}(t) &= \langle 2, 3 \rangle + t \cdot \langle 1, 2 \rangle.\\ +\end{align*} $$ The components themselves are also functions of $t$, in this case univariate functions. Depending on the context, it can be useful to view vector-valued functions as a function that returns a vector, or a vector of the component functions. @@ -107,21 +109,22 @@ In `Plots`, the command `plot(xs, ys)`, where, say, `xs=[x1, x2, ..., xn]` and ` Similarly, were a third vector, `zs`, for $z$ components used, `plot(xs, ys, zs)` will make a $3$-dimensional connect the dot plot. -However, our representation of vector-valued functions naturally generates a vector of points: `[[x1,y1], [x2, y2], ..., [xn, yn]]`, as this comes from broadcasting `f` over some time values. That is, for a collection of time values, `ts` the command `f.(ts)` will produce a vector of points. (Technically a vector of vectors, but points if you identify the $2$-$d$ vectors as points.) +However, our representation of vector-valued functions naturally generates a vector of points: `[[x1,y1], [x2, y2], ..., [xn, yn]]`, as this comes from broadcasting `f` over some time values. That is, for a collection of time values, `ts` the command `f.(ts)` will produce a vector of vectors. In `Plots`, a vector of *tuples* will be read as a vector of points and plotted accordingly. On the other hand, a vector of vectors is read in as a number of series, with each element being plotted separately. (That is, `[x1,y1]` maps to `plot!([1,2], [x1,y1])`.) To get the desired graph, *either* our function can return a tuple---which makes it clumsier to work with when manipulating the output---or we can turn a vector of points into two vectors---one with the `x` values, one with the `y` values. -To get the `xs` and `ys` from this is conceptually easy: just iterate over all the points and extract the corresponding component. For example, to get `xs` we would have a command like `[p[1] for p in f.(ts)]`. Similarly, the `ys` would use `p[2]` in place of `p[1]`. The `unzip` function from the `CalculusWithJulia` package does this for us. The name comes from how the `zip` function in base `Julia` takes two vectors and returns a vector of the values paired off. This is the reverse. As previously mentioned, `unzip` uses the `invert` function of the `SplitApplyCombine` package to invert the indexing (the $j$th component of the $i$th point can be referenced by `vs[i][j]` or `invert(vs)[j][i]`). +To get the `xs` and `ys` from this is conceptually easy: just iterate over all the points and extract the corresponding component. For example, to get `xs` we would have a command like `[p[1] for p in f.(ts)]`. Similarly, the `ys` would use `p[2]` in place of `p[1]`. + +The `unzip` function from the `CalculusWithJulia` package does this for us. The name comes from how the `zip` function in base `Julia` takes two vectors and returns a vector of the values paired off. This is the reverse. As previously mentioned, `unzip` uses the `invert` function of the `SplitApplyCombine` package to invert the indexing (the $j$th component of the $i$th point can be referenced by `vs[i][j]` or `invert(vs)[j][i]`). -Visually, we have `unzip` performing this reassociation: - +Visually, we have `unzip` performing this re-association: ```{verbatim} -[[x1, y1, z1], (⌈x1⌉, ⌈y1⌉, ⌈z1⌉, - [x2, y2, z2], |x2|, |y2|, |z2|, - [x3, y3, z3], --> |x3|, |y3|, |z3|, +[[x₁, y₁, z₁], (⌈x₁⌉, ⌈y₁⌉, ⌈z₁⌉, + [x₂, y₂, z₂], |x₂|, |y₂|, |z₂|, + [x₃, y₃, z₃], --> |x₃|, |y₃|, |z₃|, ⋮ ⋮ - [xn, yn, zn]] ⌊xn⌋, ⌊yn⌋, ⌊zn⌋ ) + [xₙ, yₙ, zₙ]] ⌊xₙ⌋, ⌊yₙ⌋, ⌊zₙ⌋ ) ``` To turn a collection of vectors into separate arguments for a function, splatting (the `...`) is used. @@ -175,6 +178,18 @@ ts = range(-2, 2, length=200) plot(unzip(h.(ts))...) ``` +### Using points, not vectors + +As mentioned, there is an alternate manner to plot a vector-valued function that has some conveniences. This is to use a tuple to store the component values. For example: + +```{julia} +g(t) = (cos(t) + 1/5 * cos(5t), sin(t) + 2/3*sin(3t)) +ts = range(0, 2pi, 251) +plot(g.(ts); legend=false, aspect_ratio=:equal) +``` + +Broadcasting `g` creates a vector of tuples, which `Plots` treats as points. The drawback to this approach, as mentioned, is that manipulating the output is generally easily when the function output is a vector. + ### The `plot_parametric` function @@ -229,8 +244,8 @@ For example: #| hold: true a, ecc = 20, 3/4 f(t) = a*(1-ecc^2)/(1 + ecc*cos(t)) * [cos(t), sin(t)] -plot_parametric(0..2pi, f, legend=false) -scatter!([0],[0], markersize=4) +plot_parametric(0..2pi, f; legend=false) +scatter!([(0,0)]; markersize=4) ``` @@ -272,14 +287,14 @@ function spiro(t; r=2, R=5, rho=0.8*r) cent(t) = (R-r) * [cos(t), sin(t)] - p = plot(legend=false, aspect_ratio=:equal) - circle!([0,0], R, color=:blue) - circle!(cent(t), r, color=:black) + p = plot(; legend=false, aspect_ratio=:equal) + circle!([0,0], R; linecolor=:blue) + circle!(cent(t), r; linecolor=:black) - tp(t) = -R/r * t + tp(t) = -R / r * t s(t) = cent(t) + rho * [cos(tp(t)), sin(tp(t))] - plot_parametric!(0..t, s, color=:red) + plot_parametric!(0..t, s; linecolor=:red) p end @@ -479,10 +494,15 @@ f(t) = [3cos(t), 2sin(t)] t, Δt = pi/4, pi/16 df = f(t + Δt) - f(t) -plot(legend=false) -arrow!([0,0], f(t)) -arrow!([0,0], f(t + Δt)) -arrow!(f(t), df) +plot(; legend=false, aspect_ratio=:equal) +plot_parametric!(pi/5..3pi/8, f; line=(:red, 1)) +arrow!([0,0], f(t); line=(:blue,)) +arrow!([0,0], f(t + Δt); line=(:blue,)) +arrow!(f(t), df; line=(:black, 3,0.5)) +annotate!([(f(t)..., text("f(t)", :bottom, :left)), + (f(t+Δt)..., text("f(t + Δt)", :bottom, :left)), + ((f(t) + df/2)..., text("df", :top, :right)), + ]) ``` The length of the difference appears to be related to the length of $\Delta t$, in a similar manner as the univariate derivative. The following limit defines the *derivative* of a vector-valued function: @@ -514,9 +534,12 @@ We can visualize the tangential property through a graph: ```{julia} #| hold: true f(t) = [3cos(t), 2sin(t)] -p = plot_parametric(0..2pi, f, legend=false, aspect_ratio=:equal) +plot(; legend=false, aspect_ratio=:equal) +p = plot_parametric!(0..2pi, f; line=(:black, 1)) for t in [1,2,3] - arrow!(f(t), f'(t)) # add arrow with tail on curve, in direction of derivative + arrow!([0,0], f(t); line=(:gray, 1, 0.5)) + annotate!((2f(t)/3)..., text("f($t)", :top, :left)) + arrow!(f(t), f'(t); line=(:blue, 2)) # add arrow with tail on curve, in direction of derivative end p ``` @@ -528,8 +551,8 @@ Were symbolic expressions used in place of functions, the vector-valued function ```{julia} -@syms 𝒕 -𝒗vf = [cos(𝒕), sin(𝒕), 𝒕] +@syms t +vvf = [cos(t), sin(t), t] ``` We will see working with these expressions is not identical to working with a vector-valued function. @@ -539,7 +562,7 @@ To plot, we can avail ourselves of the the parametric plot syntax. The following ```{julia} -plot(𝒗vf..., 0, 2pi) +plot(vvf..., 0, 2pi) ``` The `unzip` usage, as was done above, could be used, but it would be more trouble in this case. @@ -549,7 +572,7 @@ To evaluate the function at a given value, say $t=2$, we can use `subs` with bro ```{julia} -subs.(𝒗vf, 𝒕=>2) +subs.(vvf, t=>2) ``` Limits are performed component by component, and can also be defined by broadcasting, again with the need to adjust the values: @@ -557,21 +580,21 @@ Limits are performed component by component, and can also be defined by broadcas ```{julia} @syms Δ -limit.((subs.(𝒗vf, 𝒕 => 𝒕 + Δ) - 𝒗vf) / Δ, Δ => 0) +limit.((subs.(vvf, t => t + Δ) - vvf) / Δ, Δ => 0) ``` Derivatives, as was just done through a limit, are a bit more straightforward than evaluation or limit taking, as we won't bump into the shape mismatch when broadcasting: ```{julia} -diff.(𝒗vf, 𝒕) +diff.(vvf, t) ``` The second derivative, can be found through: ```{julia} -diff.(𝒗vf, 𝒕, 𝒕) +diff.(vvf, t, t) # or diff.(vvf, t, 2) ``` ### Applications of the derivative @@ -586,13 +609,13 @@ Here are some sample applications of the derivative. The derivative of a vector-valued function is similar to that of a univariate function, in that it indicates a direction tangent to a curve. The point-slope form offers a straightforward parameterization. We have a point given through the vector-valued function and a direction given by its derivative. (After identifying a vector with its tail at the origin with the point that is the head of the vector.) -With this, the equation is simply $\vec{tl}(t) = \vec{f}(t_0) + \vec{f}'(t_0) \cdot (t - t_0)$, where the dot indicates scalar multiplication. +With this, the equation is simply $\vec{tl}(t) = \vec{f}(t_0) + \cdot (t - t_0) \vec{f}'(t_0) $, where the dot indicates scalar multiplication. ##### Example: parabolic motion -In physics, we learn that the equation $F=ma$ can be used to derive a formula for position, when acceleration, $a$, is a constant. The resulting equation of motion is $x = x_0 + v_0t + (1/2) at^2$. Similarly, if $x(t)$ is a vector-valued position vector, and the *second* derivative, $x''(t) =\vec{a}$, a constant, then we have: $x(t) = \vec{x_0} + \vec{v_0}t + (1/2) \vec{a} t^2$. +In physics, we learn that the equation $F=ma$ can be used to derive a formula for position, when acceleration, $a$, is a constant. The resulting equation of motion is $x(t) = x_0 + v_0t + (1/2) at^2$. Similarly, if $x(t)$ is a vector-valued position vector, and the *second* derivative, $x''(t) =\vec{a}$, a constant, then we have: $x(t) = \vec{x_0} + \vec{v_0}t + (1/2) \vec{a} t^2$. For two dimensions, we have the force due to gravity acts downward, only in the $y$ direction. The acceleration is then $\vec{a} = \langle 0, -g \rangle$. If we start at the origin, with initial velocity $\vec{v_0} = \langle 2, 3\rangle$, then we can plot the trajectory until the object returns to ground ($y=0$) as follows: @@ -606,7 +629,8 @@ xpos(t) = x0 + v0*t + (1/2)*a*t^2 t_0 = find_zero(t -> xpos(t)[2], (1/10, 100)) # find when y=0 -plot_parametric(0..t_0, xpos) +plot(; legend=false) +plot_parametric!(0..t_0, xpos) ``` ```{julia} @@ -797,7 +821,7 @@ The dot being scalar multiplication by the derivative of the univariate function Vector-valued functions do not have multiplication or division defined for them, so there are no ready analogues of the product and quotient rule. However, the dot product and the cross product produce new functions that may have derivative rules available. -For the dot product, the combination $\vec{f}(t) \cdot \vec{g}(t)$ we have a univariate function of $t$, so we know a derivative is well defined. Can it be represented in terms of the vector-valued functions? In terms of the component functions, we have this calculation specific to $n=2$, but that which can be generalized: +For the dot product, the combination $\vec{f}(t) \cdot \vec{g}(t)$ creates a univariate function of $t$, so we know a derivative is well defined. Can it be represented in terms of the vector-valued functions? In terms of the component functions, we have this calculation specific to $n=2$, but that which can be generalized: $$ @@ -842,8 +866,8 @@ In summary, these two derivative formulas hold for vector-valued functions $R \r $$ \begin{align*} -(\vec{u} \cdot \vec{v})' &= \vec{u}' \cdot \vec{v} + \vec{u} \cdot \vec{v}',\\ -(\vec{u} \times \vec{v})' &= \vec{u}' \times \vec{v} + \vec{u} \times \vec{v}'. +(\vec{u} \cdot \vec{v})' &= \vec{u}' \cdot \vec{v} + \vec{u} \cdot \vec{v}', \\ +(\vec{u} \times \vec{v})' &= \vec{u}' \times \vec{v} + \vec{u} \times \vec{v}'\qaud (n=3). \end{align*} $$ @@ -892,7 +916,9 @@ $$ \vec{F} = m \vec{a} = m \ddot{\vec{x}}. $$ -Combining, Newton states $\vec{a} = -(GM/r^2) \hat{x}$. +(The double dot is notation for two derivatives in a $t$ variable.) + +Combining, Newton's law states $\vec{a} = -(GM/r^2) \hat{x}$. Now to show the first law. Consider $\vec{x} \times \vec{v}$. It is constant, as: @@ -901,7 +927,8 @@ Now to show the first law. Consider $\vec{x} \times \vec{v}$. It is constant, as $$ \begin{align*} (\vec{x} \times \vec{v})' &= \vec{x}' \times \vec{v} + \vec{x} \times \vec{v}'\\ -&= \vec{v} \times \vec{v} + \vec{x} \times \vec{a}. +&= \vec{v} \times \vec{v} + \vec{x} \times \vec{a}\\ +&= 0. \end{align*} $$ @@ -1000,7 +1027,7 @@ c^2 &= \|\vec{c}\|^2 \\ $$ -Solving, this gives the first law. That is, the radial distance is in the form of an ellipse: +Solving for $r$, this gives the first law. That is, the radial distance is in the form of an ellipse: $$ @@ -1231,23 +1258,25 @@ p --- +::: {.callout-note appearance="minimal"} +## Curvature of a space curve The *curvature* of a $3$-dimensional space curve is defined by: -> *The curvature*: For a $3-D$ curve the curvature is defined by: -> -> $\kappa = \frac{\| r'(t) \times r''(t) \|}{\| r'(t) \|^3}.$ +$$ +\kappa = \frac{\| r'(t) \times r''(t) \|}{\| r'(t) \|^3}. +$$ - - -For $2$-dimensional space curves, the same formula applies after embedding a $0$ third component. It can also be expressed directly as +For $2$-dimensional space curves, the same formula applies after embedding a $0$ third component. It simplifies to: $$ \kappa = (x'y''-x''y')/\|r'\|^3. \quad (r(t) =\langle x(t), y(t) \rangle) $$ -Curvature can also be defined as derivative of the tangent vector, $\hat{T}$, *when* the curve is parameterized by arc length, a topic still to be taken up. The vector $\vec{r}'(t)$ is the direction of motion, whereas $\vec{r}''(t)$ indicates how fast and in what direction this is changing. For curves with little curve in them, the two will be nearly parallel and the cross product small (reflecting the presence of $\sin(\theta)$ in the definition). For "curvy" curves, $\vec{r}''$ will be in a direction orthogonal of $\vec{r}'$ to the $\sin(\theta)$ term in the cross product will be closer to $1$. +::: + +Curvature can also be defined by the derivative of the tangent vector, $\hat{T}$, *when* the curve is parameterized by arc length, a topic still to be taken up. The vector $\vec{r}'(t)$ is the direction of motion, whereas $\vec{r}''(t)$ indicates how fast and in what direction this is changing. For curves with little curve in them, the two will be nearly parallel and the cross product small (reflecting the presence of $\sin(\theta)$ in the definition). For "curvy" curves, $\vec{r}''$ will be in a direction orthogonal of $\vec{r}'$ to the $\sin(\theta)$ term in the cross product will be closer to $1$. Let $\vec{r}(t) = k \cdot \langle \cos(t), \sin(t), 0 \rangle$. This will have curvature: @@ -1269,17 +1298,16 @@ If a curve is imagined to have a tangent "circle" (second order Taylor series ap The [torsion](https://en.wikipedia.org/wiki/Torsion_of_a_curve), $\tau$, of a space curve ($n=3$), is a measure of how sharply the curve is twisting out of the plane of curvature. +::: {.callout-note appearance="minimal} +## Torsion of a space curve The torsion is defined for smooth curves by - -> *The torsion*: -> -> $\tau = \frac{(\vec{r}' \times \vec{r}'') \cdot \vec{r}'''}{\|\vec{r}' \times \vec{r}''\|^2}.$ - - +$$ +\tau = \frac{(\vec{r}' \times \vec{r}'') \cdot \vec{r}'''}{\|\vec{r}' \times \vec{r}''\|^2}. +$$ For the torsion to be defined, the cross product $\vec{r}' \times \vec{r}''$ must be non zero, that is the two must not be parallel or zero. - +::: ##### Example: Tubular surface @@ -1294,7 +1322,7 @@ This last example comes from a collection of several [examples](https://github.c The task is to illustrate a space curve, $c(t)$, using a tubular surface. At each time point $t$, assume the curve has tangent, $e_1$; normal, $e_2$; and binormal, $e_3$. (This assumes the defining derivatives exist and are non-zero and the cross product in the torsion is non zero.) The tubular surface is a circle of radius $\epsilon$ in the plane determined by the normal and binormal. This curve would be parameterized by $r(t,u) = c(t) + \epsilon (e_2(t) \cdot \cos(u) + e_3(t) \cdot \sin(u))$ for varying $u$. -The Frenet-Serret equations setup a system of differential equations driven by the curvature and torsion. We use the `DifferentialEquations` package to solve this equation for two specific functions and a given initial condition. The equations when expanded into coordinates become $12$ different equations: +The Frenet-Serret equations describe the relationship between tangent, normal, and binormal vectors through a system of differential equations driven by the curvature and torsion. Their derivation will be discussed later, here we give an example usage by using the `DifferentialEquations` package to solve these equations for a specific curvature and torsion function and given initial conditions. The vector equations along with the relationship between the space curve and its tangent vector---when expanded into coordinates---become $12$ different equations: ```{julia} @@ -1316,7 +1344,7 @@ function Frenet_eq!(du, u, p, s) #system of ODEs end ``` -The last set of equations describe the motion of the spine. It follows from specifying the tangent to the curve is $e_1$, as desired; it is parameterized by arc length, as $\mid c'(t) \mid = 1$. +The last set of equations describe the motion of the spine. It follows from specifying the tangent to the curve is $e_1$, as desired (it is parameterized by arc length, as $\lVert c'(t) \rVert = 1$). Following the example of `@empet`, we define a curvature function and torsion function, the latter a constant: @@ -1345,7 +1373,7 @@ prob = ODEProblem(Frenet_eq!, u0, t_span, (κ, τ)) sol = solve(prob, Tsit5()); ``` -The "spine" is the center axis of the tube and is the $10$th, $11$th, and $12$th coordinates: +The "spine" is the center axis of the tube and is described by the $10$th, $11$th, and $12$th coordinates: ```{julia} @@ -1372,14 +1400,15 @@ ts_0 = range(a_0, b_0, length=251) t_0 = (a_0 + b_0) / 2 ϵ = 1/5 -plot_parametric(a_0..b_0, spine) +plot(; legend=false) +plot_parametric!(a_0..b_0, spine; line=(:black, 2)) -arrow!(spine(t_0), e₁(t_0)) -arrow!(spine(t_0), e₂(t_0)) -arrow!(spine(t_0), e₃(t_0)) +arrow!(spine(t_0), e₁(t_0); line=(:blue,)) +arrow!(spine(t_0), e₂(t_0); line=(:red,)) +arrow!(spine(t_0), e₃(t_0); line=(:green,)) r_0(t, θ) = spine(t) + ϵ * (e₂(t)*cos(θ) + e₃(t)*sin(θ)) -plot_parametric!(0..2pi, θ -> r_0(t_0, θ)) +plot_parametric!(0..2pi, θ -> r_0(t_0, θ); line=(:black, 1)) ``` The `ϵ` value determines the radius of the tube; we see it above as the radius of the drawn circle. The function `r` for a fixed `t` traces out such a circle centered at a point on the spine. For a fixed `θ`, the function `r` describes a line on the surface of the tube paralleling the spine. @@ -1475,7 +1504,7 @@ speed = simplify(norm(diff.(viviani(t, a), t))) integrate(speed, (t, 0, 4*PI)) ``` -We see that the answer depends linearly on $a$, but otherwise is a constant expressed as an integral. We use `QuadGk` to provide a numeric answer for the case $a=1$: +We see that the answer depends linearly on $a$, but otherwise is a constant involving an integral. We use `QuadGk` to provide a numeric answer for the case $a=1$: ```{julia} @@ -1573,7 +1602,7 @@ This should be $\kappa \hat{N}$, so we do: ```{julia} κₕ = norm(outₕ) |> simplify Normₕ = outₕ / κₕ -κₕ, Normₕ +κₕ ``` Interpreting, $a$ is the radius of the circle and $b$ how tight the coils are. If $a$ gets much larger than $b$, then the curvature is like $1/a$, just as with a circle. If $b$ gets very big, then the trajectory looks more stretched out and the curvature gets smaller. @@ -1778,13 +1807,13 @@ Xₑ(t)= 2 * cos(t) Yₑ(t) = sin(t) rₑ(t) = [Xₑ(t), Yₑ(t)] unit_vec(x) = x / norm(x) -plot(legend=false, aspect_ratio=:equal) +plot(; legend=false, aspect_ratio=:equal) ts = range(0, 2pi, length=50) for t in ts Pₑ, Vₑ = rₑ(t), unit_vec([-Yₑ'(t), Xₑ'(t)]) - plot_parametric!(-4..4, x -> Pₑ + x*Vₑ) + plot_parametric!(-4..4, x -> Pₑ + x*Vₑ; line=(:black, 1)) end -plot!(Xₑ, Yₑ, 0, 2pi, linewidth=5) +plot!(Xₑ, Yₑ, 0, 2pi, line=(:red, 5)) ``` is that of an ellipse with many *normal* lines drawn to it. The normal lines appear to intersect in a somewhat diamond-shaped curve. This curve is the evolute of the ellipse. We can characterize this using the language of planar curves. @@ -1858,8 +1887,10 @@ Tangent(r, t) = unit_vec(r'(t)) Normal(r, t) = unit_vec((𝒕 -> Tangent(r, 𝒕))'(t)) curvature(r, t) = norm(r'(t) × r''(t) ) / norm(r'(t))^3 -plot_parametric(0..2pi, t -> rₑ₃(t)[1:2], legend=false, aspect_ratio=:equal) -plot_parametric!(0..2pi, t -> (rₑ₃(t) + Normal(rₑ₃, t)/curvature(rₑ₃, t))[1:2]) +plot(; legend=false, aspect_ratio=:equal, xlims=(-6,6), ylims=(-5,5)) +plot_parametric!(0..2pi, t -> rₑ₃(t)[1:2]; line=(:red,5)) +plot_parametric!(0..2pi, t -> (rₑ₃(t) + Normal(rₑ₃, t)/curvature(rₑ₃, t))[1:2]; + line=(:black, 1)) ``` We computed the above illustration using $3$ dimensions (hence the use of `[1:2]...`) as the curvature formula is easier to express. Recall, the curvature also appears in the [Frenet-Serret](https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas) formulas: $d\hat{T}/ds = \kappa \hat{N}$ and $d\hat{N}/ds = -\kappa \hat{T}+ \tau \hat{B}$. In a planar curve, as under consideration, the binormal is $\vec{0}$. This allows the computation of $\vec\beta(s)'$: @@ -1877,6 +1908,7 @@ $$ We see $\vec\beta'$ is zero (the curve is non-regular) when $\kappa'(s) = 0$. The curvature changes from increasing to decreasing, or vice versa at each of the $4$ crossings of the major and minor axes--there are $4$ non-regular points, and we see $4$ cusps in the evolute. +---- The curve parameterized by $\vec{r}(t) = 2(1 - \cos(t)) \langle \cos(t), \sin(t)\rangle$ over $[0,2\pi]$ is cardiod. It is formed by rolling a circle of radius $r$ around another similar sized circle. The following graphically shows the evolute is a smaller cardiod (one-third the size). For fun, the evolute of the evolute is drawn: @@ -1891,10 +1923,10 @@ end #| hold: trie r(t) = 2*(1 - cos(t)) * [cos(t), sin(t), 0] -plot(legend=false, aspect_ratio=:equal) -plot_parametric!(0..2pi, t -> r(t)[1:2]) -plot_parametric!(0..2pi, t -> evolute(r)(t)[1:2]) -plot_parametric!(0..2pi, t -> ((evolute∘evolute)(r)(t))[1:2]) +plot(; legend=false, aspect_ratio=:equal) +plot_parametric!(0..2pi, t -> r(t)[1:2]; line=(:black, 1)) +plot_parametric!(0..2pi, t -> evolute(r)(t)[1:2]; line=(:red, 1)) +plot_parametric!(0..2pi, t -> ((evolute∘evolute)(r)(t))[1:2]; line=(:blue,1)) ``` --- @@ -1911,9 +1943,10 @@ a = t1 beta(r, t) = r(t) - Tangent(r, t) * quadgk(t -> norm(r'(t)), a, t)[1] -p = plot_parametric(-2..2, r, legend=false) -plot_parametric!(t0..t1, t -> beta(r, t)) -for t in range(t0,-0.2, length=4) +p = plot(; legend=false) +plot_parametric!(-2..2, r; line=(:black, 1)) +plot_parametric!(t0..t1, t -> beta(r, t); line=(:red,1)) +for t in range(t0, -0.2, length=4) arrow!(r(t), -Tangent(r, t) * quadgk(t -> norm(r'(t)), a, t)[1]) scatter!(unzip([r(t)])...) end @@ -1924,14 +1957,15 @@ This lends itself to this mathematical description, if $\vec\gamma(t)$ parameter $$ -\vec\beta(t) = \vec\gamma(t) + \left((a - \int_{t_0}^t \| \vec\gamma'(t)\| dt) \hat{T}(t)\right), +\vec\beta(t) = \vec\gamma(t) + \left(a - \int_{t_0}^t \| \vec\gamma'(t)\| dt\right) \hat{T}(t), $$ where $\hat{T}(t) = \vec\gamma'(t)/\|\vec\gamma'(t)\|$ is the unit tangent vector. The above uses two parameters ($a$ and $t_0$), but only one is needed, as there is an obvious redundancy (a point can *also* be expressed by $t$ and the shortened length of string). [Wikipedia](https://en.wikipedia.org/wiki/Involute) uses this definition for $a$ and $t$ values in an interval $[t_0, t_1]$: $$ -\vec\beta_a(t) = \vec\gamma(t) - \frac{\vec\gamma'(t)}{\|\vec\gamma'(t)\|}\int_a^t \|\vec\gamma'(t)\| dt. +\vec\beta_a(t) = \vec\gamma(t) - +\frac{\vec\gamma'(t)}{\|\vec\gamma'(t)\|}\int_a^t \|\vec\gamma'(t)\| dt. $$ If $\vec\gamma(s)$ is parameterized by arc length, then this simplifies quite a bit, as the unit tangent is just $\vec\gamma'(s)$ and the remaining arc length just $(s-a)$: @@ -1989,7 +2023,7 @@ $$ $$ -That is the evolute of an involute of $\vec\gamma(s)$ is $\vec\gamma(s)$. +That is, the evolute of an involute of $\vec\gamma(s)$ is $\vec\gamma(s)$. We have: @@ -2041,8 +2075,9 @@ speed = 2sin(t/2) ex = r(t) - rp/speed * integrate(speed, t) -plot_parametric(0..4pi, r, legend=false) -plot_parametric!(0..4pi, u -> float.(subs.(ex, t .=> u))) +plot(; legend=false) +plot_parametric!(0..4pi, r; line=(:black, 1)) +plot_parametric!(0..4pi, u -> float(subs.(ex, t => u)); line=(:blue, 1)) ``` The expression `ex` is secretly `[t + sin(t), 3 + cos(t)]`, another cycloid. diff --git a/quarto/integrals/improper_integrals.qmd b/quarto/integrals/improper_integrals.qmd index 887be19..0cf16b3 100644 --- a/quarto/integrals/improper_integrals.qmd +++ b/quarto/integrals/improper_integrals.qmd @@ -421,6 +421,125 @@ We want to just say $F'(x)= e^{-x}$ so $f(x) = e^{-x}$. But some care is needed. Finally, at $x=0$ we have an issue, as $F'(0)$ does not exist. The left limit of the secant line approximation is $0$, the right limit of the secant line approximation is $1$. So, we can take $f(x) = e^{-x}$ for $x > 0$ and $0$ otherwise, noting that redefining $f(x)$ at a point will not effect the integral as long as the point is finite. +## Application to series + + +In this application, we compare a series to a related integral to decide convergence or divergence of the series. + +:::{.callout-note appearance="minimal"} +#### The integral test +Consider a continuous, monotone decreasing function $f(x)$ defined on some interval of the form $[N,\infty)$. Let $a_n = f(n)$ and $s_n = \sum_{k=N}^n a_n$. + +* If $\int_N^\infty f(x) dx < \infty$ then the partial sums converge. +* If $\int_N^\infty f(x) dx = \infty$ then the partial sums diverge. +::: + +By the monotone nature of $f(x)$, we have on any interval of the type $[i, i+1)$ for $i$ an integer, that $f(i) \geq f(x) \geq f(i+1)$ when $x$ is in the interval. For integrals, this leads to + +$$ +f(i) = \int_i^{i+1} f(i) dx +\geq \int_i^{i+1} f(x) dx +\geq \int_i^{i+1} f(i+1) dx = f(i+1) +$$ + +Now if $N$ is an integer we have + +$$ +\int_N^\infty f(x) dx = \sum_{i=N}^\infty \int_i^{i+1} f(x) dx +$$ + +This translates to this bound + +$$ +\sum_{i=N}^\infty f(i) +\leq \int_N^\infty f(x) dx +\leq \sum_{i=N}^\infty f(i+1) = \sum_{i=N+1}^\infty f(i) +$$ + +If the integral converges, the first inequality implies the series converges; if the integral diverges, the second inequality implies the series diverges. + +### Example + +The $p$-series test is an immediate consequence, as the integral + +$$ +\int_1^\infty \frac{1}{x^p} dx +$$ + +converges when $p>1$ and diverges when $p \leq 1$. + +### Example +Let + +$$ +a_n = \frac{1}{n \cdot \ln(n) \cdot \ln(\ln(n))^2} +$$ + +Does $\sum a_n$ *converge*? + +We use `SymPy` to integrate: + +```{julia} +@syms x::real +f(x) = 1 / (x * log(x) * log(log(x))^2) +integrate(f(x), (x, 3^2, oo)) +``` + +That this is finite shows the series converges. + +--- + +The integral of a power series can be computed easily for some $x$: + +:::{.callout-note appearance="minimal"} +### The integral of a power series + +Suppose $f(x) = \sum_n a_n (x-c)^n$ is a power series about $x=c$ with radius of convergence $r > 0$. [Then](https://en.wikipedia.org/wiki/Power_series#Differentiation_and_integration) the limits of the integral and the sum can be switched around when $x$ is within the radius of convergence: + +$$ +\begin{align*} +\int f(x) dx +&= \int \sum_n a_n(x-c)^n dx\\ +&= \sum_{n=0}^\infty \int a_n(x-c)^n dx\\ += \sum_{n=0}^\infty a_n \frac{(x-c)^{n+1}}{n+1} +\end{align*} +$$ + +The radius of convergence of this new power series is also $r$. +::: + + +This geometric series has a well known value ($|r| < 1$): + +$$ +\frac{1}{1-r} = 1 + r + r^2 + \cdots +$$ + +This gives rise to + +$$ +\ln(1 - r) = -(r + r^2/2 + r^3/3 + \cdots). +$$ + +The power series for $e^x$ is + +$$ +e^x = \sum_{n=0}^\infty \frac{x^n}{n!} +$$ + +This has integral then given by + +$$ +\int e^x dx = \sum_{n=0}^\infty \frac{x^{n+1}}{n+1}\frac{1}{n!} += \sum_{n=0}^\infty \frac{x^{n+1}}{(n+1)!} += \sum_{n=1}^\infty \frac{x^n}{n!} += e^x - 1 +$$ + +The $-1$ is just a constant so the antiderivative of $e^x$ is $e^x$. + + + ## Questions diff --git a/quarto/limits/figures/mona-lisa-recursive.png b/quarto/limits/figures/mona-lisa-recursive.png new file mode 100644 index 0000000..9543c7c Binary files /dev/null and b/quarto/limits/figures/mona-lisa-recursive.png differ diff --git a/quarto/limits/limits_extensions.qmd b/quarto/limits/limits_extensions.qmd index 0dd4c2a..045640c 100644 --- a/quarto/limits/limits_extensions.qmd +++ b/quarto/limits/limits_extensions.qmd @@ -461,16 +461,6 @@ $$ 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-Weierstrass) - * 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 diff --git a/quarto/limits/sequences_series.qmd b/quarto/limits/sequences_series.qmd new file mode 100644 index 0000000..ef3bc29 --- /dev/null +++ b/quarto/limits/sequences_series.qmd @@ -0,0 +1,1178 @@ +# Sequences and series + +{{< include ../_common_code.qmd >}} + + +This section uses the following add-on package: + + +```{julia} +using SymPy +``` + +```{julia} +#| echo: false +#| results: "hidden" +using Plots +using LaTeXStrings +plotly() +nothing +``` + +--- + +![Smaller and smaller and smaller..., the [Droste effect](https://en.wikipedia.org/wiki/Droste_effect)](./figures/mona-lisa-recursive.png) + +This section expands on limits of infinite sequences and their sums. + + +## Definitions + +An infinite sequence is simply an infinite, ordered set of terms $a_1, a_2, a_3, \dots$; the initial term may be indexed by any fixed integer, not just $1$. We may refer to the individual terms, $a_n$, or the whole sequence $\{a_n\}$. + +The *partial sum* is the sequence $s_n = a_1 + a_2 + \cdots + a_n = \sum_{i=1}^na_i$. Again, the starting index need not be $1$. + +A series is a sum of an infinite sequence $\sum_{i=1}^\infty a_i = a_1 + a_2 + a_3 + \cdots$. + +As mentioned, a sequence converges to $L$ if for any $\epsilon$ we can find an $M$ such that if $n > M$ then $|a_n - L| < \epsilon$. A non-convergent sequence is called *divergent*. Series too may be convergent of divergent, with details to come. + + +## Examples + + +Some examples of sequences are: + +* A constant sequence $a_n = c$ will converge to $c$. +* The sequence $a_n = 1/n$ clearly converges to $0$. +* Similarly, $a_n = n^k$ diverges if $k \geq 0$ and converges (to $0$) when $k < 0$. +* The sequence $(1 + 1/n)^n$ has a limit of $e$, which comes up in compound interest calculations and numerous other places. This limit can be used to define the value of $e$. +* The sequence $a_n = r^n$ will converge to $0$ if $|r| < 1$; converge to $1$ when $r=1$ and diverge otherwise. +* The sequence $a_n = \cos(n \pi)$, $n\geq 1$ diverges. It is said to oscillate. (It is $-1,1,-1,1,-1,\dots$.) + + + +### Some limit theorems for sequences + +The limit theorems apply to limits of sequences as well: + +:::{.callout-note appearance="minimal"} +#### The squeeze theorem + +If $l_n < a_n < r_n$ and *both* $l_n$ and $r_n$ converge to $L$ then $a_n$ converges to $L$. +::: + +:::{.callout-note appearance="minimal"} +#### Linear combinations +If $a_n \rightarrow L$ and $b_n \rightarrow M$ then for constants $c$ and $d$: +$c\cdot a_n + d \cdot b_n \rightarrow c\cdot L + d\cdot M$. +::: + +:::{.callout-note appearance="minimal"} +#### Products and ratios +If $a_n \rightarrow L$ and $b_n \rightarrow M$ +$a_n \cdot b_n \rightarrow LM$ and if $M != 0$ +$a_n / b_n \rightarrow L/M$. +::: + +:::{.callout-note appearance="minimal"} +#### Composition +If the function $f(x)$ has a limit of $L$ at $b$ and +$a_n$ converges to $b$ *and* $a_n \neq b$ for large $n$ then + +$$ +\lim_{n \rightarrow \infty} f(a_n) = L. +$$ + +::: + +#### Other limit theorems + +We mention a few other limit theorems for sequences. + +One fact about convergent series is + +> Convergent series are bounded. + +(That is, there exists an $M>0$ with $-M \leq a_n \leq M$ for all $n$.) + + +Not all bounded sequences converge; however: + +:::{.callout-note appearance="minimal"} +##### Bounded and monotone +If $a_n$ is monotone increasing ($a_n \leq a_{n+1}$ for all $n$) and *bounded* then $a_n$ converges. + +This is a [monotone convergence theorem](https://en.wikipedia.org/wiki/Monotone_convergence_theorem). It's proof shows the least upper bound is the limit. A similar statement holds for bounded, monotone decreasing sequences. +::: + +The sequence $a_n = (1 + 1/n)^n$ is both monotone increasing and bounded, hence convergent. As mentioned, it converges to $e$. That this limit has a known value is not a result of the theorem, which only says some value exists. + + + +A *subsequence* of an infinite sequence is an infinite sequence chosen by taking only some of the terms (along the same order). A simple example would be $b_n = a_{2n}$, which would take every other term of the sequence $\{a_n\}$. More generally if $\phi(n)$ is an increasing function with integer values, then $b_n = a_{\phi(n)}$ would be a formal way to define a subsequence. + +:::{.callout-note appearance="minimal"} +##### Bolzano-Weierstrass theorem + +Every bounded sequence has a convergent subsequence. +::: + +A sketch is to consider the interval $I_1 = [-M,M]$. It has infinitely many values of the sequence in it when $M$ is a bound. Divide this interval in half. There is a choice of $I_2$ so that it also contains infinitely many points of the sequence. (Maybe both do, in which case either choice can be made.) This splitting and choosing can be repeated to create an infinite sequence of *nested* intervals $\{I_n\}$ each containing infinitely many points of $\{a_n\}$ and each of length $M/2^{n-2}$. As these intervals are nested the left-hand endpoints are bounded and increasing, hence convergent. + +There may be many different convergent subsequences, this just identified one. + +Finally, this following fact can be used to reverse the pedagogical approach of defining limits by starting with limits restricted to sequences. + +:::{.callout-note appearance="minimal"} +##### Limits of functions + +The limit of $f(x)$ 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$. +::: + + +## Series + +As defined, a series is an *infinite* sum of a sequence: $a_1 + a_2 + \cdots$. The partial sums of a sequence are $s_n = a_1 + a_2 + \cdots + a_n$. The series is *convergent* (*divergent*) if the sequence of partial sums, $\{ s_n \}$, is convergent (*divergent*). + +##### Example: the geometric series + +A ubiquitous series is the *geometric series* for a value of $r$. This is the sum $s = \sum_{i=0}^\infty r^i$. The partial sums satisfy + +$$ +s_n = \sum_{i=0}^n r^i = 1 + r + r^2 + \cdots + r^n += \frac{1 - r^{n+1}}{1 - r}, +$$ + +a formula that comes from multiplying out the sum by $1-r$. + +If $|r| < 1$ then $s$ is convergent and $s_n \rightarrow (1 - r)^{-1}$. If $|r| \geq 1$ the series is divergent. + + +##### Example: geometric series adjacent + +Consider now a related sum $s = \sum_{i=0}^\infty i \cdot r^i = \sum_{i=1}^\infty i \cdot r^i$, assuming $|r| < 1$. What does this converge to? + +The partial sums also have a (lesser) known formula: + +$$ +\sum_{i=1}^n i\cdot r^i = +r \frac{1 - (n+1)r^n + nr^{n+1}}{(1 - r)^2}. +$$ + +We verify this with `SymPy` + +```{julia} +@syms r::positive n::integer i::integer +proposed = r * (1 - (n+1)*r^n + n*r^(n+1))/(1-r)^2 +out = summation(i*r^i, (i, 1, n)) - proposed +simplify(out) +``` + +We can't set a *value* for `r` symbolically and were `r=1` this sum is different, but we have $|r| < 1$ so the proposed is indeed the partial sum. + +As $n \rightarrow \infty$ for $|r| < 1$ this expression goes to $s = r / (1-r)^2$. It would diverge otherwise. + + +##### Example: Sum of inverse factorials + +Consider these two sequences: + +$$ +s_n = \sum_{k=0}^n \frac{1}{k!}, \quad +p_n = \left(1 + \frac{1}{n}\right)^n +$$ + +We know $p_n \rightarrow e$. We will see that it also follows that $s_n \rightarrow e$. That is the series for the sequence $a_k = 1/k!$ converges to $e$. + +First we see that $e$ is in the ballpark. + +We bound each term of $s_n$ for $k \geq 2$ + +$$ +a_k = \frac{1}{k!} \leq \frac{1}{(k(k-1))} = \frac{1}{k-1} - \frac{1}{k}, +$$ + +With this, we can identify a telescoping sum: + +$$ +\begin{align*} +s_n &= \sum_{k=0}^n a_k\\ +&= a_0 + a_1 + \sum_{k=2}^n a_k\\ +&\leq 2 + \sum_{k=2}^n \left(\frac{1}{k-1} - \frac{1}{k}\right) \\ +&= 2 + \left(\frac{1}{1} - \frac{1}{n}\right) = 3 - \frac{1}{n} < 3. +\end{align*} +$$ + +This is in agreement with $s = e$. To get that value takes more effort and different bounds. + + + + +The binomial theorem applied to $p_n$ gives: + +$$ +\begin{align*} +p_n &= \left(1 + \frac{1}{n}\right)^n\\ +&= \sum_{k=0}^n {n \choose k} \frac{1}{n^k} 1^{n-k}\\ +&= \sum_{k=0}^n \frac{n!}{k!(n-k)!}\frac{1}{n^k}\\ +&= \sum_{k=0}^n \frac{1}{k!}\frac{n!}{(n-k)!}\frac{1}{n^k}\\ +&= \sum_{k=0}^n \frac{1}{k!} \cdot \left(1 - \frac{1}{n}\right) \cdot \left(1-\frac{2}{n}\right) \cdot \cdots \cdot \left(1 - \frac{k-1}{n}\right)\\ +&= \sum_{k=0}^n \frac{1}{k!} b_{n,k} +\end{align*} +$$ + +We see that $p_n \leq s_n$ by noting $b_{n,k} \leq 1$ as each term in it is. + + + +Next, [following](https://faculty.curgus.wwu.edu/Courses/226_202040/two_sequences_cmj.pdf) a reference, we establish the bound $s_n - 3/(2n) \leq p_n$. + +We have by multiplying out: + +$$ +\left(1 - \frac{1}{n}\right) \left(1 - \frac{2}{n}\right) = +1 - \frac{1 + 2}{n} + \frac{1\cdot 2}{n} > +1 - \frac{1 + 2}{n}. +$$ + +Assume this pattern holds for some $k$, then we have the induction step + +$$ +\begin{align*} +\left(1 - \frac{1}{n}\right) &\left(1 - \frac{2}{n}\right)\cdot\left(1 - \frac{k}{n}\right)\cdot\left(1 - \frac{k+1}{n}\right)\\ +&> \left(1 - \frac{1 + 2 + \cdots + k}{n}\right)\left(1 + \frac{k+1}{n}\right)\\ +&= 1 - \frac{1 + 2 + \cdots + k + (k+1)}{n} + \frac{(1+2+\cdots+k)(k+1)}{n}\\ +&> 1 - \frac{1 + 2 + \cdots + k + (k+1)}{n} +\end{align*} +$$ + +So the inequality holds for any $k$ by induction. In our bound for $b_{n,k}$ we have this sum $1 + 2 + \cdots + (k-1) = (k-1)k/2$. Together this gives: + +$$ +\begin{align*} +p_n &= \sum_{k=0}^n \frac{1}{k!}b_{n,l}\\ +&> \sum_{k=0}^n \frac{1}{k!} \cdot \left(1 - \frac{(k-1)k}{2n}\right)\\ +&= s_n - \sum_{k=0}^n \frac{1}{k!}\frac{(k-1)k}{2n}\\ +&= s_n - \frac{1}{2n} \sum_{k=2}^n \frac{1}{(k-2)!}\\ +&= s_n - \frac{1}{2n} s_{n-2} +$> s_n - \frac{3}{2n} +\end{align*} +$$ + +The last inequality using the earlier bound on $s_n$. + +Together these observations give the bounds: + +$$ +s_n - 3/(2n) \leq p_n \leq s_n \leq p_n + 3/(2n). +$$ + +If we know $p_n \rightarrow e$, then by the squeeze theorem, we get $s_n \rightarrow e$. + + +### Non-negative terms + +The examples above required a bit of problem-specific work to get a value for a series. + +Sometimes the value isn't important---just the question of convergence is. +There are some general things that are the case for series to understand convergence. + +First we consider only sequences with non-negative terms. + +:::{.callout-note appearance="minimal"} +##### Necessary condition for convergence +If $a_n \geq 0$ for each $n$ then a necessary condition that $s_n \rightarrow s$ is that $a_n \rightarrow 0$. +::: + +This says if $a_n$ does not coverge to $0$ then $s_n$ diverges. It is definitely not the case that a sequence that converges to $0$ will lend itself to a convergent series. A famous example would be $\sum_{i=1}^n 1/i$ which diverges. The partial sums of this series are termed the [harmonic series](https://tinyurl.com/ua4893w5) and have the property that $s_n = \ln(n) + \gamma + 1/(2n) + \epsilon_n$ where $e_n \rightarrow 0$ and $\gamma \approx 0.5772$ is a constant termed the Euler-Mascheroni constant. (See `MathConstants.γ`.) + + +:::{.callout-note appearance="minimal"} +##### Only the tail terms determine convergence +Convergence of $\sum_n a_n$ only depends on the terms for $n > N$ for any fixed $N$. + +Only the tail terms determine convergence, but every term determines the value of the series when it converges. +::: + +Fix any $N > 0$, the partial sums with $n>N$ satisfy: + +$$ +s_n = \sum_{k=1}^n a_k +=\sum_{k=1}^N a_k + \sum_{k=N}^n a_k += s_N + (s_n - s_N) +$$ + +The limit as $n \rightarrow \infty$ does not depend on the constant $s_N$. + + + +:::{.callout-note appearance="minimal"} +##### Comparison test +If $0 \leq c_n \leq a_n \leq b_n$ for each $n$ then + +* if $\sum_{i=1}^n b_i$ converges then $\sum_{i=0}^n a_i$ converges; + +* if $\sum_{i=1}^n c_i$ diverges then $\sum_{i=0}^n a_i$ diverges. +::: + +This can be used to prove, for example, that if a series based on a non-negative sequence converges, any series based on a subsequence will also converge. + +##### Example + +Does the following sequence of partial sums converge of diverge: + +$$ +s_n = \sum_{i=1}^n \frac{i}{i^2 - i^{-3}}? +$$ + +Diverge. We can see that the $i$th term is bounded below: + +$$ +\frac{i}{i^2 - i^{-3}} = \frac{1}{i^1 - i^{-4}} +> \frac{1}{i} +$$ + +As each term is bounded below by a sequence whose series diverges, the partial sums in question must diverge. This follows as $i^{-4} > 0$ for any positive $i$ so $i - i^{-4} < i$; the reciprocal reverses the bound. + +##### Example +Does the following sequence of partial sums converge or diverge? + +$$ +s_n = \sum_{i=1}^n \sqrt{i} \cdot r^i, \quad 0 < r < 1? +$$ + +As $\sqrt{i} \leq i$ for $i\geq 1$, so $\sqrt{i} \cdot r^i \leq i r^i$. +We can use the comparison test to say $s_n$ converges, as we earlier saw the bounding series does. + +--- + +There are other tests that, when applicable, are more direct and avoid needing to identify a bound. + +:::{.callout-note appearance="minimal"} +##### Ratio test +Consider the series formed from the sequence $\{a_n\}$ with $a_n \geq 0$. The ratios $a_{n+1}/a_n$ can determine if the series converges or diverges: + +* if $a_{n+1}/a_n \rightarrow L$ and $L < 1$ then the series converges +* if $a_{n+1}/a_n \rightarrow L$ and $L > 1$ then the series diverges +* if $a_{n+1}/a_n \rightarrow L$ and $L = 1$ then the series may or may not converge. +::: + +For the first case, identify an $r$ with $|L| < r < 1$. Then for some $M > 0$ and any $n > M$ it follows that $a_{n+1} \leq a_n r$. For any $n>0$ the convergence only depends on values after $n$. As such, we shift things to assume for all $n$ that $a_{n+1} \leq a_n r$. Iterating, we get + +$$ +a_{n+1} \leq a_n r \leq a_{n-1}r^2 \leq \cdots \leq a_1 r^n +$$ + +By the comparison test, the series $\sum a_k$ converges, since $0 < r < 1$. + +The case for $L > 1$ is similar, only we find a lower bound on each term. + +For the case $L=1$---which is where most hard problems fall---we have examples where the series converges or diverges. The harmonic series is a divergent example, the series of the sequence $\{1/n^2\}$ is convergent (with limit $\pi^2/6$), though we haven't proved that (cf. [Basel problem](https://en.wikipedia.org/wiki/Basel_problem)). + +A similar type of theorem involves powers of the terms in the sequence + +:::{.callout-note appearance="minimal"} +##### Root test +Consider the series formed from the sequence $\{a_n\}$ with $a_n \geq 0$. The values of $(a_n)^{1/n}$ can determine if the series converges or diverges: + +* if $(a_n)^{1/n} \rightarrow L$ and $L < 1$ then the series converges +* if $(a_n)^{1/n} \rightarrow L$ and $L > 1$ then the series diverges +* if $(a_n)^{1/n} \rightarrow L$ and $L = 1$ then the series may or may not converge. +::: + +The proof is similar. Consider the first case with $L < r < 1$. Then +$(a_n)^{1/n} < r$ implies $a_n < r^n$ so the partial sums (possibly after ignoring initial terms and some shifting) satisfy +$a_0 + a_1 + a_2 + \cdots + a_n < r^0 + r^1 + r^2 + \cdots + r^n$. The geometric series converges under the assumptions. By the comparison test so must the series in question. + +The same two examples ($a_n = 1/n$ and $a_n = 1/n^2$) give examples of divergent and convergent series when $L = 1$. + +:::{.callout-note appearance="minimal"} +##### The p-series test +Fix $p>0$. Consider the series +$$ +s = \sum_{i=1}^\infty \frac{1}{i^p} +$$ + +If $p > 1$ this series is convergent; if $0 < p \leq 1$ the series is divergent. +::: + +This test is a consequence of a more general integral test which will be discussed later, below we offer a specific proof. + +When $p = 1$ this clearly diverges, it being the harmonic series. + +When $p < 1$, we have $i^p < i$ so $1/i^p > 1/i$. By the comparison test (to the harmonic series) the series $s$ will diverge. + + +To prove this series converges when $p > 1$, we split the sum up into different pieces from $2^k$ to $2^{k+1}-1$. Call this sum $t_k$ then $s = \sum_k t_k$ with + +$$ +t_k = \sum_{i=2^k}^{2^{k+1}-1} \frac{1}{n^p} +\leq 2^k \cdot \frac{1}{(2^{k})^p} +\leq \left(\frac{2}{2^p}\right)^k +$$ + +The above replaces each term with the smallest value over $2^k$ to $2^{k+1}-1$ and then multiplies by the number of terms. + + +For $p > 1$, the value of $2/2^p < 1$. That is, $s$ is bounded by a geometric series hence convergent. + +##### Example +Consider this series + +$$ +\sum_{n=1}^\infty \frac{n^k}{5^n}, +$$ +for some positive integer $k$. + +Will this converge? + +The ratio of $a_{n+1}$ to $a_n$ is: + +$$ +\frac{a_{n+1}}{a_n} += \frac{(n+1)^k}{5^{n+1}} \frac{5^n}{n^k} += \left(\frac{n+1}{n}\right)^k \frac{1}{5} +\rightarrow \frac{1}{5} +$$ + +As the limit of this ratio is less than $1$, the series converges. + + +##### Example +Let $a$ be a positive number and consider this series + +$$ +\sum_{n=1}^\infty \frac{a^n}{n^n} +$$ + +Does this converge? + +The root test is easy to apply given the two powers of $n$: + +$$ +(a_n)^{1/n} += \left(\frac{a^n}{n^n}\right)^{1/n} += \frac{a}{n} +\rightarrow 0 +$$ + +That this is less than $1$ says the series converges. + +##### Example +Consider this series: + +$$ +\sum_{n=3}^\infty \frac{1}{n^{3/2} \log(n)} +$$ + +This isn't exactly in the format for the $p$-series test, but we note that $\log(n) \geq 1$ for $n\geq 3$. So + +$$ +a_n = \frac{1}{n^{3/2} \log(n)} +\leq \frac{1}{n^{3/2}} +$$ + +The series $\sum n^{-3/2}$ converges by the $p$-series test, hence the series in question must also converge. + + +### General series + +If there is no assumption that $a_n$ is non-negative, then some different behaviours are possible. + +First, we say that a series is *absolutely convergent* if $\sum |a_n|$ converges. + +A series which is convergent but not absolutely convergent is termed *conditionally convergent*. + + +:::{.callout-note appearance="minimal"} +##### Absolute convergence implies convergence +If the series $\sum a_k$ is *absolutely convergent* then it is convergent. +::: + + +##### Example +Is this series convergent? + +$$ +s = \sum_{k=1}^\infty \frac{\sin(n)}{n^4} +$$ + +We show that the series is absolutely convergent by the comparison theorem. + +We have + +$$ +|a_n| = \frac{|\sin(n)|}{n^4} \leq \frac{1}{n^4} +$$ + +Since $p=4 > 1$ the series is absolutely convergent by the $p$-series test: + + +--- + +However, not all convergent series are also absolutely convergent. A key example is the alternating harmonic series: + +$$ +s = 1 - \frac{1}{2} + \frac{1}{3} - \frac{1}{4} + \cdots +$$ + +This series is conditionally convergent---not absolutely convergent. + +Why follows immediately from a more general statement. + +:::{.callout-note appearance="minimal"} +##### Alternating series test +If $a_n$ and $a_{n+1}$ have different signs for each $n$ *and* $|a_n| \rightarrow 0$ *monotonically* then +$$ +s = \sum_{k=1}^\infty a_k = a_1 + a_2 + a_3 + \cdots +$$ +converges. +::: + + +To visually see this, consider @fig-strang-alternating-series. + +::: {#fig-strang-alternating-series} +```{julia} +#| echo: false +gr() +let + n = 6 + as = [(-1)^(i+1)*1/i for i in 1:n] + p = plot(; xaxis=([], false), + yaxis=([], false), + framestyle=:origin, + legend=false + ) + plot!([0,1],[0,0]; line=(:gray, 1)) + annotate!(0,0, text(L"0", :top)) + + sn = 0; + for (i,a) ∈ enumerate(as) + plot!([sn, sn+a], [i,i]; arrow=true, side=:head, line=(:black, 2)) + sn = sn + a + plot!([sn, sn], [0,i]; line=(:gray, 1, :dash)) + annotate!(sn, 0, text(LaTeXStrings.latexstring("s_{$i}"), :top)) + end + + current() +end +``` + +```{julia} +#| echo: false +plotly() +nothing +``` + +The partial sums of an alternating series converge provided the magnitude of each summand goes to $0$ monotonically. In the figure the arrows represent $a_i$ and get shorter for increasing $i$. +As the $a_i$ alternate in sign and get shorter in length, as indexed, the values of $\{s_{2n}\}$ are monotonic increasing and bounded; the values of $\{s_{2n+1}\}$ are monotonic decreasing and bounded. Hence both series converge. As +$|s_{2n} - s_{2n+1}| = |a_{2n+1}| \rightarrow 0$, they must converge to the same value and the series is convergent by the squeeze theorem. +::: + + + +##### Example: reordering + +Take the sequence $\{ a_n \}$. This is simply a list of values with some indicated order. Let a reordering be any sequence formed by traversing the values in a different order. There are two key facts: + +* If the series based on the sequence is *absolutely convergent*, then a series based on any reordering will be absolutely convergent. + +* If the series is *conditionally convergent* but not *absolutely convergent* then a reordering may converge (conditionally) to a different value or even diverge. + +The case of the latter is the alternating harmonic series. to see it diverges, we note that the subsequences of both negative and positive terms diverge. Call these $\{b_n\}$ and $\{c_n\}$. To see that we can make these diverge, we note that for any $N>0$ and $L$ we can find $k$ so that $b_N + b_{N+1} + \cdots + b_{N+k} > L$. Now for each $i$, we take a consecutive subsequence of values of $b_n$ which sum to $i + |c_i|$. Then the subsequence formed by a group of $b$s followed by $c_i$ will have partial sums always bigger than $i$, hence divergent. + + +## Power series + +A polynomial of degree $n$ is defined by its coefficients through: $p(x) = a_0 + a_1\cdot x + a_2 \cdot x^2 + \cdots + a_n \cdot x^n$ where $a_n$ is non zero. The polynomial as a function of $x$ may be shifted through $p(x-c) = a_0 + a_1\cdot (x-c) + a_2 \cdot (x-c)^2 + \cdots + a_n \cdot (x-c)^n$. + +Pushing this, let $\{a_n\}$ be a sequence. We define a *power series* around $c$ by: + +$$ +\sum_{n=0}^\infty a_n (x - c)^n. +$$ + +A typical case is $c=0$. For any fixed $x$ this is simply a series. Convergence is seen to depend on the value of $x$. + +Suppose the series $\sum a_n$ is absolutely convergent. Then there are some values around $c$ for which the series converges ($x=c$ is one). The *radius of convergence* is a value $r$ for which + +* if $|x-c| < r$ then the power series converges absolutely; and +* if $|x-c| > r$ the power series *diverges*. + +The root test indicates why such a value exists. + +Suppose we consider the term $b_n = a_n (x-c)^n$. Then + +$$ +(|b_n|)^{1/n} = (|a_n|)^{1/n} |x-c| +$$ + +If $(|a_n|^{1/n}) \rightarrow L$ then the root test indicates if the power series converges absolutely or not. In particular. If $L|x-c| < 1$ it converges and if $L|x-c| > 1$ it diverges. That is if $|x-c| < 1/L$ or $|x-c| > 1/L$. Taking $r=1/L$ yields the radius of convergence. (For cases where the limit does not exist, a relaxed version of the root test with the *limit inferior* is applicable.) + +The ratio test can also be used to establish the radius of convergence provided: + +$$ +\frac{|a_{n+1}||(x-c)^{n+1}|}{|a_n||(x-c)^n|} = +\frac{|a_{n+1}|}{|a_n|} |x-c| \rightarrow L |x-c|. +$$ + +Again, $r=1/L$. + +##### Examples + +Consider the power series + +$$ +1 + \frac{x}{1} + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots +$$ + +This has $c=0$ and $a_n = 1/n!$. The ratio test simplifies to + +$$ +\frac{|x-c|^{n+1}}{(n+1)!} \cdot +\frac{n!}{|x-c|^n} = +\frac{|x-c|}{n} \rightarrow 0 +$$ + +Hence $r=\infty$ and the power series is always absolutely convergent. + + +Consider the power series + +$$ +x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \cdots +$$ + +This has term $a_n = (-1)^{n} x^{2n+1}/(2n+1)$, $n\geq 0$. The root test for absolute convergence has + +$$ +(|a_n|)^{1/n} = \frac{x^{2 + 1/n}}{(2n+1)^{1/n}} \rightarrow x^2 +$$ + +Provided $|x| < 1$ the power series will converge. + +Both these examples are related to *Taylor series* for some function. + + + +## Questions + +###### Question + +Which of these sequences *converge*? (The options define the $i$th element in the sequence.) + +```{julia} +#| echo: false +choices = [ + L"a_i = 1/i", + L"a_i = i/(i+2)", + L"a_i = (i^2 + 2i)/(i^3 - 1)", + L"a_i = \frac{i!}{(2i)!}" +] +answers = (1, 2, 3, 4) +multiq(choices, answers) +``` + +###### Question +Which of these sequences *diverge*? + +```{julia} +#| echo: false +choices = [ + L"a_i = i", + L"a_i = i^p, \quad p < 0", + L"a_i = i^p, \quad p > 0", + L"a_i = (2i)/(3i + 4)" +] +answers = (1,3) +multiq(choices, answers) +``` + +###### Question + +Which of these series *converge*? + +```{julia} +#| echo: false +choices = [ + L"\sum_{i=1}^\infty (\frac{\pi}{4})^i", + L"\sum_{i=1}^\infty (\frac{\pi}{2})^i", + L"\sum_{i=1}^\infty \frac{1}{i^{\pi/4}}", + L"\sum_{i=1}^\infty \frac{1}{i^{4/\pi}}", + +] +answers = (1,4) +multiq(choices, answers) +``` + +###### Question +Which of these series *diverge*? + +```{julia} +#| echo: false +choices = [ + L"\sum_{i=1}^\infty (\frac{\pi}{3})^i", + L"\sum_{i=1}^\infty \frac{i}{i + 2}", + L"\sum_{i=1}^\infty \frac{1}{i^{1.23}}", + L"\sum_{i=1}^\infty \frac{1}{1.23^i}", + +] +answers = (1,2) +multiq(choices, answers; keep_order=true) +``` + +###### Question + +Some terms grow faster than others. For example, it is well known that exponential growth is greater than polynomial growth. Here we look at a few forms. + +A polynomial term is like $n^k$ for some power $k>0$. We know from discussion on horizontal asymptotes that $n^k$ grows faster than $n^j$ if $k > j$. + + + + + + +What about comparing a polynomial term to an exponential term? +Let's use `SymPy` to do an example. Suppose $r > 1$ + +```{julia} +@syms x::positive +r = 1 + x +@syms n::(integer, positive) k::(integer, positive) +a_n = r^n +b_n = n^k +limit(a_n/b_n, n=>oo) +``` + +That this is $\infty$ indicates that the exponential term $r^n$ grows faster than any "polynomial" term $n^k$. + + + + +Compare the exponential term $r^n$ to a factorial term $n!$ using `SymPy`. + +What do you conclude? + +```{julia} +#| echo: false +choices = [ +raw"The factorial term `factorial(n)` grows faster than the exponential term `r^n`", +raw"The factorial term `factorial(n)` grows slower than the exponential term `r^n`" +] +radioq(choices, 1) +``` + +Compare the growth of a term like $n^n$ to $n!$ using `SymPy`. What do you conclude. + + +```{julia} +#| echo: false +choices = [ + raw"The term `n^n` grows faster than `factorial(n)`", + raw"The term `n^n` grows slower than `factorial(n)`", +] +radioq(choices, 1) +``` + + + + + + +###### Question +Consider the sequence defined by + +$$ +a_n = \frac{n!}{n^n}, \quad n \geq 0. +$$ + +We have + +```{julia} +@syms n::(integer, positive) +an = factorial(n)/n^n # aₙ +an_1 = an(n => n+1) # aₙ₊₁ +limit(an_1/an, n => oo) +``` + +Based on this output, does the sequence converge? + +```{julia} +#| echo: false +choices = [ +raw"Yes, the ratio is eventually less then $1$ implying the sequence is monotone decreasing and bounded (below) by 0. Hence convergent", +raw"No, the limit above must be $0$ for $a_n$ to converge" +] +radioq(choices, 1) +``` + + + +###### Question + +Compute + +$$ +\sum_{n=0}^\infty \frac{2}{3^n} + \frac{4}{5^n} +$$ + +```{julia} +#| echo: false +answer = 2 * 1/(1-1/3) + 4 * 1/(1 - 1/5) +numericq(answer) +``` + +###### Question + +Compute + +$$ +\sum_{n=2}^\infty \left(\frac{1}{2}\right)^n +$$ + +```{julia} +#| echo: false +r = 1/2 +answer = 1/(1-r) - r^(0) - r^(1) +numericq(answer) +``` + +###### Question + +Consider the series + +$$ +\sum_{n=1}^\infty \frac{n}{e^n} +$$ + +This series + +```{julia} +#| echo: false +choices = [ +"converges", +"diverges" +] +radioq(choices, 1) +``` + +###### Question + +Consider the series + +$$ +\sum_{n=1}^\infty (-1)^n \cdot \frac{n}{2n - 3} +$$ + +This series + +```{julia} +#| echo: false +choices = [ +"converges", +"diverges" +] +radioq(choices, 2) +``` + + +###### Question +Consider the power series about $c=0$ formed from the sequence + +$$ +a_n = (-1)^{n+1}\frac{x^{2n+1}}{(2n+1)!} +$$ + +That is, $s = x - x^3/3! + x^5/5! - \cdots$. Find the radius of convergence. + +This computation might prove useful: + +```{julia} +@syms x::real n::(positive,integer) +an =x^(2n+1)/factorial(2n+1) +an_1 = an(n => n+1) +limit(an_1/an, n=>oo) +``` + +The radius of convergence is: + +```{julia} +#| echo: false +choices=[ +L"0", +L"1", +L"\infty" +] +radioq(choices, 3) +``` + +###### Question + +Consider the series based on the terms + +$$ +a_n = (-1)^{n}\frac{1}{n}(x-1)^n +$$ + +Find the radius of convergence. + +This computation might prove useful + +```{julia} +@syms x::real n::(positive,integer) +an = (x-1)^n / n +an_1 = an(n => n+1) +limit(an_1/an, n=>oo) +``` + +The radius of convergence is: + +```{julia} +#| echo: false +choices=[ +L"0", +L"1", +L"\infty" +] +radioq(choices, 2) +``` + + + +###### Question + +Consider the series + +$$ +\sum_{k=1}^\infty k\cdot x^k = x + 2x^2 + 3x^3 + \cdots +$$ + +We can show directly, without needing a formula for the partial sums as before, that this series converges whenever $|x| < 1$. + + +What does this computation with `SymPy` show for positive $x$? + +```{julia} +@syms delta::positive n::integer +r = 1 + delta +limit(r^n - n, n=>oo) +``` + +```{julia} +#| echo: false +choices = [ +raw"It shows $r^n > n$ for all $n$", +raw"It shows $r^n > n$ for large enough $n$" +] +radioq(choices, 2) +``` + +Suppose $r^n > n$, then $nx^n \leq n|x|^n < r^n |x|^n < (r|x|)^n$. If $|x| < 1$ why can we find $r>1$ with $r|x| < 1$? + +```{julia} +#| echo: false +choices = [ +raw"We can take $r = 1/|x|$", +raw"We can take $r = 1/\sqrt{|x|}$" +] +radioq(choices, 2) +``` + +If $r$ is so chosen, then by the comparison theorem the sum is eventually bounded by a geometric series. + + + +###### Question + +Let $s(x) = \sum_{i=1}^\infty i^2 x^i$ be a power series. The ratio test for convergence considers: + +$$ +|\frac{a_{n_+1}}{a_n}| = \frac{(n+1)^2 x^{n+1}}{n^2x^n} = +\frac{(n+1)^2}{n^2} |x|. +$$ + +This has a limit as $n \rightarrow \infty$. Use this limit to find the *radius* of convergence. What is the value? + +```{julia} +#| echo: false +numericq(1) +``` + +Now for fixed integer $k > 2$ let $s(x) = \sum_{i=1}^\infty i^k x^i$ be a power series. The ratio test again can be used to find the radius of convergence. What does it find? + +```{julia} +#| echo: false +numericq(1) +``` + + +###### Question + + +Absolutely convergent series have some properties + +* If $\sum a_n$ and $\sum b_n$ are absolute convergent then $\sum (a_n + b_n)$ will be absolutely convergent. + +* if $\sum a_n$ and $\sum b_n$ are absolute convergent then $\sum (a_n \cdot b_n)$ will be absolutely convergent. + +To see the first we could use the triangle inequality: + +$$ +|a_n + b_n| \leq |a_n| + |b_n| +$$ + +So that the partial sum + +$$ +\sum_{k=1}^n |a_n + b_n| \leq +\sum_{k=1}^n |a_n| + \sum_{k=1}^n |b_n| +$$ + +Why do each of these sums converge? + +```{julia} +#| echo: false +choices = [ +raw"The two series are absolutely convergent so their partial sums have a limit", +raw"The two series are are divergent so their partial sums diverge" +] +radioq(choices, 1) +``` + +For the second one, if $\sum b_n$ is absolutely convergent, then we can assume $|b_n| < 1$ eventually. Hence, eventually + +$$ +|a_n b_n| \leq |a_n| \cdot 1 +$$ + +Since $\sum a_n$ is absolutely convergent by the comparison theorem so will be $\sum a_n b_n$. + +Why is $|b_n| < 1$ eventually? + +```{julia} +#| echo: false +choices = [ +raw"The series $\sum b_n$ is absolutely convergent, hence if must be $|b_n| \rightarrow 0$", +raw"The series $\sum b_n$ is absolutely convergent, hence $\sum b_n < 1$" +] +radioq(choices, 1) +``` + +###### Question + +The Cauchy criteria for convergence of a series $s = \sum a_k$ is that $s$ converges if for any $\epsilon > 0$ there exists an $N$ such that if $n,m \geq N$ then $|s_n - s_m| < \epsilon$ and vice versa. This basically says the terms at the end eventually contribute a negligible amount to the sum when convergent. + +Why might this be useful? + +```{julia} +#| echo: false +choices = [ + raw"The Cauchy criteria is actually harder to compute as it requires two sums to be known, not just one.", + raw"The definition of convergence depends on a known limit, but this may in practice be unknown. The Cauchy criteria only involves the partial sums, not the limit."] +radioq(choices, 2) +``` + +###### Question + +The following extends the comparison test: + +:::{.callout-note appearance="minimal"} +### Limit comparison test +Take two series with *positive* terms $\sum a_n$ and $\sum b_n$. + +If $\lim_{n\rightarrow \infty} a_n/b_n = c$ with $0 < c < \infty$ then either both series converge of both series diverge. +::: + +Basically the limit says both sequences $\{a_n\}$ and $\{b_n\}$ go to $0$ at the same rate so their series are somewhat comparable. + +To prove this, fix an $\epsilon$ so $c-\epsilon > 0$. Then eventually + +$$ +\left| \frac{a_n}{b_n} - c \right| < \epsilon +$$ + +Rearranging gives $a_n < (c+\epsilon) b_n$. + +If $\sum a_n$ *diverges* why must $\sum b_n$ diverge? + +```{julia} +#| echo: false +choices = [ +raw"If $\sum a_n$ diverges, then so must $\sum a_n/(c+\epsilon)$. By the comparison test, so must $\sum b_n$ diverge", +raw"If $\sum a_n$ diverges, then by the ratio test $a_{n+1}/a_n \rightarrow d > 1$ hence $b_{n+1}/b_n \rightarrow d (c + \epsilon) > 1$." +] +radioq(choices, 1) +``` + +Another rearrangement gives $b_n < a_n / (c - \epsilon)$. If $\sum a_n$ is *convergent* why must $\sum b_n$ be convergent? + + +```{julia} +#| echo: false +choices = [ +raw"If $\sum a_n$ converges, then so must $\sum a_n/(c-\epsilon)$. By the comparison test, so must $\sum b_n$ converge", +raw"If $\sum a_n$ converges, then by the ratio test $a_{n+1}/a_n \rightarrow d < 1$ hence $b_{n+1}/b_n \rightarrow d (c - \epsilon) < 1$." +] +radioq(choices, 1) +``` + + +###### Question + +Let $s = \sum_{n=0}^\infty a_n \cdot (x-c)^n$ and $t = \sum_{n=0}^\infty b_n \cdot (x-c)^n$. + + +Guess what this power series is: + +$$ +\sum_{n=0}^\infty (a_n + b_n) \cdot (x-c)^n +$$ + +```{julia} +#| echo: false +choices = [ +L"s + t", +L"s - t", +L"s \cdot t", +L"s / t" +] +radioq(choices, 1; keep_order=true) +``` + +Guess what this power series is: + +$$ +\sum_{n=0}^\infty \left(\sum_{i=0}^n (a_i \cdot b_{n-i})\right) \cdot (x-c)^n +$$ + +```{julia} +#| echo: false +choices = [ +L"s + t", +L"s - t", +L"s \cdot t", +L"s / t" +] +radioq(choices, 31; keep_order=true) +``` + +For completeness, [Wikipedia](https://en.wikipedia.org/wiki/Power_series#Multiplication_and_division) gives this formula for division $s/t = \sum_{n=0}^\infty d_n \cdot (x-c)^n$ where + +$$ +d_0 = \frac{a_0}{b_0} +$$ + +and +$$ +d_n = \frac{1}{b_0^{n+1}} \cdot +\begin{vmatrix} +a_n & b_1 & b_2 & \cdots & b_n\\ +a_{n-1} & b_0 & b_1 & \cdots & b_{n-1}\\ +a_{n-2} & 0 & b_0 & \cdots & b_{n-1}\\ +\vdots & \vdots & \vdots & \ddots & \vdots\\\ +a_0 & 0 & 0 & \cdots & b_0 +\end{vmatrix} +$$ + +The last operation is called the determinant and will be discussed later on.