\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{latexsym}
\usepackage[pdftex]{graphicx}
\usepackage[table]{xcolor}
\usepackage{url}
\usepackage{mathdots}
\usepackage{mathrsfs}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\input{preamble.tex}

\begin{document}
\lecture{7: Differential Equations}{Week 7}

This is the seventh week of the Mathematics Subject Test GRE prep course; here, we review various techniques used to solve \textbf{differential equations}!

\section{Definitions and Concepts}

A \textbf{differential equation} is any mathematical equation that relates some collection of functions to their derivatives; the mathematical fields of ordinary and partial differential equations study various methods used to find all of the functions that satisfy such equations.

More so than most other fields of mathematics, the study of ordinary and partial differential equations is far more focused on its processes than its theorems; in other words, mathematicians in these areas are less concerned with recognizing and applying various large theorems, and are more concerned with the practical nitty-gritty of solving and working with specific classes of equations.  To give an example, think of the difference in feel between studying limits and series in calculus, versus integrating various functions in calculus.  In the first subject, most of your proofs involve sticking together various results (i.e.\ the mean value theorem, the squeeze theorem, etc) to solve problems.  The second, however, feels much more like an art --- when integrating functions, you're mostly looking for the right clever use of substitution/parts/trig identities/change of variables/etc to solve your specific equation!

Accordingly, our review section here is a bit different than other review sections.  Here, we sketch several basic techniques for solving various differential equations; in the second half of this talk, we use these techniques to solve several GRE-styled problems from the field.  Our listing of techniques is (of course) partial, as mathematics itself only knows techniques for solving some families of differential equations!  However, almost all of the problems you encounter on the GRE will be approachable with one of these techniques.

Finally, one last note about the specific structure of the GRE itself: due to the nature of the GRE as a multiple-choice test, it will sometimes be possible to simply ``plug in'' your five possible answers into your differential equation, and eliminate answers based on those that do not solve your question!  This may not always be the most time-efficient approach, as it will require you to take derivatives of between one to five functions; but derivation is usually pretty ``easy'' as far as mathematical operations go.  Do not be afraid to ``game'' the GRE in this manner; it is a multiple-choice test, and you should exploit this structure to your advantage!

\begin{enumerate}
\item \textbf{Separable first-order differential equations.}  Suppose that you have a differential equation of the form
\begin{align*}
M(x)N(y) = \frac{dy}{dx}.
\end{align*}
for two functions $M(x), N(y)$.   We can solve this equation by ``separating'' $M(x)$ from $N(y)$:\ that is, by dividing both sides by $N(x)$ and ``multiplying'' by $dx$ to get\footnote{Formally speaking, we are doing something more subtle than multiplying through by $dx$, because what would that even mean?  What \textit{is} a dx, outside of an integral?  For rigorous answers to this, take courses on analysis and differential equations!  For now, however, just roll with it.}  the following:
\begin{align*}
M(x) dx = \frac{1}{N(y)} dy.
\end{align*}
Integrating both sides yields
\begin{align*}
\int M(x) dx = \int\frac{1}{N(y)} dy,
\end{align*}
which gives us a relation that can be used to solve for $y$ with algebra/other techniques.

Be aware that this equation above only gives us solutions for which $g(y) \neq 0.$  In the event that $g(y)$ is identically 0 --- i.e. $y$ is a constant --- you would need to check this manually by seeing if a constant value of $y$ can solve our equation.

We calculate an example here:
\begin{exmp}
Solve the differential equation
\begin{align*}
\frac{3x^2 + 1}{2y-3} = \frac{dy}{dx},
\end{align*}
with the boundary condition that when $x = 0$, $y = 0$ as well.
\end{exmp}
\begin{proof}
We simply separate variables and solve:
\begin{align*}
& \frac{3x^2 + 1}{2y-3} = \frac{dy}{dx}\\
\Rightarrow & \int(3x^2 + 1)dx = \int(2y-3) dy \\
\Rightarrow & x^3 + x  = y^2 - 3y + c\\
\end{align*}
Because $(0,0)$ is a point that should be a solution to our equation, we can see that $c = 0$, and that our equation is (solving for $y$)
\begin{align*}
 & x^3 + x  = y^2 - 3y\\
