\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{color}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
%\tikzstyle{ball} = [circle,shading=ball, ball color=black,
%    minimum size=1mm,inner sep=1.3pt]
%\usetikzlibrary{arrows.meta}
%\tikzset{>={Latex[length=2mm,width=1.5mm]}}

%\usepackage{graphicx}

\usepackage{enumitem}
\setlist[enumerate]{leftmargin=*}

\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lub}{\mathrm{lub}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\begin{document}
\centerline{Math 322 lecture for Monday, Week 1}
\bigskip

{\bf Homepage.} Please see our \href{http://www.reed.edu/~davidp/322}{course
homepage}.  In particular, please follow the ``Course information'' link and
carefully read the material there.
\medskip

{\bf Text.} Our text is \emph{Differential equations and dynamical systems},
edition~3, by Lawrence Perko.  
\medskip

{\bf Overview.}  This is a course in differential equations for advanced
undergraduates.  Here is a rough outline of what we'll cover:
\begin{enumerate}
  \item {\bf Elementary methods.}  We will spend two weeks to cover the
    major part of what one might do in a first course in differential equations
    in a lower-level course.
  \item {\bf Linear theory.} We will then learn how to solve systems of linear
    differential equations with constant coefficients.  The key is
    exponentiation of matrices and the Jordan form.
  \item {\bf Local nonlinear theory.} Most nonlinear systems cannot be solved.
    So we are interested in describing the qualitative behavior of such systems.
    The main idea is to approximate nonlinear systems with linear systems.  We
    will cover the important existence-uniqueness theorems.
  \item {\bf Global theory.} At the end of the course, we will study limits of
    trajectories and topological properties for systems of ODEs.
\end{enumerate}

{\bf First goal: elementary methods.} For this part of the course, we will not
have a text.  The main source for information will be the lecture notes and
handouts.  There is also plenty of material readily available online.  My hope
is that this will be a time to have fun doing lots of computations by hand.  We
will cover the six methods from the handout
\href{http://www.reed.edu/~davidp/322/handouts/recipes.pdf}{First recipes},
starting with separable equations.  In the following, we will generally think
of~$y$ as a real-valued function of~$t$.
\medskip

{\bf I. Separable equations.}  A separable differential equation has the
form (or can be manipulated to have the form)
\[
  p(y)\frac{dy}{dt}=q(t).
\]
It is solved by integration:
\[
  \int p(y)\,dy = \int q(t)\,dt.
\]

{\sc examples.} Consider the differential equation
\[
  y'=\frac{3t}{y}.
\]
It's separable since we can get
the~$y$s on one side of the equality and the~$t$s on the other:
\[
  yy'=3t.
\]
Integrate:
\[
  \int y(t)y'(t)\,dt=\int 3t\,dt.
\]
Forgetting about constant until the end, the right-hand side is
\[
  \int 3t\,dt=\frac{3}{2}\,t^{2}
\]
For the left-hand side, make the substitution~$u=y(t)$.  So~$du=y'(t)\,dt$.
Substituting gives:
\[
  \int y(t)y'(t)\,dt=\int u\,du=\frac{1}{2}u^2=\frac{1}{2}y^2.
\]
Setting the two sides equal and adding a constant gives the most general
solution:
\[
  \frac{1}{2}y^2=\frac{3}{2}\,t^2+\tilde{c}
\]
or, equivalently,
\[
  \fbox{$y(t)^2=3t^2+c$}
\]
for some constant~$c$.

(An alternative way to integrate:
\[
  \int y\,dy=\int 3t\,dt\quad\Rightarrow\quad\frac{1}{2}y^2=\frac{3}{2}t^2+c.)
\]

To find a particular solution, we can impose an initial condition.  For
instance, if~$y(0)=5$, then
\[
  25=y(0)^2=3\cdot 0^2+c\quad\Rightarrow\quad c=25,
\]
and the solution is defined implicitly by
\[
  y(t)^2=3t^2+25.
\]
Thus, $y(t)=\pm\sqrt{3t^{2}+25}$.  Since we want~$y(0)=5$, we must choose the
positive solution:
\[
  y(t)=\sqrt{3t^{2}+25}.
\]
It is a solution for all~$t\in\R$.  If you initial condition were~$y(0)=-5$, the
solution would be~$y(t)=-\sqrt{3t^{2}+25}$, again for all~$t\in\R$.

There are, qualitatively, two types of behavior for solutions of this
differential equation depending on whether~$c$ is positive or negative.
\begin{center}
\begin{tikzpicture}
  \begin{axis}[ 
      scale=1.0,
      title style={at={(0.5,0)},anchor=north,yshift=-30},
      title={Graph of~$y(t)=\sqrt{3t^2+1}$.},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-0.2,
      %xmax=5,
      ymin=-0.2,
      %ymax=16,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-1:1,samples=100,thick, blue] {sqrt(3*x*x+1)};
  \end{axis}
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tikzpicture}
  \begin{axis}[ 
      scale=1.0,
      title style={at={(0.5,0)},anchor=north,yshift=-30},
      title={Graph of~$y(t)=\sqrt{3t^2-1}$.},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-0.2,
      %xmax=5,
      %ymin=-0.2,
      %ymax=16,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-2:2,samples=100,thick, blue] {sqrt(3*x*x-1)};
  \end{axis}
\end{tikzpicture}
\end{center}
For an example where~$c<0$, suppose the initial condition is~$y(-1)=\sqrt{2}$.
Then
\[
  2 = y(-1)^{2}=3\cdot 1^{2}+c\quad\Rightarrow\quad c=-1,
\]
and the implicit solution is
\[
  y(t)^{2}=3t^{2}-1.
\]
The solution (with the given initial condition) is
\[
  y(t)=\sqrt{3t^{2}-1},
\]
which makes sense for~$3t^{2}\geq1$, i.e., $t\geq \sqrt{3}/3$ and
$t\leq-\sqrt{3}/3$.
Since our initial condition is at~$t=-1$, the maximal interval for the solution
is~$(-\infty,-\sqrt{3}/3)$.
\medskip

\textbf{Exponential growth and decay model.} Let~$y(t)$ now denote the size of a
population, varying over time. What happens if we assume that the rate of growth of the
population is proportional to the size of the population?  The rate of growth of
the population is~$y'(t)$ and the size of the population is~$y(t)$.  To say they
are proportional is to say there is a constant~$r$ such that
\[
  y'(t)=ry(t).
\]
This is a separable equation, which is easy to solve:
\[
  y'(t)=ry(t) \quad\Rightarrow\quad \frac{y'(t)}{y(t)}=r
  \quad\Rightarrow\quad \int\frac{y'(t)}{y(t)}\,dt=\int r\,dt.
\]
Integrate, then solve for~$y$:
\[
  \ln |y(t)| = rt+c\quad\Rightarrow\quad |y(t)|=e^{rt+c}=e^ce^{rt}=ae^{rt},
\]
where~$a$ a positive constant.  So the solution is
\[
  y(t)=
  \begin{cases}
    \hfill ae^{rt}&\text{if~$y>0$}\\
    \hfill-ae^{rt}&\text{if~$y<0$}.
  \end{cases}
\]
where~$a$ is positive.  But we can combine these two solutions into the single
solution~$y(t)=ae^{rt}$ by letting~$a$ be any nonzero real number.
Setting~$t=0$, we see
\[
  y(0)=ae^{0}=a.
\]
Hence,~$a$ is the initial population.  So we might write the solution as
\[
  y(t)=y_0e^{rt}.
\]
For instance, if~$y_0=r=1$, we get the picture below:
\begin{center}
\begin{tikzpicture}
  \begin{axis}[ 
      scale=1.0,
      title style={at={(0.5,0)},anchor=north,yshift=-30},
      title={Graph of~$y(t)=e^t$.},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-0.2,
      %xmax=5,
      ymin=-0.2,
      %ymax=16,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-2:2,samples=100,thick, blue] {exp(x)};
  \end{axis}
\end{tikzpicture}
\end{center}
If~$y_0=1$ and~$r=-1$, we get:
\begin{center}
\begin{tikzpicture}
  \begin{axis}[ 
      scale=1.0,
      title style={at={(0.5,0)},anchor=north,yshift=-30},
      title={Graph of~$y(t)=e^t$.},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-0.2,
      %xmax=5,
      ymin=-0.2,
      %ymax=16,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-2:2,samples=100,thick, blue] {exp(-x)};
  \end{axis}
\end{tikzpicture}
\end{center}
In performing the integration, \emph{we assumed that~$y$ was never zero in the range
over which we integrated}.  What if the initial condition is~$y(t_0)=0$ for some time~$t_0$?  One solution
then is to take~$y(t)=0$ for all~$t$. Again, the equation~$y(t)=y_{0}e^{rt}$
works.  Is this the only solution?  We'll focus on this question later in the course.
\medskip

{\bf Example.} If~$y(t)=ae^{rt}$ with $y(0)=a\neq0$ at what time~$t$ has the population doubled?
\smallskip

{\sc solution:}  The initial population size is~$a$.  So we are trying to find
the time~$t$ when~$y(t)=2a$, so we need to solve
\[
  ae^{rt}=2a.
\]
Since~$a\neq0$, we need to solve
\[
  e^{rt}=2
\]
for~$t$. Taking logs,
\[
  \ln(2)=\ln(e^{rt})=rt.
\]
Hence, assuming~$r\neq0$,
\[
  t=\frac{\ln(2)}{r}.
\]
If~$r=0$, then $y(t)=a$ for all~$t$, and the population never doubles.
\medskip

\textbf{Population model based on Newton's law of cooling.} Suppose now that the
rate of change of the population is governed by the differential equation
\[
  y'(t)=r(S-y(t))
\]
where~$r$ and~$S$ are positive constants.
\medskip

{\bf Problems:}
\begin{enumerate}
  \item When is the population increasing? Decreasing?
    \medskip

    {\sc Answer:} We have
    \[
      y'(t)=r(S-y(t))>0
      \quad\Leftrightarrow\quad S-y(t)>0
      \quad\Leftrightarrow\quad S>y(t).
    \]
    So the population is increasing whenever it's less that~$S$ and decreasing
    whenever it's larger than~$S$.
  \item What is the long-term behavior of the population? 
\medskip

{\sc Answer:} Given the answer to the previous problem it seems like the
population should tend towards~$S$.
  \item Solve the equation assuming~$y<S$.
\medskip

{\sc solution:} The equation is separable:
\begin{align*}
  \int \frac{dy}{S-y}=\int r\,dt
  &\quad\Rightarrow\quad -\ln(S-y)=rt+c\\[8pt]
  &\quad\Rightarrow\quad S-y=ae^{-rt}\\[8pt]
  &\quad\Rightarrow\quad y=S-ae^{-rt}.
\end{align*}
Note that~$y(t)\to S$ as~$t\to\infty$.

Let's now make the initial population explicit in the solution.  Say~$I$ is the
initial population.  Then
\[
  I=y(0)=S-ae^0=S-a\quad\Rightarrow\quad a = S-I.
\]
Our final form for the solution is
\[
  \fbox{$\displaystyle y(t)=S-(S-I)e^{-rt}$}\ ,
\]
where~$I=y(0)$ is the initial population.
\end{enumerate}
\begin{center}
\begin{tikzpicture}
  \begin{axis}[ 
      scale=1.0,
      title style={at={(0.5,0)},anchor=north,yshift=-30},
      title={Graph of~$y(t)=S-(S-I)e^{-rt}$ with~$S=100$,~$I=50$, and~$r=1$.},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-0.2,
      %xmax=5,
      %ymin=-0.2,
      %ymax=16,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=0:10,samples=100,thick, blue] {100-(100-50)*exp(-x)};
      \draw[orange,densely dashed,thick] (axis cs:0,100)--(axis cs:10,100);
  \end{axis}
\end{tikzpicture}
\end{center}
\end{document}


