\chapter[More Separation of Variables]{Differential Equations II: More Separation of Variables}

In certain practical situations we might want to make simplifying
assumptions that lead to somewhat more complicated differential equations
which are still not too complicated to be solved by the method of
\index{nonlinear separation of variables} separation of variables.  This section is devoted to several examples of
this.

But first we want to illustrate how the general method of separation
of variables can be used to solve differential equations that look quite
different from those in the last chapter.

\begin{example}
\label{example:17.1}
Find an equation for the curve that passes through the point $(2,3)$
and satisfies the differential equation $dy/dx=y^2/x^3$.

\smallskip

We first separate variables in the differential equation, obtaining
\[
\frac{dy}{y^2}=\frac{dx}{x^3}.
\]
If we integrate both sides and combine the constants of integration into
a single constant on the right, we get 
\[
-\frac{1}{y}=-\frac{1}{2}\cdot\frac{1}{x^2}+C.
\]
To find $C$, we use the ``initial data'' that the point $(2,3)$ is on
the curve.  Thus, $-\frac{1}{3}=-\frac{1}{2}\cdot\frac{1}{2^2}+C$,
from which we get $C=\frac{1}{8}-\frac{1}{3}=-\frac{5}{24}$.  Finally,
we solve for $y$ by taking the negative reciprocal of both sides.  The
result is:
\[
y=\frac{1}{\frac{1}{2x^2}+\frac{5}{24}}=\frac{24x^2}{12+5x^2}.
\]

\end{example}

\section{Spread of an Epidemic} 

Suppose that $y(t)$ is the number of people (or some type of animal) who
have a certain contagious disease at time $t$.  We are
interested in the rate of change of $y(t)$, and eventually in a formula for
$y(t)$.  Since the spread of the disease depends on the number of people
from whom one can catch it, we might try supposing that the rate of spread
of the disease is simply proportional to the number who have it, i.e.,
$dy/dt=ky$.  This would lead to the exponential growth function
$y(t)=y_0e^{kt}$, a function which might be a reasonable approximation for
some small time interval, but which clearly is far off for large $t$: the
function $y_0e^{kt}$ rapidly grows without bound, while the total population
has some finite value $P$.  The number of sick people cannot be greater
than the number of people.

\smallskip
So let's try another type of simplifying assumption: {\it that the spread
of the disease is proportional to the number of contacts between a sick
person and a healthy person, and that this, in turn, is proportional to the
product of the number of people with the disease and the number of people
without the disease.} That is, at any time $t$, $dy/dt$ is proportional to
the product of $y(t)$ and $P-y(t)$: 
\[
\frac{dy}{ dt}=ky(P-y).
\]
 It must be
admitted that this \index{model for the spread of an epidemic} model for the spread of an epidemic is still very
simplistic.  It assumes, for instance, that no attempt is made to
quarantine sick people, that everyone is susceptible to the disease, that
someone who gets the disease remains sick (and a carrier) indefinitely, and
so on.  But in some situations
this differential equation is a reasonable approximation to reality.

\smallskip
We now solve the above differential equation by separation of variables.
The first step is to move the $dt$ to the right, to move the part on the
right with $y$ over to the left, and then to insert an integral sign on
both sides: 
\[
\int\frac{dy}{ y(P-y)}=\int kdt=kt+C_2.
\]
 The anti-derivative
on the left can be found by the \index{method of partial fractions} method of partial fractions, i.e., we write:
\[
\frac{1}{ y(P-y)}
=-\frac{1}{(y-0)(y-P)}
=-\frac{1}{ 0-P}\left(\frac{1}{ y}-\frac{1}{y-P}\right)
=\frac{1}{ P}\left(\frac{1}{ y}+\frac{1}{ P-y}\right),
\]
after which we see that the above indefinite integral with respect to $y$ is
\begin{align*} 
\frac{1}{ P}\,(\ln|y|-\ln|P-y|)+C_1&=\frac{1}{ P}(\ln y-\ln(P-y))+C_1\\
\intertext{(since both $y$ and $P-y$ are positive)}
&=\frac{1}{ P}\,\ln \left(\frac{y}{P-y}\right)+C_1.
\end{align*}    
We next move the $C_1$ to the right of the equality, multiply through by
$P$, and set $C=P(C_2-C_1)$.  We then exponentiate both sides.  The result
is 
\[
\frac{y}{ P-y}=e^{Pkt+C}.
\]
 To solve this for $y$, the simplest thing is
