\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 Friday, Week 1}
\bigskip

\textsc{II.~A. Exact equations.}  
\bigskip

An exact differential equation has the form
\[
  M(t,y)+N(t,y)\,\frac{dy}{dt}=0.
\]
where
\[
  \frac{\partial M}{\partial y}=\frac{\partial N}{\partial t}.
\]
We would like to find a solution that defines~$y$ implicitly, i.e., we are
looking for a function of the form
\[
  \Phi(t,y)=0.
\]
If we had such a function, then by the chain rule,
\[
  0=\frac{d\Phi}{dt}=\frac{\partial\Phi}{\partial t}+\frac{\partial\Phi}{\partial y}\frac{dy}{dt}.
\]
Then~$\Phi$ would be a solution if
\[
  M(t,y)=\frac{\partial\Phi}{\partial t}\quad\text{and}\quad
  N(t,y)=\frac{\partial\Phi}{\partial y}.
\]
Note that the conditions on the partials of~$M$ and~$N$ which are required of an
exact equation would then follow necessarily:
\[
  \frac{\partial M}{\partial y}=\frac{\partial^2\Phi}{\partial t\,\partial y}
  =\frac{\partial N}{\partial t}.
\]
The trick then is to reverse-engineer this argument.  Since
$\displaystyle M(t,y)=\frac{\partial\Phi}{\partial t}$, we integrate~$M$ with respect
to~$t$:
\[
  \Phi(t,y)=\int M(t,y)\,dt=: m(t,y)+f(y)
\]
where~$f$ is an arbitrary function of~$y$.  Then we use the fact that
$\displaystyle N(t,y)=\frac{\partial\Phi}{\partial y}$ to determine~$f(y)$:
\[
  N(t,y)= \frac{\partial\Phi}{\partial y} = \frac{\partial }{\partial
  y}(m(t,y)+f(y)).
\]
This determines~$f(y)$ up to a constant.
\medskip

\textbf{Note for those who have seen differential forms:} Recall that the
differential form~$\omega$ is {\em exact} if there is a form~$\psi$ such
that~$d\psi=\omega$.  Since~$d^2=0$, such forms are automatically {\em closed}:
$d\omega=d^2\psi=0$.  In our case, we are considering the
$0$-form,~$\psi=\Phi(t,y)$, and then
\[ d\psi = \frac{\partial\Phi}{\partial t}\,dt+\frac{\partial\Phi}{\partial y}\,dy.
  =M(t,y)\,dt+N(t,y)\,dy.
\]
Another way of saying the same thing is that the vector field
\[
  (t,y)\mapsto (M(t,y),N(t,y))
\]
is the gradient vector field~$\nabla\Phi$.
\medskip

\textbf{Example.}  Solve
\[
  \sin(t+y)+(2y+\sin(t+y))y'=0.
\]
The equation is not separable.  However, it is exact since
\[
  \frac{\partial}{\partial y}\sin(t+y)=\cos(t+y)=\frac{\partial}{\partial
  t}(2y+\sin(t+y)).
\]
We have~$M(t,y)=\sin(t+y)$ and~$N(t,y)=2y+\sin(t+y)$.  To solve the equation,
note that
\[
  \int M(t,y)\,dt=-\cos(t+y)+f(y)
\]
for some~$f(y)$, and then
\[
  \frac{\partial}{\partial y}(-\cos(t+y)+f(y))=N(t,y)=2y+\sin(t+y)
\]
implies that
\[
  \frac{df}{dy}=2y.
\]
Hence,~$f(y)=y^2+\tilde{c}$.  Our final solution is
\[
  -\cos(t+y)+y^2=c.
\]
\medskip

