\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{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\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 2}
\bigskip

\textbf{V. Method of undetermined coefficients.} 
\bigskip

We look at one more example of the method of undetermined coefficients.
Consider the equation 
\[
  y''-2y'+y=t\cos(3t).
\]
We guess a particular solution of the form
\[
  y = (a_{0}+a_{1}t)\cos(3t)+(b_{0}+b_{1}t)\sin(3t).
\]
Then
\begin{align*}
  y'
  &= (a_{1}+3b_{0}+3b_{1}t)\cos(3t)+(-3a_{0}+b_{1}-3a_{1}t )\sin(3t)\\[8pt]
  y'' &= (-9a_{0}+6b_{1}-9a_{1}t)\cos(3t)+(-6a_{1}-9b_{0}-9b_{1}t )\sin(3t)
\end{align*}
So we have
\begin{align*}
  y''-2y'+y
  &= (- 8a_{0} - 2a_{1} - 6b_{0} + 6b_{1} - (8a_{1}+6b_{1})t )\cos(3t)\\
  &\qquad+(6a_{0} - 6a_{1} - 8b_{0} - 2b_{1}+(6a_{1}- 8b_{1})t )\sin(3t)
\end{align*}
Set this equal to~$t\cos(3t)$ and compare coefficients to get the system on
linear equations
\begin{align*}
 0&= - 8a_{0} - 2a_{1} - 6b_{0} + 6b_{1}\\
 1&= -8a_{1}-6b_{1}\\
 0&= 6a_{0} - 6a_{1} - 8b_{0} - 2b_{1}\\
 0&= 6a_{1}-8b_{1}
\end{align*}
Solving this system gives the particular solution
\[
  y_p=  -\frac{1}{250} \, {\left(13 + 20 \, t\right)} \cos\left(3 \, t\right) -
  \frac{3}{250} \, {\left(-3 + 5 \, t\right)} \sin\left(3 \, t\right).
\]
The corresponding homogeneous equation, $y''-2y'+y=0$, has a general solution
$ae^{t}+bte^{t}$. So the general solution to our inhomogeneous equation is
\[
  y = ae^{t}+bte^{t}-\frac{1}{250} \, {\left(13 + 20 \, t\right)} \cos\left(3 \, t\right) -
  \frac{3}{250} \, {\left(-3 + 5 \, t\right)} \sin\left(3 \, t\right)
\]
Let's again consider the initial conditions~$y(0)=1$ and~$y'(0)=-2$.  Plugging
these into the general solution and its derivative allow us to
determine~$a$ and~$b$.  The result is
\[
y=
\frac{263}{250} \, e^{t}
- \frac{77}{25} \, t e^{t} 
-\frac{1}{250} \, {\left(13 + 20 \, t\right)} \cos\left(3 \, t\right) 
- \frac{3}{250} \, {\left(-3 + 5 \, t\right)}
\sin\left(3 \, t\right).
\]
\Needspace{3\baselineskip}
Graph of solution:
\begin{center}
\begin{tikzpicture}
  \begin{axis}[
      scale=0.8,
      %title style={at={(0.5,0)},anchor=north,yshift=-30},
      %title={\mbox{\parbox{\textwidth}{Graph of~$P(t)$ with~$K=1000$ and~$P(0)=10$ and two different
      %growth rates:~$r=0.5$ in red and~$r=0.2$ in blue.}}},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      xmin=-3,
      xmax=3,
      ymin=-3,
      %ymax=1100,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-3:3,thick, samples=100,blue]
    {263*exp(x)/250-77*x*exp(x)/25-(20*x+13)*cos(deg(3*x))/250-3*(5*x-3)*sin(deg(3*x))/250};
  \end{axis}
\end{tikzpicture}
\end{center}
\medskip