to take the reciprocal of both sides, getting 
\[
\frac{P-y}{ y}=\frac{P}{ y}-1=e^{-C}e^{-Pkt}.
\]
To find $y$ we add 1 to both sides, take the
reciprocal again and multiply through by $P$, obtaining: 
\[
  y(t)=\frac{P}{1+e^{-C}e^{-Pkt}}.
\]
 To find $C$ we need some initial information, such as
$y_0=y(0)$.  Substituting $t=0$ (it's simplest to substitute into our
earlier equation which had $(P/y)-1$ on the left) gives:
$e^{-C}=(P/y_0)-1$.  In a practical situation, if you're not given the
value of $k$, you can find it if you know the value of $y(t)$ at some other
particular time.

Cautionary note: The above solution technique works only when $k$ and $P$
are constant with respect to time $t$.

\begin{example}
\label{example:17.2}
Let $y(t)$ denote the fraction of the population having
the disease at time $t$ months (in other words, we are measuring population
in units of fraction of the total, rather than in units of individuals; in
that way the total population $P=1$).  At time $t=0$ suppose that 1\% of
the population are sick, and after a month 10\% are sick.  Find a formula
for $y(t)$, graph $y(t)$, and find out at what time the rate of spread of
the disease starts to slow down.

\smallskip

As shown above, we have 
\[
  y(t)=\frac{1}{ 1+e^{-C}e^{-kt}}.
\] 
\begin{rightindent}{2.5 truein}
\noindent
Substituting
$t=0$ gives $e^{-C}=(1/0.01)-1=99$.  To find $k$, we substitute $t=1$
month: $(1/y(1))-1=e^{-C}e^{-k\cdot 1}=99e^{-k}$, so that $9=99e^{-k}$,
which leads to $-k=\ln(1/11)$, i.e., $k=\ln 11=2.4$.  At the right,
we show the graph of our solution $y(t)=1\bigm/\left(1+99e^{-2.4t}\right)$.
\end{rightindent}
 \hfill
%-figure PA -----------------------------
\begin{psfigure}{2.5in}{1.0in}{figPA.ps}
%\putcrosshair{-1,-1}
%\puttext{0,-1}{}
\end{psfigure}
%------------------------------

