\documentclass[12pt]{article}

\usepackage[cm]{fullpage}
%\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{-0.25in}
\setlength{\evensidemargin}{-0.25in}
\setlength{\textwidth}{7in}
\setlength{\textheight}{8.5in}

% do not indent outermost itemize environ
\setlength{\leftmargini}{0.5in}

%\usepackage{hyperref}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{enumitem}
\renewcommand{\arraystretch}{1.2}

\begin{document}

\begin{center}{\sc {\Large M\&M Death and Immigration\footnote{Adapted from 1-1-M\&M-DeathImmigrationParameterEstimation, SIMIODE modeling scenario by Dr. Brian Winkel, Professor Emeritus, USMA, Director SIMIODE.}}\\


\vspace*{.3 true cm}
DR. Karen Bliss\\Department of Mathematics and Computer Science\\Quinnipiac University, Hamden CT 06518 USA.}
\end{center}

\noindent Consider a regular size bag of M\&M candies (not peanut, just regular). Usually there are about 55
pieces in each bag. They are of different colors, but each piece almost always has an ``m" pressed
on one side and not the other. Hence, there are distinctions between the sides. Let us conduct a couple of
experiments (life and death experiments!) on the M\&Ms.\\

%----------------------------------------------------------------------------------------------------------------------------------
\section[]{Model 1:  Death Model (sounds ominous, right?)}
\noindent Put 50 M\&M's into a small container like a paper cup. First {\bf just read} the description of the experiment. Before actually doing anything, describe what you think will happen and offer up some assumptions in support of
your description, some which might not have that much to do with what you expect to happen.