\textbf{Slope fields.}  Let~$y=y(t)$ be the solution to a differential
equation~$y'=F(y,t)$.  The graph of~$y(t)$ is a curve.  At time~$t_0$, the curve
passes through the point~$(t_0,y(t_0))$ and has slope~$y'(t_0)=F(t_0,y(t_0))$.
Imagine attaching to each point~$(a,b)\in\R^2$ a tiny line segment with
slope~$F(a,y(a))$.  Any solution curve will then be tangent to each line segment
it meets.  (There will be lots of solutions, depending on the initial
condition.)  For example, Figure~\ref{fig: slope field} creates the slope field
and exhibits several possible solutions.
\begin{figure}[ht]
\begin{center}
\includegraphics[height=2.0in]{01fri_slope_field.png}
\end{center}
\caption{Slope field and solutions for $\sin(t+y)+(2y+\sin(t+y))y'=0$.}
\label{fig: slope field}
\end{figure}
Here is the Sage code used to produce the figure:
\begin{verbatim}
sage: v = plot_slope_field(-sin(t+y)/(2*y+sin(t+y)),(t,-5,5),(y,-3,3),
...: headaxislength=3, headlength=3,color='blue')
sage: c = contour_plot(-cos(t+y)+y^2,(t,-5,5),(y,-3,3),fill=false)
sage: v + c
Launched png viewer for Graphics object consisting of 2 graphics primitives
\end{verbatim}

\textsc{II.~B. Exact after multiplying through by integrating factor.}  
\bigskip

We are again interested in solving
\[
  M(t,y)+N(t,y)\,\frac{dy}{dt}=0,
\]
but this time, we don't assume that~$\partial M/\partial y=\partial
N/\partial t$.  In that case, we look for a function~$\mu(t,y)$ such that
\[
  \mu(t,y)M(t,y)+\mu(t,y)N(t,y)\,\frac{dy}{dt}=0,
\]
is exact.  In fact,~$\mu$ always exists:
\smallskip

{\bf Proof.} Let~$\Phi$ be such that~$\Phi(t,y)=0$ (we can talk about the
existence of~$\Phi$ later, but for now let's assume it exists). Differentiate
with respect to~$t$, as before, and use the chain rule
\[
  0=\frac{d\Phi}{dt}=\frac{\partial\Phi}{\partial t}+\frac{\partial\Phi}{\partial y}\frac{dy}{dt}.
\]
We have
\[
  \frac{dy}{dt}=-\frac{\partial\Phi/\partial t}{\partial\Phi/\partial
  y}=-\frac{M(t,y)}{N(t,y)},
\]
and, hence,
\[
  \frac{\partial\Phi/\partial t}{M(t,y)}
  =
  \frac{\partial\Phi/\partial y}{N(t,y)}
  =:\mu(t,y),
\]
where we have just now defined~$\mu$.  It follows that
\[
0=\mu(t,y)M(t,y)+\mu(t,y)N(t,y)\frac{dy}{dt}
=
\frac{\partial\Phi}{\partial t}+\frac{\partial\Phi}{\partial
y}\frac{dy}{dt},
\]
which is now exact.
\hfill$\Box$

That's the good news.  The bad news is that it might not be easy to
find~$\mu$.  I typical strategy is to assume that~$\mu$ has a certain form
involving parameters, and then try to figure out what values for the parameters
will make your equation exact.  
\medskip

{\bf Example.} Solve
\[
  ty^2+4t^2y+(3t^2y+4t^3)\frac{dy}{dt}=0.
\]
This equation is not exact.  We'll try to find an integrating factor of the
form~$\mu(t,y)=t^my^n$.  So we would like for
\[
  (t^my^n)(ty^2+4t^2y)+t^my^n(3t^2y+4t^3)\frac{dy}{dt}=0
\]
to be exact.  We need
\[
  \frac{\partial}{\partial y}(t^{m+1}y^{n+2}+4t^{m+2}y^{n+1})
  =
  \frac{\partial}{\partial t}(3t^{m+2}y^{n+1}+4t^{m+3}y^{n}).
\]
In other words, we need
\[
  (n+2)t^{m+1}y^{n+1}+4(n+1)t^{m+2}y^{n}
  =
  3(m+2)t^{m+1}y^{n+1}+4(m+3)t^{m+2}y^{n}.
\]
Equate coefficients:
\[
  n+2=3(m+2)\quad\text{and}\quad 4(n+1)=4(m+3).
\]
Solving this system of linear equations yields~$m=-1$ and~$n=1$.  Our
integrating factor is~$\mu(t,y)=y/t$. Ah, ha!  That reminds me of the
homogeneity trick.  In fact, solving for~$dy/dt$ in the original equation does
give the form~$y'=F(y/t)$!  So we could have solved this with our earlier
machinery.  Nevertheless, we'll continue from here.  Multiplying through by the
integrating factor transforms our original equation into
\[
  y^3+4ty^{2}+(3ty^{2}+4t^2y)\frac{dy}{dt}=0,
\]
which is now exact with
\[
  M=y^3+4ty^{2}\quad\text{and}\quad N=3ty^{2}+4t^2y.
\]
(Check that~$\partial M/\partial y=\partial N/\partial t$ to be sure.)
Solve the exact equation:
\[
  \Phi(t,y)=\int M\,dt=ty^3+2t^2y^2+f(y)
\]
implies
\[
  N(t,y)=\frac{\partial\Phi}{\partial y}=3ty^2+4t^2y+\frac{df}{dy}.
\]
Comparing with~$N(t,y)$ shows that~$df/dy=0$. Hence,~$f(y)=\tilde{c}$, a constant.  Our
solution:
\[
  ty^3+2t^2y^2=c,
\]
(where~$c=-\tilde{c}$, is just another constant).  Figure~\ref{fig: slope field
2} give the slope field and several solutions.  Figure~\ref{fig: surface} plots
the function~$z=ty^3+2t^2y^2$.  The level sets of this function are solutions to
the differential equation.
\newpage

\begin{figure}[ht] 
   \centering
  \includegraphics[height=2in]{01fri_slope_field2.png}
  \caption{Slope field and solutions to $ty^2+4t^2y+(3t^2y+4t^3)\frac{dy}{dt}=0.$}
  \label{fig: slope field 2}
\end{figure}

\begin{figure}[ht] 
  \centering
  \includegraphics[height=2in]{01fri_surface.png}
  \caption{Plot of the surface $z=ty^3+2t^2y^2$.}
  \label{fig: surface}
\end{figure}
\end{document}