\Rightarrow & y^2 - 3y - (x^3 + x) = 0\\
\Rightarrow y = \frac{ 3 \pm \sqrt{ 9 + 4(x^3 + x)}}{2}.
\end{align*}
At $x = 0$, this expression is $\frac{3 \pm 3}{2}$, which we know should be 0; this tells us that we want the positive branch of this expression, i.e.\
\begin{align*}
y = \frac{ 3 + \sqrt{ 9 + 4(x^3 + x)}}{2}.
\end{align*}
\end{proof}

\item \textbf{Homogeneous first-order differential equations.}  Suppose that you have a differential equation of the form
\begin{align*}
M(x,y) + N(x,y)\frac{dy}{dx} = 0,
\end{align*}
where $M(x,y), N(x,y)$ are a pair of degree-$n$ \textbf{homogeneous} equations\footnote{ A function $f(x,y)$ of two variables is called \textbf{homogeneous} of degree $n$ if $f(tx, ty) = t^nf(x,y)$ for all $t, x, y$.  For example, $f(x,y) = x^2 + xy + y^2$ is homogeneous of degree 2, as $f(tx, ty) = t^2x^2 + txty + t^2y^2 = t^2f(x,y)$.}.  We can solve this differential equation by defining $v = y/x$, which lets us make the substitution $y = xv$, and yields the equation
\begin{align*}
M(x,xv) + N(x,xv)\frac{d}{dx}(xv) = 0.
\end{align*}
If $M, N$ are homogeneous of degree $n$, this yields
\begin{align*}
x^n\cdot M(1,v) + x^n \cdot N(1,v) \cdot \left( v + x\frac{dv}{dx}\right) = 0,
\end{align*}
which we can solve for $\frac{dv}{dx}$  to get
\begin{align*}
 \frac{dv}{dx}= \left(-\frac{N(1,v)}{M(1,v)} - v\right) \cdot \frac{1}{x}.
\end{align*}
This is a separable differential equation, and therefore is solvable by our earlier methods!  Use them to solve this differential equation, and then finally substitute $v = y/x$ back to get a solution for our original problem.

We calculate an example here:
\begin{exmp}
Solve the differential equation
\begin{align*}
x^2y + y^2x \frac{dy}{dx} = 0,
\end{align*}
given the boundary condition that at $x = 0$ we want $y = 1$.
\end{exmp}
\begin{proof}
The two functions $M(x,y) = x^2 y, N(x,y) = xy^2$ are both homogeneous of degree 3, so we can attempt to proceed as directed above.  We start by substituting in $y = xv$, and performing various algebraic manipulations:
\begin{align*}
& x^3v + x^3v^2 \left( v + x\frac{dv}{dx}\right)  = 0\\
\Rightarrow & v + x\frac{dv}{dx} = \frac{-x^3v}{x^3v^2}\\
\Rightarrow & x\frac{dv}{dx} = -\frac{1}{v} - v\\
\Rightarrow & -\frac{1}{\frac{1}{v} + v} dv = \frac{1}{x} dx.\\
\end{align*}
Integrating both sides of this separable equation gives us
\begin{align*}
-\int \frac{1}{\frac{1}{v} + v} dv = -\int \frac{v}{1+v^2} dv = -\frac{1}{2}\ln(1+v^2) = \int \frac{1}{x} dx = \ln(x) + c.
\end{align*}
Plugging in $v = y/x$ yields
\begin{align*}
 &-\frac{1}{2}\ln\left( 1 + \frac{y^2}{x^2} \right) =  \ln(x) + c\\
\Rightarrow & 1 + \frac{y^2}{x^2} = e^{-2\ln(x) + c} = c \cdot \left(e^{\ln(x)}\right)^{-2} = \frac{c}{x^2}\\
\Rightarrow & y^2 = c - x^2 \\
\Rightarrow & y = \pm \sqrt{c - x^2}.\\
\end{align*}
At $x = 0$ we wanted $y = 1$; so this tells us that $c = 1$ and our sign is positive, and therefore that $y = \sqrt{1-x^2}$ is our answer!