To ask when the rate of spread of the disease starts to slow down is the
same as asking when $y'=dy/dt$ reaches its maximum.  This is the point of
inflection in the above graph, which we find by setting $y''=0$.  We could
take the second derivative of our $y(t)$ formula.  But an easier way is to
take $d/dt$ of both sides of the original differential equation
$y'=ky(1-y)$.  Using the product rule on the right, we obtain
\[
y''=ky(-y')+ky'(1-y)=ky'(-y+1-y)=ky'(1-2y).
\]
 This vanishes when $y=1/2$.
In other words, the spread of the disease starts to ease off as soon as
more than 50\% of the population has the disease.  To find the time when
this occurs, we can set the $y(t)$ formula equal to $1/2$ and solve for
$t$.  The result is: approximately 2 months.

\end{example}

\section{More Mixing Problems} 
\index{nonlinear mixing problems}
Suppose that water is being pumped into our container at a constant rate
$r_1$ that is faster than the constant rate $r$ at which water is leaving.
This means that the volume $V$ is no longer constant: it changes at rate
$r_1-r$, and so is given by the formula $V=V_0+(r_1-r)t$.  On the right
side $rk-\frac{r}{ V}y$ of the differential equation in the last section the
effect is to change the first $r$ to $r_1$ and replace the constant volume
$V$ by a function of $t$: 
\[
\frac{dy}{ dt}=r_1k-\frac{ry}{ V_0+(r_1-r)t}.
\]
If $k\ne 0$ and we try to solve this by separation of variables, we find
that we are stymied.  This problem can be solved by a different technique
that will not be covered in this course, but it cannot be solved by
separation of variables.  So for now let us assume that $k=0$, i.e., that
fresh water is being pumped into the container.  In that case, we can use
separation of variables: we divide both sides by $y$, multiply both sides
by $dt$, and put an integral sign in front of both sides: 
\[
\int\frac{dy}{ y}
=\int-\frac{r\,dt}{ V_0+(r_1-r)t}
=-\frac{r}{V_0}\int\frac{dt}{ 1+\frac{r_1-r}{ V_0}t}.
\]
Performing both integrations, we obtain 
\[
\ln|y|+C_1=-\frac{r}{ r_1-r}\,\ln\Bigl|1+\frac{r_1-r}{ V_0}t\Bigr|+C_2.
\]
 Since the expressions in
the absolute value signs are both positive, we can drop the absolute value.
We also set $C=C_2-C_1$ and exponentiate both sides.  The result is:
\[
y(t)=e^C\left(1+\frac{r_1-r}{ V_0}t\right)^{-r/(r_1-r)}.
\]
Finally, by substituting $t=0$ on both sides, we find that $e^C=y(0)=y_0$.

\smallskip

Notice that this \index{variant on the mixing problem} variant on the mixing problem has a very different
solution from the variant we treated in the last section, where we had
$r_1=r$.  Finally, be careful to note that the above solution is correct
only when $r$ and $r_1$ are constants (do not change with $t$).

\begin{example}
\label{example:17.3}
At time $t=0$ a container has $y_0$ gm of salt dissolved
in 100 liters of water.  Fresh water is pumped into the container at 5
liters/min, and the well-mixed solution leaves the container at 3
liters/min.  Find a formula for the amount of salt in the water at time
$t$.

\smallskip
In this problem $V_0=100$, $r_1=5$, and $r=3$.  Hence, by the formula just
derived, $y(t)=y_0(1+0.02t)^{-1.5}.$

\end{example}

\section{Harmonic Oscillation}

Suppose that we have an object of mass $m$ at the end of a spring.  Let
$y(t)$ be the distance of the object from the equilibrium
point at time $t$ (i.e., the distance through which the spring is
extended).  We shall assume that the only force on the object is
that of the spring (i.e., we neglect friction, air resistance, gravity, 
etc.).  We shall also assume the following basic physical relationship:
{\it the force of the spring is proportional to the amount by which the
string is extended}.  Since acceleration is proportional to force
(it is equal to force divided by $m$), it follows that the acceleration
$\ddot{y}(t)$ is proportional to $y(t)$.  Note that the direction of pull
is {\it opposite} to the direction of extension --- that is, if the string is
extended, then the pull is inward, i.e., negative; while if the string is
compressed, then the pull is outward, i.e., positive.  Thus, the
proportionality constant between $\ddot{y}(t)$ and $y(t)$ is negative;
we shall let $-k$ be this constant.  Thus, the distance function $y(t)$
satisfies the differential equation 
\[
\ddot{y}=-ky.
\]
This is called a \index{{\it second order} differential equation} {\it second order} differential equation, because it
involves the {\it second} derivative.  Before solving it, we rewrite it
in the form 
\[
\ddot{y}+ky=0.
\]

Instead of worrying about the differential equation in its present form,
we instead look at a different expression involving only $y(t)$ and
its {\it first} derivative $\dot{y}(t)$: 
\[
\dot{y}^2+ky^2.
\]
 This is
basically the sum of the squares of the function and its first derivative,
with the constant $k$ thrown in.  Why would we want to look at that?
In the next paragraph we'll say something about where this expression comes
from.  For now what we want to do is just take its derivative:
\[
\frac{d}{ dt}\Bigl(\dot{y}^2+ky^2\Bigr)=2\dot{y}\,\ddot{y}+2ky\,\dot{y}=
2\dot{y}(\ddot{y}+ky).
\]
 But according to our differential equation,
$\ddot{y}+ky=0$, so the derivative of our sum-of-squares expression
is zero.  The only function with zero derivative is a constant.  What
is the value of this constant?  We use our initial conditions to answer
this question: at time $t=0$ the sum-of-squares
expression has value $\dot{y}(0)^2+ky(0)^2=v_0^2+ky_0^2$.  Let us suppose
that the object is at location 0 at time $t=0$; then the constant is
simply $v_0^2$, where $v_0$ is the object's initial velocity.  We conclude that
$\dot{y}^2+ky^2=v_0^2$.

Before solving this last differential equation, we make a remark about
where the sum-of-squares expression comes from.  It is essentially what
physicists call the {\it energy} of the object.  More precisely, if we
multiply it by the constant $\frac{1}{ 2} m$ (where $m$ is the mass),
we get the energy.  The conclusion of the last paragraph --- that this
is constant --- is an example of another fundamental principle of physics,
the {\it \index{law of conservation of energy} law of conservation of energy}.  If we work only with the
mathematics, then admittedly the expression $\dot{y}^2+ky^2$ seems to
be pulled out of a hat.  However, if we know a little physics, then
the method of solving this differential equation seems quite natural.

Anyway, we now have the differential equation 
\[
\dot{y}^2+ky^2=v_0^2,
\]
which we shall see can be solved by separation of variables.  If we
move $ky^2$ to the right and take square roots, we get (using
the notation $dy/dt$ instead of $\dot{y}$)
\[
\frac{dy}{ dt}=\sqrt{v_0^2-ky^2},
\]
 and then, separating variables,
\[
\int\frac{dy}{\sqrt{v_0^2-ky^2}}=\int dt.
\]
On the left, if we pull the $k$ out of the radical (so that it becomes
$\sqrt{k}$) and set $r^2=(v_0/\sqrt{k})^2$, then we have Example 7.8 of
the chapter on inverse trig functions (with $y$ in place of $x$ and
with $r$ replaced by $v_0/\sqrt{k}$).  Using the answer to Example 7.8,
we find that the anti-derivative on the left is
\[
\frac{1}{\sqrt{k}}{\rm Arcsin}\left(\frac{y}{v_0/\sqrt{k}}\right)+C_1.
\]
Thus, we can write
\[
\frac{1}{\sqrt{k}}{\rm Arcsin}\left(\frac{y}{v_0/\sqrt{k}}\right)=t+C
\]
(where $C=C_2-C_1$ is the difference of the constants of integration
that one gets on the right and on the left).  To find $C$ we again use
the initial information that $y(0)=0$ when $t=0$; since Arcsin$(0)=0$,
we find that $C=0$.  Finally, we solve for $y$ by multiplying through
by $\sqrt{k}$ and then taking the sine of both sides:
\[
\frac{y}{ v_0/\sqrt{k}}=\sin(\sqrt{k}\,t),\qquad{\rm so~that}\qquad
y(t)=\frac{v_0}{\sqrt{k}}\sin(\sqrt{k}\,t)=\frac{v_0}{\omega}\sin(\omega
t),
\]
where we have set $\omega=\sqrt{k}$, which is the angular frequency.

Thus, the object oscillates back and forth with sinusoidal motion having
period $2\pi/\omega$.  This motion is called {\it \index{harmonic oscillation} harmonic oscillation}.

Notice that once we have found the function $y(t)=\frac{v_0}{\omega}
\sin(\omega t)$, it is very easy to check that it really does satisfy
the original differential equation $\ddot{y}=-ky=-\omega^2y$;
namely, just take the second derivative of $y(t)$, and see that both sides
of the equality are equal to $-v_0\omega\sin(\omega t)$.  It is also clear that
$y(0)=0$ and $\dot{y}(0)=\frac{v_0}{\omega}\cdot\omega\cdot\cos(\omega\cdot 0)
=v_0$.

What would happen if we had to take into account friction or air
resistance?  Suppose that this contributed a force proportional to
velocity (as we assumed in Section 3 of Chapter 16).  Then our
original differential equation would have another term equal to a constant
times $\dot{y}$.  One can show that the solution is a function similar
to Example 10.2 in the chapter on the exponential function --- it has an
exponential decay factor.  This is called {\it \index{damped harmonic oscillation} damped harmonic oscillation}.

%%---------------------------------------------------------------