\noindent \textbf{Description of the Experiment:} (don't do it yet!) \\
\noindent Gently shake the M\&Ms out onto a flat surface like a desk (or you might want to use a paper
plate to catch the M\&Ms and keep them clean as well). We determine for each M\&M if it lives
or dies. If the m shows on top this M\&M dies, otherwise there is life for this M\&M. Upon death
you should remove the M\&M from the population (set these aside as we will need them for another
experiment), count and note down the number of M\&Ms who survive in Table 1, and thus put
fewer M\&Ms back into your container for the next iteration. Do this over and over and record your
results.

\noindent \textbf{Questions:}
\begin{enumerate}
	\item  State your assumptions about the physical activity.  Many times assumptions run into each other, so break the assumptions down to their simplest form (i.e., do not use words like ``and").
	\item  Offer up a description (in words) of what should happen. Care to make a prediction about what happens in the long run?
	
\newpage
	\item Now perform the experiment.  In the table below, record what happened.
	\begin{center}
	{\sc Death of M\&Ms}
	
	\begin{tabular}{|c|c|c|}
	\hline
	Iteration	& \# M\&Ms at start of iteration\\
	\hline
	\hline
	0	& 50\\
	\hline
	1	&	\\
	\hline
	2	&	\\
	\hline
	3	&	\\
	\hline
	4	&	\\
	\hline
	5	&	\\
	\hline
	6	&	\\
	\hline
	7	&	\\
	\hline
	8	&	\\
	\hline
	9	&	\\
	\hline
	10	&	\\
	\hline
	\end{tabular}\\
	\end{center}
	
		\item  Compare your description/prediction with what actually happened.
\end{enumerate}

\noindent  \textbf{Attempt at a mathematical model:}
Now attempt to build a mathematical model of this situation.  Let's define the number of M\&Ms alive at the start of iteration $n$ as $a(n)$. What values would $n$ take? What would
$a(0)$ be in this case? Do you ``know" what $a(1)$ would be?

\noindent \textbf{Questions:}
\begin{enumerate}[resume]
	\item  Based on the observations and your assumptions, produce a reasonable formula for $a(n).$   That is,
offer up a discrete function $a(n),$ in the one variable, $n$, for $n = 0, 1, 2, \ldots$.
	\item Discuss the reasonableness of your function model for $a(n).$
	\item  Use Matlab to iterate your model for at least 50 iterations.  You may choose to make a vector called {\tt a\_values} where Matlab stores $a(n)$ values using a {\tt for} loop.  Print the vector to the screen.  Discuss the reasonableness of the model in light of this output of model.
	\item How will you measure your ``success" as a modeler in this situation?\\
\end{enumerate}
\newpage

%----------------------------------------------------------------------------------------------------------------------------------
\section{Model 2:  Death with Immigration}
This time we will permit immigration to recover the damage to the M\&M population from death. Again, start with 50 M\&Ms, and as before, don't start the experiment until you've thought about what you expect will happen.

\noindent \textbf{Description of the Experiment:} (don't do it yet!) \\
\noindent Gently shake the M\&Ms out onto the flat surface to determine for each M\&M if it lives or dies.
Remember, if the m shows on top this M\&M dies; otherwise, there is life for this M\&M. Upon death
you should remove the M\&M from the population (set these aside).  VERY IMPORTANT CHANGE: In addition to putting the
M\&Ms which survived back into the cup, add 10 immigrants AT EACH ITERATION. You can use those from your ``death
pile." Do this over and over and record your results.

\noindent \textbf{Questions:}
\begin{enumerate}[resume]
	\item State your assumptions about the physical activity.
	\item Offer up a description of what you expect will happen over time.
	\item Now perform the experiment.  In the table below, record what happened.
	\begin{center}
	{\sc Death with Immigration}
	
	\begin{tabular}{|c|c|c|}
	\hline
	Iteration	& \# M\&Ms at start of iteration\\
	\hline
	\hline
	0	& 50\\
	\hline
	1	&	\\
	\hline
	2	&	\\
	\hline
	3	&	\\
	\hline
	4	&	\\
	\hline
	5	&	\\
	\hline
	6	&	\\
	\hline
	7	&	\\
	\hline
	8	&	\\
	\hline
	9	&	\\
	\hline
	10	&	\\
	\hline
	\end{tabular}
	\end{center}

	\item  Compare your description/prediction with what actually happened.
\end{enumerate}

\noindent  \textbf{Attempt at a mathematical model:}
Now attempt to build a mathematical model of this situations.  Let's define the number of M\&Ms alive at the start of iteration $n$ as $b(n)$. What would $b(0)$ be in this case? Do you ``know" what $b(1)$ would be?

\noindent \textbf{Questions:}
\begin{enumerate}[resume]
	\item  Based on the observations and your assumptions, produce a reasonable formula for $b(n).$   That is,
offer up a discrete function $b(n),$ in the one variable, $n$, for $n = 0, 1, 2, \ldots$.
	\item Discuss the reasonableness of your function model for $b(n).$
	\item How will you measure your ``success" as a modeler in this situation?
\end{enumerate}

%----------------------------------------------------------------------------------------------------------------------------------
\section{Another Approach:  Modeling Change}
\noindent  It was hard to come up with a model formula for the death and immigration model
directly! Maybe we need to think about things a little differently.  Let's focus on how we get from generation to
generation. We seem pretty confident that in each iteration we lose about half of our M\&Ms (again--why is that so?), but then but we then add 10 M\&Ms as immigrants. You should be able to tell what
the $(n + 1)$th generation, $b(n + 1)$, looks like in terms of the $n$th generation, $b(n)$, and immigration.
Give it a try to predict $b(n + 1)$ in terms of $b(n)$ and immigration. Fill in the following: 

$$ b(n + 1) =  \line(1,0){250}\, .$$
    
\noindent What was easy and what was hard in trying to determine what to put on the right had side of the
expression above for $b(n+1)$? It is worthwhile pausing here in this early modeling activity to savor
the moments of discovery and frustration and learn from these. So just reflect for a moment on
what you have accomplished and what it took to do just that - build a mathematical model.

\noindent It is not unreasonable to come up with several possibilities. Here are several. Explain what is
not good about each one. Try to put each of these ill-conceived models into words and test them
against your own understanding of the physical process of M\&M tossing and migration.
	\begin{align*}
	b(n+1)	&= 10b(n) + 0.5\\
	b(n+1)	&= 0.5 \cdot 10 \cdot b(n)\\
	b(n+1)	&= 0.5 b(n+1) + 10\\
	b(n+1)	&= -0.5 b(n) + 10\\
	b(n+1)	&= [b(n+1)]^n +10\\
	\end{align*}
	
\noindent Here's what we want from our model:  ``The value of $b(n+1)$ is to be half of $b(n)$ due to death plus 10 due to immigration."  Does that sentence translate directly into mathematics for you? How does (\ref{eqn1}) look as a mathematical translation?
	\begin{equation}  b(n + 1) = 0.5 b(n) + 10 \label{eqn1} \end{equation}
Another way to look at (\ref{eqn1}) is to model the change at each generation and we can do this by
subtracting $b(n)$ from each side of (\ref{eqn1}),
	\[ b(n + 1) - b(n) = 0.5 b(n) + 10  - b(n),\]
 which we can simplify as
	\begin{equation}  b(n + 1) - b(n) = -0.5b(n)+ 10. \label{eqn2} \end{equation}
Equation (2) is referred to as a difference equation. Now translate (\ref{eqn2}) into a sentence and see how
it sits with you.\\

\noindent Often we replace $b(n + 1) - b(n)$ by the symbols $\Delta b(n)$ for ``change in $b(n)$." Thus (\ref{eqn2}) could be
written this way:
	\begin{equation}  \Delta b(n) = -0.5b(n) + 10. \label{eqn3} \end{equation}
	
	
\noindent There are a few things to note here:
\begin{itemize}
	\item  In all three equations, (\ref{eqn1}), (\ref{eqn2}), and (\ref{eqn3}), we need to tell our model where to start, i.e. $b(0) = 50,$ for that is how many M\&Ms we had in the cup at the beginning of the experiment.  This is called an {\it initial condition.}
	\item  Each of these three pairs of equations can be referred to as a difference equation with initial condition. Indeed,
we recognize that just as in calculus where we can have first- and second-order derivatives, we can also 
have first- and second-order difference equations.
	\item  The fact that we have a linear expression in $b(n)$ on the right hand side of (\ref{eqn3}) suggests that we call
such an equation linear. So, we see that a good way to model our death and immigration activity
is with a first-order, linear difference equation with an initial condition. That is a mouthful, but you
should now see that each of these terms has meaning.\\
\end{itemize}

%----------------------------------------------------------------------------------------------------------------------------------
\section{Another Approach:  Continuous Dynamics}
\noindent  Let us examine (\ref{eqn2}) which is repeated below. 

	\[  b(n + 1) - b(n) = 0.5 b(n) - b(n) + 10 = -0.5b(n)+ 10. \]

\noindent We consider the prospects of modeling this discrete
system with some continuous mathematics involving not just differences, but derivatives.\\

\noindent  Suppose instead of generational increments of 1, i.e. going from $n$ to $n + 1$, we were to go in
time increments of $\Delta n$, e.g., $n = 0.01$. In this case we would not lose half of our population in a
time interval of 1. Rather we would lose a fraction, $(\Delta n)\cdot 0.5$, of our population in a small time
interval of length $\Delta n$. Further, we would not add 10 immigrants in a time interval of 1, i.e. going
from $n$ to $n + 1$, but rather we would add $(\Delta n) \cdot 10$ immigrants in a time interval of length $\Delta n$.
(What assumptions about our process are we making when we say these things?) This would yield
a new equation, where again $b(n)$ is the size of the population at time $n$:

	\begin{equation}	b(n + \Delta n) -b(n) =-(\Delta n) \cdot 0.5 \cdot b(n) + \Delta n \cdot 10. \label{eqn4} \end{equation}

\noindent With the introduction of $\Delta n$ we sense a nearness of the calculus muse, for we can take our approximate population changes over smaller and smaller time intervals of length $\Delta n$. Indeed, in (\ref{eqn4}) we
could divide both sides by $\Delta n:$
	\begin{equation}
		\frac{b(n + \Delta n) -b(n)}{\Delta n} = -0.5 \cdot b(n) + 10.\label{eqn5}
	\end{equation}
	
\noindent and in (\ref{eqn5}) take the limit as $\Delta n \rightarrow 0,$ i.e. we take smaller and smaller increments of time over which
M\&Ms die and immigration takes place:
	\[  \lim_{\Delta n \rightarrow 0}\frac{b(n + \Delta n) -b(n)}{\Delta n} = \lim_{\Delta n \rightarrow 0}[-0.5 \cdot b(n) + 10]. \]
Note that the left hand side is just the definition of a derivative.  The expression inside the limit on the right hand side is constant with respect to $\Delta n,$ so we have:
	\begin{equation}
		\frac{db}{dn} = -0.5 \cdot b(n) + 10.\label{eqn6}
	\end{equation}
This is called a {\it differential equation} and if we add an initial condition, in this case $b(0) = 50,$ we have in (\ref{eqn7}) what is called an {\it initial value problem.}
	\begin{equation}
		\frac{db}{dn} = -0.5 \cdot b(n) + 10, \hspace{1cm} b(0) = 50.\label{eqn7}
	\end{equation}
Typically, when we study time-dependent differential equations, we use the variable $t$ for time (where $t$ has units of seconds or days, etc.).  As such, we can re-write (\ref{eqn7}) as
	\[ \frac{db}{dt} = -0.5 \cdot b(t) + 10, \hspace{1cm} b(0) = 50, \]
or, equivalently,
	\begin{equation}
		b'(t)  = -0.5 \cdot b(t) + 10, \hspace{1cm} b(0) = 50, \label{eqn8}
	\end{equation}
which is classified as a {\it first-order linear differential equation with an initial condition.}\\

\noindent Ideally, we'd like to find an analytic solution for this IVP (i.e., we'd like to be able to write down a formula for $b(t)$).  Can you think of a function whose derivative is the same as -0.5 times the function plus 10?  It's not obvious!  We'll discuss how to find analytic solutions later (it's not always possible!), but for now we can find a numerical solution.\\

\noindent \textbf{Questions:}
\begin{enumerate}[resume]
	\item  Use Euler's method (in Matlab) with $\Delta t = 1$ to find the numerical solution to the IVP (\ref{eqn8}) from $t = 0$ to $t = 10.$  Then repeat with $\Delta t = 0.1.$  Plot both solutions on the same set of axes.  Make sure the axes are labeled appropriately, the plot has a title, and that there is a legend to indicate which data is for $\Delta t = 1$ and which is for $\Delta t = 0.1.$
	\item  Plot the Euler's method solution of (\ref{eqn8}) with $\Delta t = 1$ on the same set of axes with the discrete version in (\ref{eqn1}).  Explain the similarities/differences.
\end{enumerate}

\end{document}