Notice how we repeatedly ignore the constants, signs, etc. that $c$ is multiplied by, as it's just a constant (and therefore we don't really care if it's two times some other constant.)
\end{proof}



\item \textbf{Linear first-order differential equations.}  Suppose that you have a differential equation of the form
\begin{align*}
\frac{dy}{dx} + P(x) y = Q(x),
\end{align*}
and we want to solve for $y$ as a function of $x$.  We can solve this equation by multiplying both sides by the ``integrating factor\footnote{An \textbf{integrating factor} is some cleverly-chosen function that we multiply both sides of a differential equation by to make it simpler in some appropriate sense.} ''
\begin{align*}
\mu(x) = e^{\int P(x) dx}.
\end{align*}
If we do this, then we get
\begin{align*}
\frac{dy}{dx} \mu(x) + P(x) y \mu(x) = Q(x)\mu(x).
\end{align*}
However, the product rule tells us that the LHS above is just $\frac{d}{dx} (\mu(x) \cdot y)$.  Therefore, our equation is now of the form
\begin{align*}
\frac{d}{dx} (\mu(x) \cdot y)= Q(x)\mu(x).
\end{align*}
Integrating both sides with respect to $x$ yields
\begin{align*}
y= \frac{1}{\mu(x)} \int Q(x)\mu(x)dx .
\end{align*}
Success!

We calculate an example here:
\begin{exmp}
Solve the differential equation
\begin{align*}
 \frac{dy}{dx} + x^2 y= x^5,
\end{align*}
given the boundary condition that at $x = 0$ we want $y = 0$.
\end{exmp}
\begin{proof}
This is a linear differential equation; therefore if we multiply both sides by the integrating factor $e^{\int x^2 dx} = e^{x^3/3}$, and go through all of the steps above we get
\begin{align*}
&\frac{dy}{dx}e^{x^3/3} + x^2 ye^{x^3/3}= x^5e^{x^3/3}\\
\Rightarrow & \frac{\partial}{\partial x} \left( ye^{x^3/3}\right) = x^5e^{x^3/3}\\
\Rightarrow &  \left( ye^{x^3/3}\right) = \int x^5e^{x^3/3} dx.\\
\end{align*}
To integrate the RHS, we use the substitution $u = x^3/3$, motivated by the fact that $e^{\textrm{anything not just a single variable}}$ is a total pain to calculate:\ as $du = x^2 dx$ and $3u = x^3,$ we get
\begin{align*}
&\left( ye^{x^3/3}\right) = \int x^5e^{x^3/3} dx\\
\Rightarrow &\phantom{\left( ye^{x^3/3}\right)}  = \int x^3 e^{x^3/3} x^2 dx\\
 &\phantom{\left( ye^{x^3/3}\right)}  = \int 3u e^{u} du\\
 &\phantom{\left( ye^{x^3/3}\right)}  = 3ue^u - 3e^u + C\\
 &\phantom{\left( ye^{x^3/3}\right)}  = e^{x^3/3}(x^3 -3) + C\\
\Rightarrow &\phantom{\left( e^{x^3/3}\right)} y = x^3 - 3 + \frac{C}{e^{x^3/3}}.
\end{align*}
Our boundary conditions tell us that we want $(0,0)$ to be a solution to our equation:\ in other words, that $3 = C$.
\end{proof}



\item  \textbf{Exact first-order differential equations.}  Suppose that you have a differential equation of the form
\begin{align*}
M(x,y) + N(x,y)\frac{dy}{dx} = 0,
\end{align*}
where $\frac{\partial}{\partial y} M(x,y) = \frac{\partial}{\partial x} N(x,y)$.  Now, take any function $F(x,y)$ that is the antiderivative of $M(x,y)$ with respect to $x$, and also the antiderivative of $N(x,y)$ with respect to $y$:\ i.e. some function $F(x,y)$ such that
\begin{align*}
F(x,y) = \int M(x,y) dx + C_y,\\
F(x,y) = \int N(x,y) dy + C_x,\\
\end{align*}
Note that I have written $C_y, C_x$ instead of the normal constants $C$; this is because when we integrate with respect to $x$, $y$ is held constant (and similarly for $y,x$.)  Therefore, terms involving the coefficient we are not integrating by are ``constants'' that can show up in our solution!  (This is why we need to consider integrating both $M(x,y)$ and $N(x,y)$, and not just one of the two.)  

