% SIMIODE-TeacherStudent-Template.tex and simiode.cls for LaTeX2e
% Version 22 November 2016.
% 
% This template is to be used with the  class file "simiode.cls". 
%  
% The latest version of this class and template files 
% can be found at
% 
%       <http://www.SIMIODE.org> in the Author section.
%
% A "Quick Start Guide" appears below.
%
% This file must be processed with version LaTeX2e or higher.
% Appreciation to Mark Frantz, IUPUI; John Thoo, Yuba College; and Eric Sullivan, Carroll College.
%
\documentclass{simiode}
%
% With this version of the tex file and the associated SIMIODE.cls file you can produce BOTH a Student Version and a Teacher Version of your modeling scenario or technique narrative.
%
% Student Version contains the title STUDENT VERSION along with the NAME OF SCENARIO, with no abstract, no keywords, no tags, no author identifiers, and no COMMENTS section. The Student Version contains only the STATEMENT of the modeling scenario only with appropriate figures, data, instructions, and perhaps a bibliography appropriate for student resourcing, but nothing in the bibliography which would "give away" the nature of the modeling scenario, etc.
%
%The Teacher Version contains the material in the Student Version, namely the title NAME OF SCENARIO, now headed with   TEACHER VERSION, but also full author  identification, abstract, key words, tag words, and, following the STATEMENT, a section of COMMENTS which can be discussion of presentation  ideas, "solutions," techniques, etc.
%
% Authors can prepare a full Teacher Version using the notions immediately below  to create a pdf for review, but in review please eliminate all information about the author as we use a double-blind referee system. Such information will be restored when accepted and published in SIMIODE at www.simiode.org.
%
%***********   Toggle the following line to turn the teacher version on (1) or off (0). ***********
%
\def\TeacherEdition{0} % Toggle this line's value.
\newcommand{\teacher}[1]{\ifnum\TeacherEdition=1 #1 \fi}
%
% The \teacher{ } command wraps any text that will appear only in the teacher version of
% the document. See this file for examples. This has been done for you in the document below.   
% Rename the pdf after you compile each final version.
%
\usepackage{amsmath,amssymb}
\usepackage{color}
\usepackage{graphicx}
%\usepackage{hyperref}
\usepackage{url}
%
\renewcommand{\baselinestretch}{1.3}
%
% NOTE regarding macros %%
%
% Any macros defined for your paper should be contained in 
% the top matter. Likewise, any environment definitions such 
% as \newtheorem or \newenvironment should also go in the 
% top matter. 
% 
% Do not \input your macros as separate files within your 
% final version because more files make it harder for the 
% editors and users to keep track of and/or modify and 
% append your paper.
%
% Top matter is above and the beginning of the document below.
%
\begin{document}

\newpage
%
% You only need to change the NAME OF SCENARIO in the next line and delete the footnote. 
% See above for instructions on toggling from Teacher Version to Student Version.
%
\title{\ifnum\TeacherEdition=1 TEACHER VERSION  \else STUDENT VERSION \fi\\Separation of Variables}



\markboth{Separation of Variables}{Separation of Variables}

\author{Brian Winkel\\ Director
SIMIODE\\
Chardon OH 44024 USA\\
BrianWinkel@simiode.org}


\makeStitlePDFLaTex


\begin{abstract}
We discuss  strategies  to solve first order, ordinary differential equations with  mathematical models when the variables may be separated.
\end{abstract}












\section*{DESCRIPTION}

We discuss  strategies  to solve first order, ordinary differential equations with  mathematical models when the variables may be separated.  Many modeling situations which lead to such equations:

\begin{itemize}
\item [M1.] Exponential growth or decay

$$\frac{dy}{dt} = k y(t) \label{eq:ExpGrowthDecay}$$

\item [M2.] Logistic
$$\label{eq:Logistic}
\frac{dy}{dt} = r y(t)\frac{K - y(t)}{K} 
$$
\item [M3.] Extinction population levels
$$\label{eq:LogisticHarvest}
\frac{dy}{dt} = r y(t)\frac{K - y(t)}{K}\frac{y(t) - M}{M}    
$$
\item [M4.] Logistic with harvesting 
$$\label{eq:Extinction}
\frac{dy}{dt} = r y(t)\frac{K - y(t)}{K}  - h
$$
\item [M5.] Gompertz
$$\label{eq:Gompertz}
\frac{dy}{dt} = -r y(t)\log\left(\frac{y(t)}{M}\right)
$$
where if we substitute $x(t) = \log\left(\frac{y(t)}{M}\right)$ we obtain  the differential equation $x'(t) = - k x(t)$ 
\item [M6.] Spread of technology
$$\label{eq:SpreadTech}
\frac{ds}{dt} = r s(t)(K - s(t))
$$
\item [M7.] Newton's Law of Cooling
$$\label{eq:NewtonCool}
\frac{dT}{dt} = k(T_{\rm Env} - T(t))
$$
\item [M8.] Tumor growth
$$\label{eq:TumorGrowth}
\frac{dV}{dt} = \lambda V(t)
$$
\item [M9.] Lambert's Absorption Law for light beam intensity
$$\label{eq:LambertsLaw}
 \frac{dI}{dt} = \mu I(t)
$$\item [M10.] Falling bodies with resistance
$$\label{eq:TumorGrowth}
m \frac{dv}{dt} = - c v(t) - m g
$$
\item [M11.] Mixing problems
$$\label{eq:Mixing}
 \frac{dA}{dt} = A_{\rm Rate\,\,In} - \alpha A(t)
$$
\item [M12.] Chemical kinetics
$$\label{eq:ChemKinetics}
 \frac{dA}{dt} = - k A(t)^r
$$
\item [M13.] Time for ant to build a tunnel
$$\label{eq:AntTunnel}
\frac{dT}{dx} = \alpha x
$$
\item [M14.] Torricelli's Law
$$\label{eq:Torricelli}
 \frac{dh}{dt} = - \frac{k}{A} \sqrt{h(t)}
$$
\item [M15.] Sublimation
$$\label{eq:Sublimation}
 \frac{dm}{dt} = - k m(t)^r
$$
\item [M16.] Electric circuit
$$\label{eq:ElecCircuit}
 L \frac{dI}{dt} + R I(t) = E_{\rm Emf} 
$$
\item [M17.] Constant infusion tracer analysis
$$\label{eq:Tracer}
\frac{dq_1}{dt} = R_{\rm in} A_0 - k_1 q_1(t)
$$
\item [M18.] Sterile male mosquito release
$$\label{eq:SterileMale}
\frac{dN}{dt} = N(t) \left( b\frac{N(t)}{N(t)+S}- d\right)
$$
\item [M19.] Spread of  oil slick
$$\label{eq:OilSlick}
\frac{dS}{dt} = -\alpha S(t) + \beta \, .
$$
\end{itemize}


We introduce  a straightforward  strategy for solving. In practice we recommend  the use of computers to solve these differential equations, e.g., {\tt DSolve} from Mathematica. Nevertheless, we believe the solution strategy we present, known as {\it separation of variables\/} gives an idea of how to build solutions and will help in understanding the nature and form of the solution, be it from pencil and paper or computer. 

\section*{SEPARATION OF VARIABLES}

Suppose a differential equation  has the form:
\begin{equation}\label{eq:GeneralForm}
\frac{dy}{dt} = y'(t) = F(t, y(t))\, .
\end{equation}
Further, suppose (\ref{eq:GeneralForm}) can be written as in  (\ref{eq:Formal}), where the right hand side is the product of two functions, say $f(t)$ and $g(y(t))$, one a function of the independent variable, $t$, and the other a function of the dependent variable, $y(t)$. We  can separate the variables, i.e., place all of the functions of $y(t)$ on the one side with the derivative term, $y'(t)$, and all the functions of  $t$  on the other side.  Using  the Chain Rule, we can reverse the differentiation process on the side with $y'(t)$and also on the other side. Recall that these two sides of our equation will then differ by a constant.   We illustrate this  in (\ref{eq:Formal}) and we produce (\ref{eq:FormalSep}).  

\begin{equation}
\label{eq:Formal}
\frac{dy}{dt}  = F(t, y(t)) = f(t)*g(y(t))
\end{equation}
Now after division of both sides by $g(y(t))$ this leads to 

 \begin{equation}
\label{eq:FormalSep}
\frac{1}{g(y(t))}\frac{dy}{dt}  =  f(t)\, .
\end{equation}

While there is no certainty (consider the many possibilities for the function $g$) it just might be possible to antidifferentiate the left hand side using the Chain Rule and the right hand side as well.

\begin{equation}
\label{eq:FormalDivideInt}
\int \frac{1}{g(y(t))}\frac{dy}{dt}\, dt  = \int f(t)\, dt + c
\end{equation}
Let us consider an example in (\ref{eq:Expo}) from chemical kinetics, where $g(y(t)) = y(t)^2$ and $f(t) = - k$,
\begin{equation}
\label{eq:Expo}
\frac{dy}{dt}  = - k y(t)^2\, .
\end{equation}

\noindent If we  divide both sides of (\ref{eq:Expo}) by $g(y(t)) = y(t)^2$ then we have (\ref{eq:FormalDivide}),
\begin{equation}
\label{eq:FormalDivide}
\frac{1}{y(t)^2}\frac{dy}{dt}  = f(t) = - k\, .
\end{equation}
Now (\ref{eq:FormalDivide}) presents  two functions of $t$, one on the left in terms of $y(t)$, our unknown function for which we are trying to solve, and  $f(t) = -k$, a function of $t$, only  -- with no $y(t)$ terms.  Recall, that if two functions of $t$ are equal then their antiderivatives or indefinite integrals with respect to $t$ differ by a constant. So integrating both sides brings us (\ref{eq:FormalDivideIntExpo}).


\begin{equation}
\label{eq:FormalDivideIntExpo}
\int \frac{1}{y(t)^2}\frac{dy}{dt}\, dt  = \int -k\, dt + c
\end{equation}
Now what we have to do is integrate the left side and the right side of (\ref{eq:FormalDivideIntExpo}), both with respect to  $t$,  and then extricate $y(t)$ from whatever our result is on the left side to solve, finally, for $y(t)$. As to the constant of integration $c$ we can determine its value by using initial value information, $y(0) = y_0$, at any point in our analysis.

There are different notations  presented for this process and we present one here:
\begin{equation}
\label{eq:FormalDivideDefInt}
\int_{t=0}^{t=T} \frac{1}{g(y(t))}\frac{dy}{dt}\, dt  = \int_{t=0}^{t=T}  f(t)\, dt 
\end{equation}
wherein we have a definite integration in which we eliminate the need for an intermediate constant of integration $c$ by going directly to a definite integral over the intervals $[0, T]$. This will permit us to take our next step from which we can extricate $y(T)$ or actually $y(t)$, for the form of our function $y({\rm whatever})$ is of final importance and so we should not be confused by $t$ or $T$ in the final analysis.

Another notation often presented is one using differentials, i.e., in (\ref{eq:FormalDivideInt}) we replace  $\frac{dy}{dt}\, dt$ with $dy$ and we formally integrate the left hand side of (\ref{eq:FormalDivideInt}), namely $$\int \frac{1}{g(y(t))}\frac{dy}{dt}\, dt  = \int \frac{1}{g(y)}\, dy\, ,$$ with respect to $y$. Upon  completion of this integration task we replace $y$ by $y(t)$ and proceed as before. We perform the integration of the right side of (\ref{eq:FormalDivideInt}) with respect to $t$ and add a constant of integration and ready ourselves to solve the resulting equation for $y(t)$.

Let us see this in practice with comments at each step.

\subsection*{Chemical Kinetics Modeling}

A model used in the study of chemical decomposition reactions is (M12). This is called a {\it second order reaction\/}. Let us suppose $k = .013$ while $r = 2$. Thus we have
\begin{equation}\label{eq:ChemKinSample}
  \frac{dA}{dt} = - 0.013 A(t)^2\, , \quad A(0) = A_0\, .
\end{equation}   
Upon separating our variables we produce
\begin{equation}\label{eq:ChemStep}
A(t)^{-2}  \frac{dA}{dt} = \frac{1}{A(t)^2}  \frac{dA}{dt} = - 0.013\, .
\end{equation}
Now we can formally integrate both sides of (\ref{eq:ChemStep}) with respect to $t$ to obtain

\begin{equation}\label{eq:ChemStepSolve}
-\frac{1}{A(t)} = - A(t)^{-1} = \int A(t)^{-2}  \frac{dA}{dt}\, dt = \int \frac{1}{A(t)^2}  \frac{dA}{dt}\, dt = \int - 0.013\,dt +c = -.013 t + c\, .
\end{equation}

\noindent From (\ref{eq:ChemStepSolve}) we can obtain $c$:


\begin{equation}\label{eq:ChemSolveForc}
-\frac{1}{A(0)} =  -.013 (0) + c = c\, .
\end{equation}

\noindent Substituting for $c$ back in (\ref{eq:ChemStepSolve}) yields

\begin{equation}\label{eq:ChemStepSolveFin}
-\frac{1}{(A(t)} = -.013 t -\frac{1}{A(0)}\, .
\end{equation}

\noindent  With some algebra in (\ref{eq:ChemStepSolveFin}), we have, finally,
\begin{equation}\label{eq:ChemStepFinalSolve}
A(t) = \frac{1}{.013 t +\frac{1}{A(0)}} = \frac{A(0)}{0.013t A(0) + 1}
\end{equation}

In Figure~\ref{fig:1-001-SIMIODESepVarChemPlot} we see a plot of our solution (\ref{eq:ChemStepFinalSolve}) to the differential equation model (\ref{eq:ChemKinSample}) with $A(0) = 100$ and it appears reasonable, in that the chemical is disappearing at a high rate when there is a lot of the chemical, due to our rate of change in $A(t)$ being proportional to the square of the amount of $A(t)$, $\frac{dA}{dt} = - 0.013 A(t)^2$.

\begin{figure}[h]
\centering
\includegraphics[width=11cm]{1-001-SIMIODESepVarChemPlot}
\parbox{7 true cm}{\caption{\label{fig:1-001-SIMIODESepVarChemPlot} Plot of the solution of differential equation (\ref{eq:ChemKinSample}) with initial value $A(0) = 100$.}}
\end{figure}

If we were to use, say  Mathematica, to solve the original differential equation (\ref{eq:ChemKinSample}) we would obtain:

\begin{equation}
\label{ChemStepMma}
A(t) = \frac{1000 A(0)}{13 A(0)\, .
   t+1000}\, 
\end{equation}
This is the same solution as our by hand solution in (\ref{eq:ChemStepFinalSolve}).

We consider the meaning of our solution (\ref{eq:ChemStepFinalSolve}) in the context of our equation (\ref{eq:ChemKinSample}). It takes two units (molecules, atoms, moles, etc.)  of $A(t)$ to form some product and while this formation is occurring the amount of $A(t)$ present is decreasing at a rate of $0.013 A(t)^2$ units of $A(t)$ per unit of time, $t$. Thus we are constantly losing $A(t)$, but at a slower and slower rate, for the amount of $A(t)$ present is decreasing. A plot of our solution in Figure~\ref{fig:1-1-SIMIODESepVarChemPlot} with, say, $A(0) = 100$ units of $A(t)$ shows this decline in $A(t)$. Incidentally, from its form in (\ref{eq:ChemStepFinalSolve}) we can see that $\lim_{t->\infty}A(t) = 0$, another reasonable consequence of our model.




\subsection*{Separation of Variables Could Be Hard Or Impossible}

A   separation of variables strategy might not be a wise or even doable choice. That does not mean a solution strategy cannot be found with by-hand methods, but it just might not be this strategy. Consider a loan pay back model for a \$100,000 loan in which the interest is 3\% annually compounded continuously and goes up 0.05\% per year while the amount for the payoff is initially \$4,250 per year and increases by 1\% each year. Convince yourself that a reasonable model for the balance, $b(t)$, on the loan after $t$ years  for such a situation is:

\begin{equation}\label{eq:Loan}
b'(t) = (.03 + .0005 t) b(t) - 4250*(1+.01 t)\, \quad {\rm with} \quad b(0) = 100000.
\end{equation} 

Can we separate this equation  to apply our separation of variables technique?  Go ahead and give it a try. Try to explain to yourself or write out in words why separation of variables will not work.

Can you make up a differential equation for which separation of variables technique will work and a similar one for which it does not? No need to worry about any modeling here, just concentrate on the form of the equation.



\subsection*{Take Them as Far As You Can Go}

Now for the models (A) - (S) offered at the start of this section pick several which interest you and see if you can separate the variables and then solve in the manner we used above. Go as far as you can and be able to articulate why you could not go any further or why you are confident in your solution which you produced for a solution.

Hint for (M2) - (M6):
$$\frac{1}{y(t)(K-y(t))} = \frac{A}{y(t)} + \frac{B}{K-y(t)} \, .$$
Can we find values of $A$ and $B$ which make the above equation true? If so, how does this help us to solve the differential equation?

\teacher{
\section*{NOTES FOR TEACHER}

We attempt, here, to take students on the short journey for success in doing a number of important differential equations used in modeling by hand with the classical separation of variables techniques. We do not do this in an overbearing manner. Nor do we stress pathological cases or obscure, non-modeling differential equations. At times we give the briefest of ideas for completion, e.g., we do not dwell on partial fraction decomposition.

In our own teaching we treat this as a side show, preferring to concentrate on modeling and let the technology do the heavy lifting of solving, in our case with Mathematica or Maple. So while we have not given up entirely on teaching this technique to students we fell compelled to expose them to it so they know what their down stream teachers are talking about and should the word come up in student-student conversation they will recall (probably vaguely, as will the student who have been drilled in this technique) that such an approach exists, but their computer algebra system can just blow most of these away and they can get on with the task at hand, namely, modeling with differential equation, NOT manually solving differential equations. 

We do not dwell on these models with ``solutions" for in our course that can be done so easily (by students, and is the preferred approach throughout the course) with Mathematica. Rather we just speak here about how this fits in to our course.

Finally, we have tried to give these differential equation some sort of context, even if only in name, and we have gone further in the case of one chemical kinetics model. 
}
\end{document}