{\bf VI. A. Second-order.}  Given a second-order equation of the
form
\[
  H(t,y',y'')=0
\]
i.e., missing a~$y$-term, we can reduce the order of the equation with the
substitution~$v=y'$. 
\medskip

{\bf Example.}  Consider the equation
\[
  ty''+4y'=t^2.
\]
Substitute~$v=y'$ to get the equation
\[
  tv'+4v=t^2.
\]
If~$t\neq 0$, this becomes the standard first-order equation
\[
  v'+\frac{4}{t}\,v=t.
\]
Say~$t>0$.  Then the integrating factor is~$\exp\left( \int \frac{4}{t}\,dt
\right)=t^4$.  Multiplying through (and using the product rule), we have
\[
t^4\,v'+4t^3\,v=(t^4v)'=t^5.
\]
Integrate:
\[
  t^4v=\frac{1}{6}t^6+c.
\]
Now substitute back~$v=y'$:
\[
  t^4y'=\frac{1}{6}t^6+c.
\]
This is separable:
\begin{align*}
  y'=  \frac{1}{6}t^2+\frac{c}{t^4}\quad\Rightarrow\quad&
  y=\frac{1}{18}t^3-\frac{1}{3}\cdot\frac{c}{t^3}+b\\[8pt]
  &=\frac{1}{18}t^3+\frac{a}{t^3}+b.
\end{align*}
Suppose the initial conditions are~$y(1)=1$ and~$y'(1)=2$.  Then
\begin{align*}
1&= \frac{1}{18}+a+b\\
2&= \frac{1}{6}-3a,
\end{align*}
which implies~$a=-11/18$ and~$b=14/9$.  The solution is
\[
  y=\frac{1}{18}t^3-\frac{11}{18}\,\frac{1}{t^3}+\frac{14}{9}.
\]
Graph of solution:
\begin{center}
\begin{tikzpicture}
  \begin{axis}[
      scale=0.8,
      %title style={at={(0.5,0)},anchor=north,yshift=-30},
      %title={\mbox{\parbox{\textwidth}{Graph of~$P(t)$ with~$K=1000$ and~$P(0)=10$ and two different
      %growth rates:~$r=0.5$ in red and~$r=0.2$ in blue.}}},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      xmin=-3,
      xmax=3,
      ymin=-3,
      %ymax=1100,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=0.5:2.3,thick, samples=100,blue] {x*x*x/18-11/(18*x*x*x)+14/9};
  \end{axis}
\end{tikzpicture}
\end{center}
{\bf Solutions defined near~$t=0$?}  Our method of forcing the equation into the
form of a standard first-order equation requires dividing by~$t$, and hence,
assumes that~$t\neq 0$.  What if we really want a solution defined
near~$t=0$?  My approach was to suppose the solution can be expanded in terms of
a power series~$y=a_0+a_1t+a_2t^2+\dots$  Plug this series into the
equation~$ty''+4y'$ and set the result equal to~$t^2$.  Now compare coefficients
and hope we can solve for the~$a_i$.  If you think about it, we only need to
consider series where~$a_i=0$ for~$i\geq 4$.  So
assume~$y=a_0+a_1t+a_2t^2+a_3t^3$.  We have
\begin{align*}
  ty''+4y'&= t(2a_2+6a_3t)+4(a_1+2a_2t+3a_3t^2)\\
  &= 4a_1+10a_2t+18a_3t^2.
\end{align*}
Setting the result equal to~$t^2$ and comparing coefficients gives~$a_1=a_2=0$,
and~$a_3=1/18$.  The solution is
\[
  y=a_0+\frac{1}{18}\,t^3.
\]
Graph of solution with initial condition~$y(0)=1$:
\begin{center}
\begin{tikzpicture}
  \begin{axis}[
      scale=0.8,
      %title style={at={(0.5,0)},anchor=north,yshift=-30},
      %title={\mbox{\parbox{\textwidth}{Graph of~$P(t)$ with~$K=1000$ and~$P(0)=10$ and two different
      %growth rates:~$r=0.5$ in red and~$r=0.2$ in blue.}}},
      axis lines = middle,
      axis line style={->},
      %axis equal image,
      %xmin=-3,
      %xmax=3,
      %ymin=-3,
      %ymax=1100,
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-2:2,thick, samples=100,blue] {1+x*x*x/18};
  \end{axis}
\end{tikzpicture}
\end{center}
Note that the only possibly initial condition for~$y'(0)$ is~$y'(0)=0$ (why?).
Since this is a second-order equation, we'd expect to be able to set initial
conditions for both~$y$ and~$y'$.  We should try to remember to come back to
this example when we talk about existence and uniqueness of solutions.
\medskip

\textbf{VI. B. Second-order equation.}  
\bigskip

Given a second-order equation of the form
\[
H(y,y',y'')=0
\]
i.e., missing~$t$, we again make the substitution~$v=y'$, but then use the chain
rule like so
\[
  y''=\frac{dv}{dt}=\frac{dv}{dy}\frac{dy}{dt}=v\frac{dv}{dy}.
\]
Substituting, our original equation becomes
\[
  H\left(y,v,v\frac{dv}{dy}\right)=0.
\]
After we find~$v$ as a function of~$y$, we solve for~$y$ by
integrating, as before.
\medskip

{\bf Example.}  Consider the equation
\[
  y''+\left( y' \right)^3y=0.
\]
Let~$v=y'$ and substitute as above to get
\[
  v\frac{dv}{dy}+v^3y=0.
\]
This is first-order linear, but even better, it is separable.
Supposing~$v>0$, the equation becomes
\[
  \frac{1}{v^2}\frac{dv}{dy}=-y.
\]
Integrate:
\begin{align*}
  \int\frac{1}{v^2}\,dv=-\int y\,dy
  &\quad\Rightarrow\quad
  -\frac{1}{v}=-\frac{1}{2}y^2+\tilde{c}\\[8pt]
  &\quad\Rightarrow\quad
  v=\frac{2}{y^2-2\tilde{c}}\\[8pt]
  &\quad\Rightarrow\quad
  v=\frac{2}{y^2+c}.
\end{align*}
Now substitute back in~$v=y'$:
\[
  y'=\frac{2}{y^2+c}
  \quad\Rightarrow\quad
  \int(y^2+c)\,dy=2\int\,dt
  \quad\Rightarrow\quad
  \frac{1}{3}y^3+cy=2t+b.
\]
Suppose our initial conditions are~$y(1)=0$ and~$y'(1)=1$.  Then
\[
  \frac{1}{2}\cdot 0^3+c\cdot0=2\cdot 1+b\quad\Rightarrow\quad b=-2.
\]
So the equation becomes
\[
  \frac{1}{3}y^3+cy=-2+2t.
\]
To use the second condition, take derivatives with respect to~$t$:
\[
  y^2\,y'+cy'=2.
\]
Plug in~$y(1)=0$ and~$y'(1)=1$ to find~$c=2$.
The solution, implicitly, is
\[
  \frac{1}{3}y^3+2y=-2+2t.
\]
\Needspace{3\baselineskip}
Here is a picture of the slope field and our solution:
\begin{center}
  \includegraphics[height=2in]{02frifig.png}
\end{center}
\medskip

\Needspace{3\baselineskip}
\textbf{VII. Duh.} 
\bigskip

If your method of solving a differential equation is not working due to a
troublesome set of initial conditions, consider obvious/trivial solutions.
\medskip

{\bf Example.}  We just solved the equation
\[
  y''+(y')^3y=0.
\]
for a particular set of initial conditions.  If you look back at our method
solution, you'll see that we can find a solution satisfying any initial
conditions~$y(t_0)=\alpha$ and~$y'(t_0)=\beta$, except for those where~$\beta=0$.
That's because we divided by~$v=y'$ in the course of our solution.  What do we
do for the troublesome case of~$\beta=0$?  Applying the ``duh'' method, we
immediately find the solution~$y=\alpha$, a constant function.
\medskip

{\bf Challenge.}  Solve
\[
  y''+(y')^3y=t.
\]
with initial condition~$y(0)=1$ and~$y'(0)=0$.
\end{document}