Fun fact we're not proving here:\ such a function always exists for exact differential equations, and you can always find it!

When you do, you'll get that  $ \frac{\partial}{\partial x} F(x,y) = M(x,y),   \frac{\partial}{\partial y} F(x,y) = N(x,y)$.  Therefore, we can write our differential equation in the form
\begin{align*}
\frac{\partial}{\partial x} F(x,y) + \frac{\partial}{\partial y} F(x,y) \frac{dx}{dy} = 0.
\end{align*}

But this is simply the total derivative of the function $F(x,y)$!  Therefore, if we are asking that this total derivative is 0, we are looking for the set of all points $(x,y)$ on which $F(x,y)$ is constant; that is, the set of all level curves of $F(x,y)$, i.e.
\begin{align*}
F(x,y) = c.
\end{align*}


We calculate an example here:
\begin{exmp}
Solve the differential equation
\begin{align*}
y\cos(xy) + x\cos(xy) \frac{dy}{dx} = 0,
\end{align*}
given the boundary condition that at $x = 1$ we want $y = 0$.
\end{exmp}
\begin{proof}
We first notice that because
\begin{align*}
\frac{\partial}{\partial y} (y \cos(xy)) = \cos(xy) - xy\sin(xy) = \frac{\partial}{\partial x} (x \cos(xy)),
\end{align*}
this differential equation is indeed exact.  Therefore, we are seeking some function $F(x,y)$ such that 
\begin{align*}
F(x,y) =& \int M(x,y) dx = \int y \cos(xy) dx = \sin(xy) + C_y,\\
F(x,y) =& \int N(x,y) dy = \int x \cos(xy) dy = \sin(xy) + C_x;
\end{align*}
i.e. $F(x,y) = \sin(xy) + C$.  Our solutions are simply the level curves of this function; i.e. the set of all points $(x,y)$ satisfying $\sin(xy) = c$.  If we want $(1,0)$ on this curve, we want $\sin(0) = C$; i.e. $C= 0$, and therefore that our solutions are the set of all points satisfying $\sin(xy) = 0$.
\end{proof}


\item \textbf{Nonexact first-order differential equations.}   Sometimes you have a differential equation 
\begin{align*}
M(x,y) + N(x,y)\frac{dy}{dx} = 0,
\end{align*}
that is not exact, but is not too far from it.  In these situations, we can sometimes be ``clever'' and multiply both the LHS and RHS by a cleverly-chosen integrating factor $\mu(x)$ or $\mu(y)$, so that the resulting equation \textbf{is} exact!    In practice, it can be very easy or very difficult to find an integrating factor.  We list a few special cases where such factors have predictable forms here:
\begin{itemize}
\item Suppose that $\displaystyle \frac{\frac{\partial}{\partial y} M(x,y) - \frac{\partial}{\partial x} N(x,y)}{N(x,y)}$ is a function $\xi(x)$ that only depends on the variable $x$.  Then $\mu(x) = e^{\int \xi(x) dx}$ is an integrating factor for our differential equation.
\item Suppose that $\displaystyle \frac{\frac{\partial}{\partial y} M(x,y) - \frac{\partial}{\partial x} N(x,y)}{M(x,y)}$ is a function $\psi(y)$ that only depends on the variable $y$.  Then $\mu(y) = e^{\int \psi(y) dy}$ is an integrating factor for our differential equation.
\end{itemize}

We calculate an example here:
\begin{exmp}
Solve the differential equation
\begin{align*}
(3x^2y + y^3 + 2yx) + (x^2 + y^2) \frac{dy}{dx} = 0,
\end{align*}
given the boundary condition that at $x = 0$ we want $y = 0$.
\end{exmp}
\begin{proof}
We first notice that because
\begin{align*}
\frac{\partial}{\partial y} (3x^2y + y^3 + 2yx) = 3x^2 + 3y^2 + 2x,\\\
 \frac{\partial}{\partial x} (x^2 + y^2) = 2x,\\
\end{align*}
we are sadly not exact.  However, we do have that
\begin{align*}
\frac{\frac{\partial}{\partial y} M(x,y) - \frac{\partial}{\partial x} N(x,y)}{N(x,y)}  = \frac{ 3x^2 + 3y^2 + 2x - 2x}{x^2 + y^2} = 3
\end{align*}
is indeed a function $\xi(x)$ that only depends\footnote{Well, really, it doesn't depend on anything.  But that's OK: constant functions are functions!} on the variable $x$!  Therefore, as suggested above, we can multiply both sides by the integrating factor $e^{\int \xi(x) dx} = e^{3x}$, to get
\begin{align*}
(3x^2y + y^3 + 2yx)e^{3x} + (x^2 + y^2)e^{3x} \frac{dy}{dx} = 0.
\end{align*}
We can see that this equation now \textbf{is} exact, as
\begin{align*}
\frac{\partial}{\partial y} (3x^2y + y^3 + 2yx)e^{3x} = (3x^2 + 3y^2 + 2x)e^{3x},\\\
 \frac{\partial}{\partial x} (x^2 + y^2)e^{3x} = 2xe^{3x} + (x^2 + y^2) 3e^{3x}\\
\end{align*}
are both equal.  Therefore, we can find a solution by integrating $(3x^2y + y^3 + 2yx)e^{3x},(x^2 + y^2)e^{3x}$ appropriately:
\begin{align*}
F(x,y) =& \int (3x^2y + y^3 + 2yx)e^{3x} dx \\
& y\left( x^2 e^{3x} - \frac{2}{3}xe^{3x} + \frac29e^{3x}\right) + \frac{y^3}{3} e^{3x} + y\left( \frac23 xe^{3x} - \frac29 e^{3x} \right) + C_y \\
=& yx^2e^{3x} + \frac{y^3}{3} e^{3x} + C_y.\\\
F(x,y) =& \int (x^2 + y^2)e^{3x} dy \\
=& yx^2e^{3x} + \frac{y^3}{3} e^{3x} + C_x.\\\
\end{align*}
So we have
\begin{align*}
F(x,y) =  e^{3x} + y\left( \frac23 xe^{3x} - \frac29 e^{3x} \right) + C,
\end{align*}
Solutions to our differential equation are level curves of this function; i.e. all $x,y$ such that
\begin{align*}
yx^2e^{3x} + \frac{y^3}{3} e^{3x} = C.
\end{align*}
Asking that $(0,0)$ is on such a curve is simply the restriction that $C = 0$; that is, we have
\begin{align*}
yx^2e^{3x} + \frac{y^3}{3} e^{3x} = 0.
\end{align*}
\end{proof}


\end{enumerate}

\section{Example GRE Problems}
We work four example problems here, taken from the three GRE exams you've completed thus far in this class:

\begin{problem}
Let $y = f(x)$ be a solution of the differential equation 
\begin{align*}
x dy + (y - xe^x)dx = 0,
\end{align*}
chosen such that $y = 0$ at $x=1$.   What is the value of $f(2)?$
~\\
\begin{center}
\begin{tabular}{|c|c|c|c|c|}\hline
(a) \quad$\frac{1}{2e}$ \quad& (b) \quad$\frac{1}{e}$\quad& (c) \quad$\frac{e^2}{2}$\quad& (d) \quad$2e$\quad& (e) \quad$2e^2$\quad\\\hline
\end{tabular}
\end{center}
\end{problem}
\begin{answer}
Notice that this equation is exact, as
\begin{align*}
\frac{\partial}{\partial y} (y - xe^x) = 1,\\\
\frac{\partial}{\partial x} (x)  = 1.\\
\end{align*}
Therefore, we can solve this by simply integrating these two functions appropriately:
\begin{align*}
F(x,y) &= \int (y - xe^x)dx =  xy - xe^x + e^x + C_y,\\\
F(x,y) &= \int x~dy = xy + C_x. \\\
\end{align*}
Combining these results gives us $F(x,y) = xy - xe^x + e^x + C$, which we want to find level curves for; i.e. our solutions look like $xy - xe^x + e^x = C$.  If we plug in the point $(1,0)$, we get $C = 0$. Finally, if we want to find out what happens when we have $x = 2$, note that
\begin{align*}
 2y - 2e^2 + e^2  = 0
\end{align*}
implies that $y = f(2)$ is just $\frac{e^2}{2}$.  In other words, our answer is (c).

\end{answer}


\begin{problem}
Which of the following five pictures gives the graphs of two functions satisfying the differential equation
\begin{align*}
\left( \frac{dy}{dx}\right)^2 + 2y \frac{dy}{dx} + y^2 = 0?
\end{align*}
~\\
\begin{center}
\includegraphics[width=5in]{diff_eqn_gre1.pdf}
\end{center}
\end{problem}
\begin{answer}

Factoring our equation yields
\begin{align*}
\left( \frac{dy}{dx} + y\right)^2  = 0,
\end{align*}
so we can simply take a square root to get the simpler problem
\begin{align*}
\frac{dy}{dx} + y = 0.
\end{align*}
This is a very simple separable differential equation; we can separate it accordingly to get
\begin{align*}
\frac{1}{y} dy = -dx \Rightarrow \ln(y) = -x + C \Rightarrow y = Ce^{-x}.
\end{align*}
The only answer whose curves have $Ce^{-x}$-like behavior is (a), so we have answered our question.
\end{answer}


\begin{problem}
Suppose that we have a tank of water.  This tank is a cube with vertical sides, no top, and side length 10 feet.  Let $h(t)$ denote the height of the water level, in feet, above the floor of the tank at time $t$.

Suppose that at time $t=0$ water begins to pour into the tank at a constant rate of 1 cubic foot per second, and also begins to pour out of the tank at a rate of $\frac{h(t)}{4}$ cubic feet per second.  As $t$ approaches infinity, what is the limit of the volume of the water in the tank?

\begin{center}
\begin{tabular}{|c|c|c|c|}\hline
(a) \quad 400 ft$^3$ \quad& (b) \quad 600 ft$^3$ & (c) \quad 1000 ft$^3$ \quad& (d) \quad The limit DNE.\quad\\\hline
\multicolumn{4}{ |c| }{(e) \quad We do not have enough information to solve this problem. \quad}\\\hline
\end{tabular}
\end{center}
\end{problem}
\begin{answer}
We note that on one hand, if we let $V$ denote the volume of our tank, we have $V = 100 h$; consequently, we have that $\frac{dV}{dt} = 100 \frac{dh}{dt}$.  Conversely, we are given $\frac{dV}{dt}$ directly as $1 - h/4$; therefore, by combining, we have the differential equation
\begin{align*}
 \frac{dh}{dt} + \frac{1}{400} h = \frac{1}{100}.
\end{align*}
This is linear; therefore, if we multiply both sides by the integrating factor $e^{\int(1/400)dt} = e^{t/400}$, we get
\begin{align*}
& \frac{dh}{dt}e^{t/400} + \frac{1}{400}e^{t/400} h = e^{t/400} \frac{1}{100}\\\
\Rightarrow & \frac{d}{dt} \left( h e^{t/400}\right) = e^{t/400} \frac{1}{100}\\
\Rightarrow &  h e^{t/400} = \int e^{t/400} \frac{1}{100} dt\\
 &  \phantom{h e^{t/400}} = 4 e^{t/400} + C\\
 \Rightarrow & \phantom{e^{t/400}} h  = 4 + \frac{C}{e^{t/400}}.\\
\end{align*}
As $t$ goes to infinity, this expression converges to 4; therefore the volume, which is $100h$, goes to 400.  So our answer is (a).

\end{answer}





\end{document}