\chapter{Discrete-Time Dynamic Modeling and Difference Equations}

\specialsection{Introduction}
\index{dynamic modeling|(}
\index{difference equation|(}
\index{model!dynamic|(}
\index{model!difference equation|(}
In Chapters 4, 5, and 6 we introduced techniques for modeling the relation between one
independent variable and one dependent variable.  In all of those examples, 
we  started from
measured values of the dependent variable for some number of input values of the independent 
variable and determined the models of various types that fit that measured data the best,
in the sense of least squares regression.  In some of the 
models we considered, the independent variable could be interpreted as a \emph{time}
and the results of the model could be interpreted as a description of how the dependent 
variable changes or evolves over time.  

In this chapter, we will consider a different way to construct \emph{dynamic models}, that is,
models of changes over time.  Our starting information will be different now.  
Instead of measured values of the dependent variable for some number of input values of the 
independent variable, we will start from \emph{a statement or description of how 
the independent variable is changing as the independent variable changes}.  This different 
point of view is important because many physical ``laws'' or scientific models can be interpreted 
as theoretical descriptions of how a quantity evolves or changes over time.  The techniques we
will introduce in this chapter will allow us to convert that sort of \emph{dynamic description}
 into a list of values for the quantity that we could use to plot it as a function of time, or in some favorable
cases even into a formula for the quantity as a function of time.

Instead of continuing to discuss this in the abstract, let's see a first example that
relates to topics we have seen before and shows the power of approaching modeling
from this new, dynamic perspective.

\begin{example}
\label{ExpDiffEq}
In Proposition~\ref{ExpProp} we stated that any function with the property that 
\begin{itemize}
\item \emph{changing the 
independent variable by a fixed amount gives function values in a fixed proportion}
\end{itemize} 
must be  an exponential function.  We did not justify that statement at the time.  But
we can now give at least a partial explanation for this claim using the new approach described
above.  Let us call the independent variable $t$ (thinking of it as a time) and 
the dependent variable $Q(t)$.  Starting
from $t = 0$, consider the values $Q(0), Q(1), Q(2)$, etc.  for all positive integer
values of $t$.   This is an example of a \emph{discrete sequence} of $t$-values because of the
discrete spacing between consecutive $t$-values, with spacing $\Delta t = 1 - 0 = 2 - 1 = 3 - 2 = \cdots = 1$.  
As a result, the values in the 
sequence are not ``clumping closer together'' or tending to a limiting value as
$t$ increases.   This is the intuition behind the way the word \emph{discreteness}
\index{discrete}
is used in mathematics.

Consider the italicized statement in the bullet point at the start of this Example.  If $Q(t)$ satisfies that statement, then
considering the two values $Q(n+1)$ and $Q(n)$ for any $n$  and what it means for the 
proportion between those two values to the the same, we see that all of the following ratios
are the same:
$$\frac{Q(1)}{Q(0)} = \frac{Q(2)}{Q(1)} = \frac{Q(3)}{Q(2)} = \cdots  = \frac{Q(n+1)}{Q(n)} = \cdots .$$
Let us introduce a name for this common ratio, namely $a > 0$.  Then we have
$$\frac{Q(n+1)}{Q(n)} = a$$
for all $n \ge 0$, and hence
\begin{equation}
\label{eq:ExpDiffEq}
\framebox{$Q(n+1) = a \cdot Q(n)$ for all $n \ge 0$.}
\end{equation}
This is a first example of a \emph{difference equation} as in the title of this chapter, and we can think 
of it as the mathematical model equivalent to the verbal statement above.

If we look at \eqref{eq:ExpDiffEq} in the right way, we can see that it
implies this formula for $Q(n)$:
\begin{equation}
\label{eq:ExpEq}
\framebox{$Q(n) = Q(0)\cdot a^n$ for all $n \ge 0$.}   
\end{equation}
Specifically, this formula clearly works for $n = 0$, since  $a^0 = 1$.  Then, if it holds for
any one integer $n = k$, that is $Q(k) = Q(0)\cdot a^k$, then \eqref{eq:ExpDiffEq}
implies
$$Q(k+1) = a \cdot Q(k) = a\cdot Q(0)\cdot a^k = Q(0)\cdot a^{k+1}.$$
Hence \eqref{eq:ExpEq} holds for $n = k + 1$ as well.  The situation 
is analogous to an infinite row of dominoes numbered by the integers $n \ge 0$, where, 
when we knock over the one for $n = 0$, that one knocks over the $n = 1$ domino, that one
in turn knocks over the $n = 2$ domino, etc.   Mathematically the truth of \eqref{eq:ExpEq} for 
$n = 0$ implies the truth for $n = 1$, which then implies the truth for $n = 2$, which
then implies the truth for $n = 3$, and so on for all integers $n \ge 0$.\footnote{Technical note:  This
argument is an example of what is known as a \emph{proof by mathematical induction}.\index{mathematical induction}} 
Therefore $Q(t)$ is given by an exponential formula (at least for integer values of $t$).  This
gives a partial justification for what we said in Proposition~\ref{ExpProp}.  Also see Exercise~\ref{ExpPctChange}
below, which gives an important related (and equivalent) statement.  $\triangle$
\end{example}

The point of this example is that the difference equation, the relationship in \eqref{eq:ExpDiffEq}, 
implies that $Q(n)$ must be given by  values of an exponential function.  What we did in Example~\ref{ExpDiffEq}
can be thought of as \emph{solving the difference equation} for the function $Q(n)$.   In this chapter
we will consider difference equations such as \eqref{eq:ExpDiffEq} in some generality.
In some cases, we will derive techniques for solving them, that is for writing $Q(n)$ in terms of known functions.  
In addition, we will apply these equations to produce discrete-time dynamic models
of quantities that are changing and evolving over time.\footnote{Technical note: There is a somewhat
parallel theory of \emph{differential equations} that starts from descriptions of how functions of continuous variables
\index{differential equations}
are changing to derive information about the functions themselves.  This is also an important modeling tool,
and a core area of more advanced applied mathematics.  An introduction to differential equations is
included in most Calculus 2 courses and almost all college and university mathematics major programs 
offer more advanced courses in differential equations as well.}

\specialsection{Difference Equations}
Let $Q$ be a function defined for integer inputs $n \ge 0$.   
For us, a difference equation will be any equation relating several values of the function $Q$, starting
with $Q(n)$ and involving some collection of the successive values $Q(n+1)$, $Q(n+2)$, $Q(n+3)$, and so forth.\footnote{We 
will always write our difference equations this way, although in thinking about what the equation
says or developing models we may also 
want to think of $Q(n)$ as the preceeding value to $Q(n+1)$, etc.}   A difference equation can
also involve other known functions of the input integer value $n$.  That equation must
hold for all input values $n \ge 0$.  An equation of this form is often also called 
a \emph{recurrence relation} because the equation says how the values of $Q$ for larger
inputs depend on values for smaller inputs.  Equation~\eqref{eq:ExpDiffEq} is a first example,
stating how one value $Q(n+1)$ depends on the immediately previous value $Q(n)$ and the constant $a$.
The examples we will consider later in this chapter will come from models of some real-world situations.
In those cases, the function $Q$ will usually
be specified by some sort of description, for example, as the population of a certain species of organisms
in a fixed habitat as a function of time in discrete intervals of some length.  But we may not know an explicit 
formula for it, and in fact, mathematically, we will often want to think of $Q$ as a sort of 
\emph{unknown} to be solved for from the difference equation.

If the equation involves
$Q(n), Q(n+k)$ and some or all of the intermediate values $Q(n+1), Q(n+2), \ldots Q(n + k - 1)$ but no other values of $Q$, 
then we say it is a $k$th order difference equation.\footnote{Technical note:  In case you 
are wondering why these are called \emph{difference equations}, there is an explanation.  Historically, difference equations were 
first studied as approximations to \emph{differential} equations (see footnote 2 above), in which \emph{derivatives} are replaced
by ``finite differences'' such as 
$$Q'(x) \doteq \frac{Q(x + h) - Q(x)}{h}$$
or 
$$Q''(x) \doteq \frac{Q(x+h) - 2 Q(x) + Q(x - h)}{h^2},$$
(no limits as $h \to 0$)
and algebraic equations are solved to derive approximate values of $Q$ at a discrete set of input $x$-values.  
This circumstance accounts for the way the perhaps perplexing name, ``difference equation,''  arose
historically.   Example~\ref{ImmigrationEmigration} discusses another way to understand this, at least
for first order difference equations. }


\subsection*{Some First Order Difference Equations}
\index{difference equation!first order|(}
\index{difference equation!affine first order|(}
Equation~\eqref{eq:ExpDiffEq} is called a \emph{first order} difference equation because the equation relates one value $Q(n)$
and the value $Q(n + 1)$ which is the \emph{first} of the following values.   Another important type 
of first order difference equation is the so-called \emph{affine equation:}
\begin{equation}
\label{eq:AffineEq}
\framebox{$Q(n+1) = a \cdot Q(n) + b$, for all $n \ge 0$.}
\end{equation}
Here, $a,b$ are constants.
We will discuss modeling with difference equations of this form in the next section.  Here, we will discuss how
to solve an affine equation--how to produce a formula for $Q(n)$ if this difference equation holds.  

Because the only difference between the affine equation in \eqref{eq:AffineEq} and 
\eqref{eq:ExpDiffEq} is the added term $b$ on the right, we expect that there should be 
a relation between the solutions.  And indeed if
we start from a known value for $Q(0)$, say $Q(0) = c$, then the affine equation implies:
\begin{align*}
Q(1) &= a\cdot Q(0) + b = c\cdot a + b\\
Q(2) &= a \cdot Q(1) + b = c\cdot a^2 + b\cdot a + b\\
Q(3) &= a\cdot Q(2) + b = c\cdot a^3 + b\cdot a^2 + b\cdot a + b,
\end{align*}
and so forth.  Recalling that the constant $c = Q(0)$, the general pattern we see\footnote{Technical note: This can be established
rigorously by another proof by mathematical induction, as in Example~\ref{ExpDiffEq}.} here is that for any $n$, 
$$Q(n) = Q(0)\cdot a^n + b(a^{n-1} + a^{n-2} + \cdots + a + 1).$$
From high school algebra, we recognize the sum in the parentheses (the part multiplied by the $b$) as the
sum of a \emph{finite geometric series}, 
\index{geometric series!finite}
which can also be written as 
$$a^{n-1} + a^{n-2} + \cdots + a + 1 = \frac{a^n - 1}{a - 1}.$$
Hence the solution can be written as 
$$Q(n) = Q(0) \cdot a^n + b \cdot \left(\frac{a^n - 1}{a - 1}\right).$$
With some more algebra, we can see an important feature of this function.  Namely, if we 
separate the fraction $\displaystyle{\frac{a^n - 1}{a - 1} = \frac{1}{a-1}\cdot a^n - \frac{1}{a-1}}$, then
we see that the first part of this can be combined with the $Q(0) \cdot a^n$ term in the formula
for $Q(n)$.  Doing this gives:
\begin{equation}
\label{eq:AffineFinalForm}
\framebox{$\displaystyle{Q(n) = \left(Q(0) + \frac{b}{a - 1}\right)\cdot a^n  - \frac{b}{a - 1}}$.}
\end{equation}
In words, the solution of the affine first order difference equation is an exponential function $c \cdot a^n$, with 
$c = Q(0) + \frac{b}{a - 1}$, 
\emph{shifted up or down} by the constant $\displaystyle{-\frac{b}{a - 1}}$.\footnote{The shift is up if $-\frac{b}{a - 1}> 0$
and down otherwise.}

\begin{example}
\label{AffineEx}
Suppose we want to solve the affine difference equation 
$$Q(n+1) = (1.2)\cdot Q(n) + 3.4$$
with $Q(0) = 1$.  
Here $a= 1.2$ and $b = 3.4$.  Substituting in \eqref{eq:AffineFinalForm}, we see
$$Q(n) = \left(1 + \frac{3.4}{1.2 - 1}\right)\cdot (1.2)^n - \frac{3.4}{1.2 - 1} = 18\cdot (1.2)^n - 17.$$
These values come from the function $f(x) = 18\cdot (1.2)^x - 17$, which is related to the increasing exponential
function $18\cdot (1.2)^x$ as in Chapter 5.  To get our function we subtract $17$, which has
the effect of shifting the whole graph down by that amount.  The negative values that might be 
expected if you think about shifting down that far only occur for $x < 0$, though.  It
is clear from the difference equation that $Q(n) > 0$ for all $n \ge 0$.  $\triangle$
\end{example}
\index{difference equation!first order|)}
\index{difference equation!affine first order|)}

\specialsection{Some Higher Order Difference Equations (Optional)}
\index{difference equation!second order|(}
Most of the examples we will see in the next sections involve first order difference equations.
But some higher-order (i.e. second-order, third-order, etc.) differences come up in some modeling
problems as well, especially in various engineering disciplines and in economics (see Exercise~\ref{ex:MultAcc} below).
So we also include a very brief introduction to some of the most 
important features and examples.

\begin{example}
\label{SecondOrder}
This is an example of a
\emph{second order} difference equation:
\begin{equation}
\label{eq:ExSecondOrder}
Q(n+2) - n \cdot Q(n+1) + n^2\cdot Q(n) = 1 - n,
\end{equation}
because it relates one value $Q(n)$, the first succeeding value $Q(n+1)$ and the second succeeding value $Q(n+2)$.  (That is,
this fits the general pattern described before with $k = 2$.)
Note that this relation involves several known functions of $n$ as well, in the coefficients on the left and 
on the right-hand side of the equation. 

A second order equation like the one in this example ``kicks in'' as soon as $n \ge 0$, but note that $Q(0)$ and $Q(1)$ could
actually be any numbers.  Knowing those \emph{initial conditions} and the difference equation determines 
$Q(2)$ and then the $Q(n)$ for $n > 2$ as well.  For instance if $Q(0) = 1$ and $Q(1) = 2$, then, from \eqref{eq:ExSecondOrder}
with $n = 0$ we get
$$Q(2) - 0\cdot Q(1) + 0^2\cdot Q(0) = 1 - 0 \Rightarrow Q(2) = 1.$$
Then with $n = 1$ in \ref{eq:ExSecondOrder}, 
$$Q(3) - 1\cdot Q(2) + 1^2\cdot Q(1) = 1 - 1 \Rightarrow Q(3) - 1 + 2 = 0, \ {\rm so}\ Q(3) = -1.$$
Then with $n = 2$ we have
$$Q(4) - 2\cdot Q(3) + 2^2\cdot Q(2) = 1 - 2 \Rightarrow Q(4) -2 \cdot(-1) + 4\cdot 1 = -1,\ {\rm so}\ Q(4) = -7.$$
Values for all $n\ge 0$ can be determined this way, one at a time.  The same will be true in all of the examples
we will consider.  $\triangle$
\end{example}


It is not always easy to find an explicit formula for the function $Q(n)$ satisfying a general difference equation and some initial conditions.
However, if we make some restrictions on the form of the difference equation, then this may be possible.  For example
there is no easy way to write down functions of $n$ satisfying \eqref{eq:ExSecondOrder} because of the
way the coefficients depend on $n$.  One useful case where it is possible to write down formulas relatively easily
is the class of \emph{constant coefficient, linear difference equations}.  For instance
\begin{equation}
\label{eq:SecondOrderLinearCC}
Q(n + 2) - 5\cdot Q(n+1) + 6\cdot Q(n) = 0
\end{equation}
is a second order, constant coefficient, linear difference equation.  The ``constant coefficient'' descriptor means
that the multiples of the various values of $Q$ are just constants (not functions of $n$ as in 
\eqref{eq:ExSecondOrder}).
The term ``linear'' means that the $Q(n)$, $Q(n+1)$ and $Q(n+2)$ appear to the first power and not substituted into 
other functions or in other ways.  Something like the difference equation 
$$Q(n+1) = (0.5)\cdot Q(n)\cdot \left(1 - \frac{Q(n)}{40}\right)$$
is \emph{not} linear because the way $(Q(n))^2$ would appear if we multiplied out the right hand side.   We will consider
some equations like this later in the chapter.  

For simplicity in this elementary discussion we will restrict even farther, to \emph{second order, constant coefficient, 
linear} difference equations as in \eqref{eq:SecondOrderLinearCC}.   Note that the first order
equation from \eqref{eq:ExpDiffEq} could be written in a very similar form:
$$Q(n+1) - a\cdot Q(n) = 0.$$
Since we know that difference equation has the exponential function solution $Q(n) = a^n$, we can ``follow our noses''
and see whether there are any exponential solutions of an equation like \eqref{eq:SecondOrderLinearCC}.
We substitute $Q(n) = a^n$ there, then use rules for exponents and factor the result to obtain
$$a^{n+2} - 5\cdot a^{n+1} + 6\cdot a^n = 0 \Rightarrow (a^2 - 5\cdot a + 6)\cdot a^n = 0.$$
This is true for all $n \ge 0$ if and only if 
$$0 = a^2 - 5\cdot a + 6 = (a - 2)(a - 3).$$
Hence there are two bases for exponentials that satisfy this equation, namely $a = 2$ and $a = 3$.     

We claim next that we can produce many different solutions of this difference equation because:
\begin{itemize}
\item {\emph{For all choices of  constants $c_1,c_2$, the function
$Q(n) = c_1 \cdot 2^n + c_2 \cdot 3^n$ satisfies \eqref{eq:SecondOrderLinearCC}.}}
\end{itemize}
This is easy to verify by substitution and some algebraic manipulation parallel to what we did before
to find the values $a = 2,3$.  We have
$Q(n+2) - 5\cdot Q(n+1) + 6\cdot Q(n) $
\begin{align*}
&= (c_1 \cdot 2^{n+2} + c_2 \cdot 3^{n+2}) - 5\cdot (c_1 \cdot 2^{n+1} + c_2 \cdot 3^{n+1}) + 6\cdot (c_1 \cdot 2^n + c_2 \cdot 3^n)\\
&= c_1\cdot 2^n(2^2 - 5\cdot 2 + 6) + c_2\cdot 3^n(3^2 - 5\cdot 3 + 6)\\
&= c_1\cdot 0 + c_2 \cdot 0\\
&= 0.
\end{align*}
This means that we can solve for $c_1,c_2$ to match any initial values $Q(0)$ and $Q(1)$.  

\begin{example}
\label{HomogSolution}
Let's find a solution of $Q(n+2) - 5\cdot Q(n+1) + 6\cdot Q(n) = 0$ with $Q(0) = 3$ and $Q(1) = 2$.   From 
the above, we know that all
$$Q(n) = c_1\cdot 2^n + c_2\cdot 3^n$$
are solutions of this difference equation.  The initial conditions then say
\begin{align*}
3 &= c_1 + c_2 \\
2 &= 2c_1 + 3c_2.
\end{align*}
Solving simultaneously, we obtain $c_1 = 7$ and $c_2 = -4$.  Hence the solution is
$$Q(n) = 7\cdot 2^n + (-4)\cdot 3^n.$$
A function of this form is called a \emph{linear combination} of the two exponentials $2^n$ and $3^n$. 
Thinking about the range of behavior for different initial conditions, we see that because $2^n$ and $3^n$ both grow 
exponentially, all solutions will be unbounded except
for the single solution with $c_1 = c_2 = 0$.  $\triangle$
\end{example}

A general second order, constant coefficient, linear difference equation can be written in the form
\begin{equation}
\label{eq:SecondOrderCC}
Q(n + 2) + r\cdot Q(n + 1) + s\cdot Q(n) = f(n),
\end{equation}
where $r,s$ are constant.  The equation is said to be \emph{homogeneous} if $f(n) = 0$ for 
all $n$, and \emph{inhomogeneous} otherwise.   
\index{difference equation!linear, homogeneous}
\index{difference equation!linear, inhomogeneous}

We consider the homogeneous case first.  We briefly describe a procedure for deriving solutions of
one of these equations and given initial conditions on $Q(0)$ and $Q(1)$.
\begin{itemize}  
\item As in the example above, the ``pure exponential''
solutions of the difference equation will come from values of $a$ satisfying the
quadratic equation 
\begin{equation}
\label{eq:chareq}
\framebox{$a^2 + r a + s = 0$,}
\end{equation}
\index{difference equation!characteristic equation}
which is often called the \emph{characteristic equation} of the difference equation.  So 
we write down this equation from the difference equation and solve it (either by factoring, or
if necessary, with the \emph{quadratic formula}).  
\item If there are two distinct real roots $a_1,a_2$, then the \emph{general solution}
has the linear combination form:
$$Q(n) = c_1\cdot (a_1)^n + c_2\cdot (a_2)^n.$$
We substitute $n = 0,1$, use the initial conditions, and solve for $c_1,c_2$.
Apart from the numbers obtained, the process in this case is always the same 
as in Example~\ref{HomogSolution}.
\item If there is a repeated real root $a$ of the characteristic equation \eqref{eq:chareq}, 
then $Q(n) = n\cdot a^n$ is also a solution of the difference equation and
the general solution has a different form, namely
$$Q(n) = c_1\cdot a^n + c_2\cdot n\cdot  a^n.$$
The coefficients $c_1,c_2$ are obtained as in the first case.  See 
Example~\ref{RepRoots} below for an example.
\item Finally, if the roots of the characteristic equation are not real, then they 
are a pair of conjugate complex numbers and the solution can be written in 
terms of conjugate complex exponentials.  If the initial conditions are real,
all the values of the function $Q(n)$ are real as well, so the complex
expression can be simplified to an expression involving real exponentials and
the trigonometric functions $\cos$ and $\sin$.  The algebra for doing this is somewhat
beyond the scope of this elementary treatment, though, so we will not pursue
this case and it will not come up in the examples we consider where we
want to derive an explicit formula for the solution.  However, it 
is the reason why particular cases of the macroeconomic model discussed in Exercise~\ref{ex:MultAcc}
exhibit \emph{cyclical} behavior and capture an aspect of the observed business cycles
in the real world(!)
\end{itemize}

Here is an example of the repeated roots case mentioned above.

\begin{example}
\label{RepRoots}
Consider the difference equation 
$$Q(n + 2) - 4\cdot Q(n+1) + 4\cdot Q(n) = 0,$$
with the initial conditions $Q(0) = 3$ and $Q(1) = 4$.  
The characteristic equation is $a^2 - 4a + 4 = (a - 2)^2$, so $a = 2$ is a repeated root.
$Q(n) = 2^n$ is one solution of this difference equation.  But in this case we 
get a second solution of the form $Q(n) = n \cdot 2^n$.  This is true because
$Q(n+2) - 4\cdot Q(n+1) + 4\cdot Q(n)$ equals
\begin{align*}
(n + 2) \cdot 2^{n+2} - 4\cdot (n+1) 2^{n+1} + 4\cdot n 2^n &= (4(n + 2) - 8(n+1) + 4n)\cdot 2^n\\
&= (4n + 8 - 8n - 8 +4n)\cdot 2^n\\
&= 0.
\end{align*}
Hence taking a linear combination $c_1 \cdot 2^n + c_2 \cdot n\cdot 2^n$, we have the initial conditions
$Q(0) = 3$ and $Q(1) = 4$ if $c_1 + 0 = 3$, so $c_1 = 3$, and then $3\cdot 2 + 2\cdot c_2 = 4$.
This shows $c_2 = -1$ and the solution is
$$Q(n) = 3\cdot 2^n - n\cdot 2^n = (3 - n)\cdot 2^n.$$
Note that the step of solving for $c_1$ and $c_2$ was even easier in this example because
$c_2$ did not appear in the equation for $n = 0$.  $\triangle$
\end{example}

The solution of the inhomogeneous cases of \eqref{eq:SecondOrderCC} is based
on the observation that \emph{any two solutions differ by a solution of the associated
homogeneous equation}, where the right-hand side $f(n)$ is replaced by $0$.  You
will show this in Exercise~\ref{ex:InhomogHomog}.  Hence
if we can find one \emph{particular solution} of the equation with right-hand side $f(n)$, 
all other solutions will equal that particular solution, plus some solution of the 
associated homogeneous equation.  This reduces the problem to finding a particular 
solution.  One basic technique\footnote{Technical note:  This called the method of 
\emph{undetermined coefficients} in more complete treatments of difference equations.} 
makes use of different trial solutions that contain
undetermined constants based on the form of the $f(n)$.  
Substituting into the difference equation, a system of 
equations is obtained and the particular solution comes from solving them for the
undetermined coefficients.   We will consider some representative examples using
polynomial and exponential functions $f(n)$.

\begin{example}
\label{UndetCoeffs1}
Suppose we want to solve
$$Q(n + 2) - 5\cdot Q(n + 1) + 6\cdot Q(n) = n^2 + 3n + 1,$$
where the associated homogeneous equation is the one we solved in Example~\ref{HomogSolution}
above.  
Here $f(n) = n^2 + 3n + 1$ is a polynomial function of $n$ of degree $2$.  Thinking about
what sorts of functions might appear in the left-hand side to produce this $f(n)$, we see
that one possibility is 
$$Q(n) = A n^2 + B n  + C,$$
if the undetermined coefficients $A,B,C$ are exactly right to make 
$$A(n+2)^2 + B(n+2) + C - 5\cdot (A(n+1)^2 + B(n+1) + C) + 6\cdot(An^2 + Bn + C)$$
equal to $n^2 + 3n + 1$.  Expanding out and collecting powers of $n$, we have
$$2 A n^2 + (-6 A + 2 B)n -A - 3B + 2C.$$
Hence, to match $n^2 + 3n + 1$ for all $n$, we want
\begin{align*}
2A &= 1\\
-6A + 2B &= 3\\
-A - 3B + 2C &=1.
\end{align*}
This implies $A = \frac{1}{2}$, $B = 3$, $C = \frac{21}{4}$.  The general solution will be
$$Q(n) = c_1\cdot 2^n + c_2\cdot 3^n + \frac{1}{2} n^2 + 3n + \frac{21}{4}.$$
We still have the constants $c_1,c_2$ free here so we can match any given 
initial values for $Q(0)$ and $Q(1)$.  $\triangle$
\end{example}

A similar computation would give a particular solution in all cases where $f(n)$ is a
polynomial function.  We just make a trial polynomial solution of the same degree as $f(n)$, 
substitute into the difference equation, and solve the resulting equations for the undetermined coefficients.

If $f(n)$ is an exponential function $f(n) = c^n$, then the trial particular solution would look like 
$Q(n) = A\cdot c^n$, unless $c^n$ was also a solution of the associated homogeneous equation.
If that is the case then $Q(n) = A \cdot n \cdot c^n$ would be used, unless the characteristic
equation of the difference equation had the same $c$ as a repeated root.  In that last
(rather uncommon) situation, the trial solution $Q(n) = A\cdot n^2\cdot c^n$ would be
used instead.\footnote{Technical note:  The guiding principle here is that we take $A\cdot n^k \cdot c^n$
where $k$ is the \emph{smallest non-negative power such that this trial solution is not 
a solution of the associated homogeneous equation.}}

\begin{example}
\label{UndetCoeffs2}
Suppose we want to solve 
$$Q(n+2) - 4\cdot Q(n+1) + 4\cdot Q(n) = 2^n.$$
The associated homogeneous equation is the one we solved in Example~\ref{RepRoots} above, 
and it is one where the characteristic equation has $a = 2$ as a double root.   This means
that both $2^n$ and $n\cdot 2^n$ solve the associated homogeneous equation.  Since $f(n) = 2^n$
is this same exponential function, we need a trial solution of the form $Q(n) = A \cdot n^2 \cdot 2^n$.
Substituting into the difference equation and simplifying, we get 
$$A(n+2)^2 2^{n+2} - 4\cdot A \cdot (n+1)^2\cdot 2^{n+1} + 4\cdot A\cdot 2^n = 8\cdot A\cdot 2^n.$$
To match $f(n) = 2^n$, we must have $A = 1/8$, and the general solution is
$$Q(n) = c_1 \cdot 2^n + c_2\cdot n\cdot 2^n + \frac{1}{8}\cdot 2^n = (c_1 + \frac{1}{8} + c_2\cdot n)\cdot 2^n.$$
Again, the $c_1,c_2$ would allow us to match any given initial values for $Q(0)$ and $Q(1)$.
$\triangle$
\end{example}
\index{difference equation!second order|)}

\specialsection{Modeling with Difference Equations}
The first example we will consider will be parallel to topics discussed in Chapter 5 on modeling with
exponential functions.  The idea is that knowing, for instance, that some quantity is undergoing 
a constant percentage increase per unit time (at least approximately) is enough to say that an
exponential model is suitable (even without fitting an exponential model as we did in Chapter 5).  
See Exercise~\ref{ExpPctChange} below.   Then knowing
the solution of $Q(n+1) = a\cdot Q(n)$ from \eqref{eq:ExpEq} lets us write down
the model immediately.

\begin{example}
\label{ExpExample}
Over the past 50 years, a major change in the practice of mathematics and its applications 
studying the real world has been an amazing increase in the prevalence and power of computing 
resources.  This has allowed the development of much more detailed and realistic models
of various processes and systems.   A major contributor to that increase has been the technological progress that has allowed 
huge numbers of electronic components (e.g. transistors) to be included in the silicon microchips
making up CPU's and other computer hardware.  This has been done by reducing the sizes of such components
to the extent that as of 2017 the next generation of chips will have individual features about 10 \emph{nanometers}
($\doteq 10^{-8}$ meters)
\index{Moore's Law}
in size. In 1965, Gordon Moore, an Intel engineer, predicted
\index{Moore, Gordon}
that \emph{the number of transistors that could be fit on a chip would double roughly every two years}.\footnote{This
statement is often called \emph{``Moore's Law,''} but it is really an empirical observation and a target for
the semiconductor industry to aim for, not a physical law.   As of March 2017, many experts were predicting
that this rate of progress in computer technology could not continue any longer, but in June 2017 IBM announced
a breakthrough in silicon nanosheet fabrication that could allow for continued improvements.}

A doubling time of $2$ years means the number of transistors per chip is growing exponentially.   Moreover,
as we know from Exercise~\ref{DoublingTime} in Chapter 5, a doubling time of $2$ years corresponds to $a = 2^{1/2} \doteq 1.414$
in our general formula for exponential functions, 
or a $41.4\%$ increase per year.  Hence
Moore's statement is equivalent to the difference equation
$$Q(n+1) = (1.414)\cdot Q(n),$$
and we know the corresponding exponential model is 
\begin{equation}
\label{eq:MooreModel}
Q(n) = Q(0)\cdot (1.414)^n,
\end{equation}
where $n$ is the number of years after $n = 0$, say the year 1965.  At least through 2016 or so, 
a fitted exponential model to the actual data of the maximum number of transistors on the
densest CPU chips matches this closely.  See Exercise~\ref{Moore} for the details.  $\triangle$
\end{example}

We now study some examples using the first order affine difference equations from 
Example~\ref{AffineEx}.

\begin{example}
\label{ImmigrationEmigration}
\index{exponential growth!with immigration/emigration}
Suppose that the population of a city is growing at a net rate of $0.4\%$ per year as a result
of births and deaths, but that in addition there is a net out-migration of $500$ people per year.\footnote{This
means that $500$ more people are moving out than are moving in, or 
$$\text{(out-migration)} - \text{(in-migration)} = 500.$$}
This might be happening, for instance
if current residents leave to pursue better
job opportunities elsewhere.  If the initial population is $Q(0) = 70,000$, we might ask, assuming that the net 
growth rate and the number of people who emigrate every year stays the same, what
will happen to the population ``in the long run'' -- that is as $t$ increases to larger and 
larger values? To answer this, we will derive a difference equation model for this situation
and study the solution.  

The net growth rate of $0.4\%$ per year says that in the year between $t = n$ and $t = n+1$, 
$${\rm births}\ -\  {\rm deaths} = (0.004)\cdot Q(n).$$
But during the same year, $500$ of the total population are also leaving.  This means that
the total change from year $t = n$ to $t = n+1$ is 
$$Q(n+1) - Q(n) = (0.004)\cdot Q(n) - 500.$$
Hence, if we add $Q(n)$ to both sides and rearrange on the right we get the
affine difference equation for the city population:
\begin{equation}
\label{AffImmigrationEmigration}
Q(n+1) = (1.004)\cdot Q(n) - 500.
\end{equation}

What we just did here gives another way to think about the name ``difference equation,'' by the way(!)
A first order difference equation can always be rearranged to the form 
$$Q(n+1) - Q(n) = {\rm some\ function\ of\ } Q(n)\ {\rm and\ } n,$$
and then the right-hand side gives the \emph{difference} between $Q(n+1)$ and
$Q(n)$, in terms of $n$ and the value $Q(n)$.  If we start from this form, we can always go back as well.  This way of thinking 
is often used to derive difference equation models as we just did in this example.  

We next apply the equation for the general solution of affine first order difference equations
found in \eqref{eq:AffineFinalForm}.
With $a = 1.004$ and $b = -500$, we obtain
$$Q(n) = \left(70,000 + \frac{-500}{.004}\right) \cdot (1.004)^n + \frac{500}{.004} = 125,000 - 55,000\cdot (1.004)^n.$$
In this example, note that $(1.004)^n$ is an increasing exponential function of $n$.  But the multiple
$55,000 \cdot (1.004)^n$ is subtracted from
the $125,000$, so $Q(n)$ is \emph{decreasing} as $n$ increases.  In real-world terms, this would mean that 
the out-migration of $500$ people per year is \emph{not being replaced} by the natural increase of the 
population due to the excess of births over deaths.   For example, in the first year, there were $(70,000)\cdot (0.004) = 280$
more births than deaths, but $500$ people also left!

What will happen in the long run?  Solving an exponential equation using logarithms as in Chapter 1, we can say that 
$$125,000 - 55,000\cdot (1.004)^n = 0$$
when 
$$(1.004)^n = \frac{125,000}{55,000} \doteq 2.27 \Rightarrow n = \frac{\log_{10}(2.27)}{\log_{10}(1.004)} \doteq 205.4$$
years.  Hence our model predicts that the city's population will be reduced to \emph{zero} in about 205 years.  After that 
point, the model gives unrealistic, negative values.   Of course, it is also reasonable to ask whether the $0.4\%$ net
growth rate and the $500$ person out-migration per year will persist for that long a period of time.  But in any case, 
our model \eqref{AffImmigrationEmigration} implies that \emph{if nothing changes}, then the city will eventually disappear, something that is not
so far-fetched in many parts of the emptied-out ``farm belt'' of the upper mid-western U.S. at present.  $\triangle$
\end{example}

In the previous example, the negative contribution to the difference between $Q(n+1)$ and $Q(n)$ was larger
than the positive contribution.  In the following example, the reverse is true.

\begin{example}
\label{Glacier}
Suppose that a small glacier is losing volume due to melting of the ice at a constant rate of $2\%$ per year, 
but new ice from snowfall is being laid down into the glacier each winter at the rate of $.05$ cubic kilometer per year.  If
the original volume was $Q(0) = 10$ cubic kilometers, what will happen to the glacier -- will it eventually
disappear, or will its volume \emph{stabilize} at some positive value?  

Here the appropriate difference equation model can again be written down by considering the difference
between the end of each year and the next.  Letting $Q(n)$ be the volume of the glacier at the end of 
year $n$ in cubic kilometers, 
$$Q(n+1) - Q(n) = -(0.02)\cdot Q(n) + .05,$$
or after rearranging
$$Q(n+1) = (0.98)\cdot Q(n) + .05\quad {\rm with}\quad Q(0) = 10.$$
This is also a first order affine difference equation with $a = 0.98$ and $b = .05$. 

Using \eqref{eq:AffineFinalForm} again, we find
$$Q(n) = \left(10 + \frac{.05}{-0.02}\right)\cdot (0.98)^n - \frac{.05}{-0.02} = 2.5 + 7.5\cdot (0.98)^n.$$
Here, $0.98 < 1$, so $(0.98)^n$ is a decaying exponential which tends to zero as $n$ increases.  Hence
$Q(n)$ is decreasing with $n$ and tending to the value $2.5$ as $n$ increases.  Note that this
means that the glacier \emph{will not disappear entirely}.  According to this model, it will
stabilize at a volume of about $2.5$ cubic kilometers.   If the melting rate per year was greater (that is, $1 - a$ was smaller)
or the replacement rate $b$ from new snowfall was smaller, the value where the volume stabilized 
would be smaller, but it would always equal $-\frac{b}{a - 1}$ according to this model.  ``According to 
this model'' means, in particular, that we are assuming the melt amount per year stays constant at 
$2\%$ of whatever the glacier volume is for all time in the future.  That is, the model essentially
includes the assumption that no
continuing changes in the overall climate are going on that might increase (or decrease) the melting rate.  
\emph{Models can only be as good as the assumptions that go into them!}  $\triangle$
\end{example}

%$Q(n) = \left(Q(0) + \frac{b}{a - 1}\right)\cdot a^n  - \frac{b}{a - 1}$

\specialsection{Equilibria and Stability of Solutions}
In the examples so far, we have not studied how the solutions of difference equations might 
depend on the initial conditions and how the behavior of the solutions might change for different $Q(0)$. 
Part of the reason is that for the equations \eqref{eq:ExpDiffEq}, there is not too much to
say(!)  The functions $Q(n) = Q(0)\cdot a^n$ for any one value of $a$ are all proportional to each other,
so for $Q(0) > 0$, they all either increase without bound ($a > 1$) or decrease to zero ($0 < a < 1$).  

However, the affine first order difference equations from Examples~\ref{AffImmigrationEmigration} and \ref{Glacier}
show that there is much more going on and more interesting behavior for solutions of other difference equations.  
Nevertheless, we can see what would happen for different values of $Q(0)$ by plotting solutions and/or examining 
the difference equation and the formulas for the solutions we derived above.  

\begin{example}
\label{AffImmigrationEmigrationContinued}
Let us reconsider the difference equation from the model in Example~\ref{AffImmigrationEmigration}, where we studied
changes in a city's population including changes due to births,
deaths, and in- and out-migration:
$$Q(n+1) = (1.004)\cdot Q(n) - 500.$$
We saw the general solution
$$Q(n) = \left(Q(0) + \frac{-500}{.004}\right)\cdot (1.004)^n + \frac{500}{.004} = 125,000 + (Q(0) - 125,000)\cdot (1.004)^n.$$
When we look at the solution this way, we can see that there are three cases:
\begin{itemize}
\item If $Q(0)$ is any value greater than $125,000$, then the coefficient of the $(1.004)^n$ is positive, and the function $Q(n)$ \emph{increases without bound}.
\item If $Q(0) = 125,000$, then the coefficient of the $(1.004)^n$ is zero, and the function $Q(n)$ is \emph{constant}
with value $125,000$.
\item If $Q(0)$ is any value less than $125,000$, then the coefficient of the $(1.004)^n$ is negative, and the function $Q(n)$ \emph{decreases} and
reaches values $< 0$ eventually.
\end{itemize}
In the first case, we can say that with a large enough initial population, the $0.4\%$ net growth per year  is enough to 
replace the $500$ net out-migration per year.  In the third case, including the example calculations we did before, 
the growth is not enough to replace the losses due to out-migration and the population decreases to zero after some
number of years.  (After that point, the function would give negative values, and as we said before, it ceases being
a realistic model for a population!)  In
the remaining, ``middle,'' case the net growth exactly matches the out-migration, and the population stays constant.  
In other words, $Q(0) = 125,000$ is what is called a \emph{threshold value}; only values of $Q(0) \ge 125,000$ give solutions where
the population persists for all $n > 0$.  
\index{threshold value}

Another way to understand this pattern is to plot the function $Q(n)$ for various values of $Q(0)$, as in Figure~\ref{fig:AffPlots1}.
\begin{figure}
\begin{center}
\includegraphics[width=3.0in,width=3.0in]{AffDiffEqPlots1.png}
\caption{$Q(n) = 125,000 + (Q(0) - 125,000)\cdot (1.004)^n$, $Q(0) = 70,000$ in red, $Q(0) = 125,000$ in black, 
$Q(0) = 140,000$ in blue.}
\label{fig:AffPlots1}
\end{center}
\end{figure} 
Note: all three solutions are plotted out to $n = 200$, but only every $10$th year is shown for legibility.  

The fact that $Q(n) = 125,000$ is a constant solution of the difference equation can also be seen by considering
the rearranged form:
$$Q(n+1) - Q(n) = (0.004)\cdot Q(n) - 500.$$
If $Q(n)$ makes the right-hand side of this form equal to zero, then there is no change from $Q(n)$ to $Q(n+1)$
and the solution will be constant.  We see
$$(0.004)\cdot Q(n) - 500 = 0 \Leftrightarrow Q(n) = \frac{500}{0.004} = 125,000.$$
So this is the constant value.  $\triangle$
\end{example}

\begin{example}
\label{GlacierContinued}
Next we reconsider the difference equation $Q(n+1) = (0.98)\cdot Q(n) + .05$ from Example~\ref{Glacier}, 
whose general solution is 
$$Q(n) = (Q(0) - 7.5)\cdot (0.98)^n + 7.5.$$
These solutions are different from those in the previous example.  There is a constant solution 
$Q(n) = 7.5$ for all $n \ge 0$.  But since $(0.98) < 1$, the solutions for all $Q(0) > 0$ tend 
toward $7.5$ as $n$ increases.  
\begin{figure}
\begin{center}
\includegraphics[width=3.0in,width=3.0in]{AffDiffEqPlots2.png}
\caption{$Q(n) = (Q(0) - 7.5)\cdot (0.98)^n + 7.5$, $Q(0) = 0$ in red, $Q(0) = 7.5$ in black, 
$Q(0) = 11$ in blue.}
\label{fig:AffPlots2}
\end{center}
\end{figure} 
Three solutions are shown in Figure~\ref{fig:AffPlots2}.  Again, all three solutions are plotted out to $n = 200$, 
but only every $10$th year is shown for legibility. $\triangle$
\end{example}

These examples illustrate two important concepts regarding the solutions of difference equations.

\begin{itemize}
\item  A constant solution, $Q(n) = c$ for all $n \ge 0$,  of a difference equation is also known as an \emph{equilibrium}
\index{equilibrium!solution}
solution and the number $c$ is called the \emph{equilibrium value}. If $Q(0)$ is an equilibrium value, the corresponding solution is an equilibrium solution.
  For instance, $Q(n) = 125,000$ is an equilibrium solution in Example~\ref{AffImmigrationEmigrationContinued}, and 
$Q(n) = 7.5$ is an equilibrium solution in Example~\ref{GlacierContinued}.
\item  An equilibrium solution is said to be \emph{stable} if all solutions that start close to the equilibrium stay close
to the equilibrium (or perhaps even tend toward the equilibrium value) as $n$ increases without bound.  An equilibrium solution
is said to be \emph{unstable} if at least some of the solutions that start close to the equilibrium tend 
away as $n$ increases.  For example, the equilibrium $Q(n) = 125,000$ in Example~\ref{AffImmigrationEmigrationContinued}
is \emph{unstable}; the equilibrium $Q(n) = 7.5$ in Example~\ref{GlacierContinued} is \emph{stable}.
\end{itemize}
\index{equilibrium!stable}
\index{equilibrium!unstable}

In real-world terms, it is usually difficult to observe an unstable equilibrium with measured
data.  A small deviation from the equilibrium value in $Q(0)$ can and usually will produce solutions that
tend away from the equilibrium value.  On the other hand, stable equilibrium values will 
be easy to observe since even if $Q(0)$ is not exactly equal to the equilibrium value, 
the solution may tend to the equilibrium over time.  A physical analogy may be helpful
in understanding this distinction.  Consider a weight on the end of a rigid rod with one
end fixed in position, like
the pendulum in a grandfather clock.  There are two equilibrium positions: One
with the weight hanging straight down; one with the weight exactly balanced at the 
top and the rod pointing straight up.  In theory, the rod can stay motionless in either of 
these two positions. The first of these is stable because pulling
the weight to either side by a small amount will yield motions that stay close
to the equilibrium position.  The second of these is unstable because moving
the weight even slightly from the straight up position will cause it to move
far away from that position.  

To determine the equilibrium solutions of a difference equation (if there are any), the most direct way is to 
rewrite the equation in the form 
$$Q(n+1) - Q(n) = {\rm some\ function\ of\ } Q(n)\ {\rm and\ } n$$
discussed in Example~\ref{AffImmigrationEmigration}.  If there is a constant value of $Q(n)$ that makes the right-hand
side \emph{equal to zero for all $n$}, then that value gives an equilibrium solution.  

\begin{example}
\label{EquilEx1}
The affine difference equation $Q(n+1) = (1.5)\cdot Q(n)  - 8$ can be rewritten as 
$$Q(n+1) - Q(n) = (0.5)\cdot Q(n) - 8.$$
The right-hand side of the rearranged equation is zero for all $n$ if $Q(n) = 16$.
This is the only equilibrium solution in this case.  

On the other hand, suppose we started from the difference equation $Q(n+1) = (1.5)\cdot Q(n) + 8$.
Rearranging as above gives 
$$Q(n+1) - Q(n) = (0.5)\cdot Q(n) + 8.$$
Here the right-hand side is zero only if $Q(n) = -16$.  If negative values for $Q$ were possible,
this would be a relevant constant solution.  Otherwise if $Q > 0$ is necessary, we might say $Q$ has
no (positive) equilibrium values. $\triangle$
\end{example}

Our final example previews the difference equations considered in the next section.
\begin{example}
\label{EquilEx2}
For instance, consider the following difference equation and rearrange by subtracting $Q(n)$ and 
then factoring the right-hand side:
$$Q(n+1) = (1.1)\cdot Q(n) - (Q(n))^2 \Leftrightarrow Q(n+1) - Q(n) = (0.1)\cdot Q(n)\cdot(1 -  10\cdot Q(n)).$$
The right-hand side of the rearranged equation is zero for all $n\ge 0$ when $Q(n) = 0$ and also 
when $Q(n) = 1/10$.  Hence these are both equilibrium solutions.  $\triangle$
\end{example}

\specialsection{Logistic Growth Models}
\index{model!logistic growth|(}
\index{logistic growth model|(}
As we pointed out in Chapter 5, the exponential models that are solutions of the difference
equations 
$$Q(n+1) = a\cdot Q(n)$$
may capture the behavior of biological populations in the short run.  But they necessarily
cease being realistic in both the cases $a > 1$ and $0 < a < 1$.  In the first
case, the mathematical solutions are unbounded.  Hence, if we track the predictions of an exponential 
model, $Q(n)$ will eventually exceed any positive value, no matter how large that value is.
This is impossible because real-world habitats are limited in space and in resources
to support the organisms.  In the second case, the values of $Q(n)$ will eventually decline
to numbers between $0$ and $1$ and this is also impossible if $Q(n)$ represents a 
number of individuals.\footnote{If $Q(n)$ represents a total biomass of the organisms, then
values between $0$ and $1$ are not necessarily a problem.  However, $Q(n)$ would 
still decline to values small enough to be unrealistic biomass values for $n$ sufficiently large, 
and this is a problem.}

In this section we will present and study another class of difference equation models, 
the so-called \emph{logistic} models, that are designed to allow more realistic
modeling of populations in resource-limited habitats.  Related differential equation models
were first introduced, interestingly enough, in the modeling of \emph{human populations} by a 
Belgian demographer named Pierre-Fran\c cois Verhulst
\index{Verhulst, Pierre-Fran\c cois}
in the 1830's.  But they are applicable much more
generally.  

\begin{assumptions}
\label{LogAss}
The assumptions underlying a logistic model for a population of a single species are the following:
\begin{enumerate}
\item[(a)]  The population is \emph{unstructured by age} and the habitat is \emph{closed} (no in- or out-migration).  
\item[(b)]  There is a (constant) \emph{maximum sustainable population} for the species that is a property
of the habitat being modeled.  This is usually called the \emph{carrying capacity} of the habitat in biology.\footnote{We discussed
power law models for how this maximum sustainable population might depend on the average size or 
body mass of the animals at the start of Chapter 6.}
We will denote this positive constant by $M$.
\index{carrying capacity}
\item[(c)]  For all $n$, the percentage change of the population per unit time between $t = n$ and $t = n+1$
\index{percent change}
is proportional to the difference between
$1$ and the ratio $Q(n)/M$, with a positive proportionality constant that we will denote by $r \times 100\%$.
\end{enumerate}
\end{assumptions}

The rationale here is that $Q(n)/M$ 
can be thought of as the \emph{fraction of the carrying capacity accounted for by the population} at time $n$. If this is less than $1$, 
then $1 - Q(n)/M$ represents the fraction of unused capacity or ``room to grow.''    If $Q(n)/M > 1$, on the other hand, then
the population is larger than the maximum sustainable population and $1 - Q(n)/M < 0$ means the carrying capacity
is exceeded.    Assumption (c)  implies that if $Q(n)$ is smaller than $M$, 
then $Q(n + 1)$ will be larger than $Q(n)$.   If $Q(n) = M$, then
the percentage growth rate is actually equal to $0$, and we have an equilibrium solution
as discussed in the previous section.  Finally, if $Q(n)$ is larger than $M$, the percentage
growth rate is negative and $Q(n+1)$ will be smaller.  The proportionality constant $r$, or rather $r \times 100\%$, can be interpreted
as the natural net percentage population change per unit time that the species would experience
in a habitat with unlimited resources.\footnote{Technical note:  Think of letting $M \to \infty$, so $Q(n)/M \to 0$ for any $Q(n)$.}

As a difference equation, the logistic model looks like this.  The assumption (c) above
translates into an equation
\begin{equation}
\label{LogisticUnSimp}
\frac{Q(n+1) - Q(n)}{Q(n)} = r\cdot\left(1 - \frac{Q(n)}{M}\right),
\end{equation}
where $r$ is the proportionality constant from assumption (c) above.  If $Q(n) = 0$, then the percentage change
between $Q(n)$ and $Q(n+1)$ is given by $r \times 100\%$.  

We will usually rearrange this to the standard  \emph{logistic equation} form:
\begin{equation}
\label{eq:Logistic}
\framebox{$\displaystyle{Q(n+1) = (1 + r)\cdot Q(n) - \frac{r\cdot (Q(n))^2}{M}}.$}
\end{equation}

\begin{example}
For instance, if $Q$ is increasing at a $20\%$ rate per unit time when $Q = 0$, then $r = .2$.  Say the carrying capacity is $M = 100$.
Then the corresponding logistic difference equation as in \eqref{eq:Logistic} is
\begin{align}
\label{eq:LogModel}
Q(n+1) &= (1.2)\cdot Q(n) - \frac{(0.2)\cdot (Q(n))^2}{100}\\ \nonumber
 &= (1.2)\cdot Q(n) - (0.002)\cdot(Q(n))^2.
\end{align}
Figure~\ref{fig:LogisticSols} plots several solutions of this difference equation, with initial conditions 
$Q(0)$ between $0$ and $100$, equal to $100$ and greater than $100$.  
\begin{figure}
\begin{center}
\includegraphics[width=3.0in,width=3.0in]{LogisticSols.png}
\caption{Several solutions of \eqref{eq:LogModel}.}
\label{fig:LogisticSols}
\end{center}
\end{figure} 
In the population model context, any value of $Q(0) \ge 0$ would be a possibility.  There are two equilibrium
\index{equilibrium!solution}
solutions of this equation, namely $Q(n) = 0$ and $Q(n) = 100$ for all $n$.  This is easiest
to see from the unsimplified form \eqref{LogisticUnSimp} if we multiply through by $Q(n)$. 
From the plots, we guess that $0$ is an unstable equilibrium and $100$ is a stable equilibrium.   $\triangle$
\index{equilibrium!solution}
\end{example}

The logistic difference equation~\eqref{eq:Logistic} is not linear.  A byproduct of this fact is that, unlike the affine first order
equations considered before, logistic equations do not possess convenient closed formulas for the solutions (except for the equilbrium solutions!)
This means that if we want to investigate solutions of a logistic equation, we may need to generate a list of the values $Q(n)$
one at a time 
for some range of $n$ and possibly plot the data points $(n,Q(n))$.  This can be done in a number of different ways either by
hand or using software. 
\index{spreadsheet}
  Excel can be adapted for this purpose quite easily by making use of the addressing conventions
when formulas are copied from one cell into another.   For instance, the following commands will generate the values of $n$ and 
$Q(n)$ for the solution of \eqref{eq:LogModel} and initial condition $Q(0) = 20$, $n = 0, \ldots, 20$ in two parallel columns, then generate a point plot of the 
$(n,Q(n))$.  
\begin{itemize}
\item Enter $0$ in cell {\tt A1} and $20$ in cell {\tt B1}.  (You might also want to enter text column headings in those columns; if so start in row 2 instead
of row 1.)
\item Enter the formula (macro) {\tt =A1+1} in cell A2 and press ENTER/RETURN.  Enter {\tt =(1.2)*B1-(0.002)*B1\^{}2} in cell {\tt B2} and press ENTER/RETURN.
\item Copy the formula from cell {\tt A2}, highlight cells {\tt A3} through {\tt A21} and paste.  You should see the numbers $2,3,\ldots,20$ in those cells.  
What is happening is that when you paste, the row number in the address {\tt A1} from is increased by 1 each time it is inserted in a new row down 
the column.  This is happening because we did \emph{not} use {\tt \$A\$1} to make it an absolute address.
\item Similarly if you copy and paste the formula from {\tt B2}, the copy in cell {\tt B3} will have the address {\tt B1} updated to {\tt B2}, so the 
formula will be evaluated using the value in {\tt B2}, the copy in cell {\tt B4} will
use the value in {\tt B3} and so forth.  The result is to compute each value of $Q(n+1)$ using the previous value $Q(n)$, just
as we want.  
\item With the parallel columns {\tt A} and {\tt B} rows {\tt 1} through {\tt 21} (i.e. the rectangular block {\tt A1:B21}, you can
generate a point plot (scatter plot) using the Insert/Chart Design options and this shows the $(n,Q(n))$ data points.
\end{itemize}
\index{model!logistic growth|)}
\index{logistic growth model|)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Plotting behavior of solutions with Excel
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection*{Modeling with Logistic Equations}
In applications, one common procedure is to take a real-world data set
and \emph{fit} a logistic model to it in order to estimate the proportionality
constant $r$ and/or the carrying capacity $M$, and then use that information
and the solutions of the logistic differential equation to understand 
projected behavior (assuming that $r$ and $M$ remain constant).  The quality
of the results will usually depend on how well those assumptions match the 
real-world situation(!)

\begin{example}
\label{LogisticFit}
In Exercise~\ref{UsPopEx} from Chapter 5, we discussed fitting linear and exponential models to the 
U.S. population data from 1790 through 2010.  This is reproduced for the reader's convenience in Table~\ref{USPopulationAgain}.  
Let us now reconsider this data and see the process of fitting a logistic model.  
\begin{table}[ht]
\renewcommand\arraystretch{1.5}
\caption{U.S. Population According to Federal Census Records}
\label{USPopulationAgain}
\noindent\[
\begin{array}{|c|c||c|c|}
\hline
{\rm Census} & {\rm Population} & {\rm Census} & {\rm Population}\\ 
\hline
1790 & 3,929,214 & 1800 & 5,308,483\\
\hline
1810 & 7,239,881 & 1820 & 9,638,453\\
\hline
1830 & 12,866,020 & 1840 & 17,069,453\\
\hline
1850 & 23,191,876 & 1860 & 31,443,321\\
\hline
1870 & 38,558,371 & 1880 & 50,189,209\\
\hline
1890 & 62,979,766 & 1900 & 76,212,168\\
\hline
1910 & 92,228,496 & 1920 & 106,021,537\\
\hline
1930 & 123,202,624 & 1940 & 132,164,569\\
\hline
1950 & 151,325,798 & 1960 & 179,323,175\\
\hline
1970 & 203,211,926 & 1980 & 226,545,805\\
\hline
1990 & 248,709,873 & 2000 & 281,421,906\\
\hline
2010 & 308,745,538 & & \\
\hline
\end{array}
\]
\end{table}
For simplicity, let us say that $n$ here represents the number of 10-year periods
after $1790$.  So $n = 0$ corresponds to the first census in 1790 and
$n = 22$ corresponds to the most recent census in 2010.\footnote{I am writing this in July, 2017.}
The idea comes directly from \eqref{LogisticUnSimp}, the translation
of assumption (c) above describing logistic models.  We
need to compute the approximate percentage changes \emph{per unit time} first (but
remembering that the unit of time is 10 years, not 1 year.  For
this we will use the values
$\frac{Q(n+1) - Q(n)}{Q(n)}$.  

\index{logistic growth model!fitting}
To make a point, we will only use the data from the censuses starting
from 1790 through 1930.  We fit a linear function of $Q$,
say $\hat{m} \cdot Q +\hat{b}$, to the data points 
$$\left(Q(n),\frac{Q(n+1) - Q(n)}{Q(n)}\right), \quad n = 0,1,2,\ldots,14.$$
Then from the right side of \eqref{LogisticUnSimp},
$$\hat{m} \cdot Q + \hat{b} \doteq  r\cdot \left(1 - \frac{Q}{M}\right) = \frac{-r}{M}\cdot Q + r,$$
we estimate $r \doteq \hat{b}$ and 
$$\hat{m} \doteq \frac{-r}{M} \Rightarrow M \doteq \frac{-r}{\hat{m}} = \frac{-\hat{b}}{\hat{m}}.$$
The results are shown in Figure~\ref{fig:LogFit}.
\begin{figure}
\begin{center}
\includegraphics[width=3.0in,width=3.0in]{USPopLogisticFit.png}
\caption{Fitting a logistic model to the data from 1790 - 1930.}
\label{fig:LogFit}
\end{center}
\end{figure} 
As you can see from the plot, the fit is reasonably good; the regression $R^2 \doteq .91$.  
\index{R@$R^2$-statistic}
But in any case, the equation of the regression line is approximately
$$0.364 - (2.208\times 10^{-9})\cdot Q$$
which says our estmated $r \doteq .364$ and 
$$M \doteq \frac{-.364}{-2.208\times 10^{-9}} \doteq 1.649 \times 10^8.$$
The plot in Figure~\ref{fig:ActualVsModel} shows the model's predicted values
for 1790 through 2010 (in black) together with the actual population data (in red).
\begin{figure}
\begin{center}
\includegraphics[width=3.0in,width=3.0in]{ActualAndModel.png}
\caption{Logistic model from the 1790 - 1930 data (in black) and actual population (in red).}
\label{fig:ActualVsModel}
\end{center}
\end{figure} 
The model's predicted values are quite close until $n = 160$ (1950), and
after that the model values are leveling off and approaching the predicted
carrying capacity of $164,900,000$.  On the other hand the actual population
is still increasing rapidly.  

The point we wished to make here is that even though the logistic fit is
quite good up until about 1940, there are a number of features of this real-world
situation that do not match the underlying assumptions of the logistic model
as described before.  First, the U.S. population was definitely not evolving 
in a closed habitat.  The geographical area under the jurisdiction of the
U.S. government was not even constant -- it was continually expanding through 
the 19th century.  Moreover, the population grew as a result of large numbers of 
immigrants from Europe, Latin America, Asia, as
well as enslaved persons from Africa before 1860.
Second, the assumption that the carrying capacity was a constant does not reflect
the fact that improvements in all sorts of technologies have certainly made
it possible to support larger human populations in the same land area.  In fact, the model's
estimated carrying capacity of $164,900,000$ was exceeded almost as
soon as the interval we modeled was complete.   
Hence it is probably to be expected that the logistic model only fits
the data reasonably well in the period corresponding to the data points we used.  $\triangle$
\end{example}

Logistic models have some other unexpected and interesting properties ``up their sleeves.''
See Exercise~\ref{ex:Chaos} below in particular. 

\specialsection{Chapter Project}
\index{logistic growth model!with harvesting|(}
Environmental scientists often try to estimate populations of plant or animal species and understand
to what extent they can be used as resources by humans without being depleted.  For instance, 
populations of wild fish and other marine creatures around the world have been a major source of food for 
humans for many years.  Yet there is evidence that many of them have been overfished and
there is fear some of them may be headed toward extinction.  
For example, following 500 years of fishing, by the summer of 1992, the biomass of northern cod 
observed in Atlantic waters off the coast of Newfoundland had fallen to an estimated $1\%$ of its
previous levels.  As a result, the federal government of Canada declared a moratorium on cod
fishing, hoping to give the cod populations time to recover.  The economic and social impacts on the human
population of Newfoundland were severe, since many of the people in the area derived 
their entire livelihood from cod fishing and others depended on cod fishermen as customers for
their businesses.  
An estimated $35,000$ people lost their jobs as 
and the whole society of Newfoundland has not really recovered to this day.  As of around 2010,
there were some encouraging signs that the cod fishery might be recovering, but the effects of other 
factors such as changes in ocean temperature and loss of populations of the food species that cod eat 
have kept the ultimate fate of the north Atlantic cod fishery uncertain.  Similar decreases have been
observed in New England cod populations more recently and the U.S. government has
instituted more and more stringent fishing limits to try to avert collapses here as well.  The 
fishing industries of Maine and Massachusetts are under similar pressures.  

In this project, you will study various models of a fishery including effects from fishing by humans.
Let $P(n)$ represent the total mass of mature Pacific halibut in units of $10^6$ kg.  We will model
the wild halibut biomass \emph{without any fishing} by the following logistic difference equation 
\begin{equation}
\label{eq:Halibut}
P(n+1) = (1.71)\cdot P(n) - (.00875)\cdot (P(n))^2.
\end{equation}
Here $r = .71$ and $r/M = .00875$.
\subsection*{Questions}
\begin{enumerate}
\item[(A)] {\it ``Greedy'' harvesting.}  Suppose the halibut stock started out at $95\%$ percent of the carrying 
\index{harvesting!greedy}
capacity according to the model \eqref{eq:Halibut}.   But in one massive fishing effort, the halibut
biomass is reduced all the way down to $1\times 10^6$ kg (say all within one year).  If no 
further fishing is allowed until stocks recover to $95\%$ of the carrying capacity, how 
long will that take, according to the model?  Estimate by computing a solution
of the difference equation \eqref{eq:Halibut}.  What would be the \emph{average fish amount
taken per year} if this process of massive fishing followed by fallow time to allow recovery to $95\%$ of the carrying capacity
was done repeatedly over a long period?
\item[(B)]  {\it Constant harvesting.}   One way to make use of a resource like
the halibut fishery that is less drastic than the ``greedy'' approach in (A) is to take some constant amount of fish every year.
\begin{enumerate}
\item[(1)]  Suppose that everything remains as in \eqref{eq:Halibut}
above, but some constant amount $h$ (in $10^6$ kg)
of halibut biomass is removed each year via fishing.\footnote{Think $h$ means a ``harvesting level,'' hence
the notation.}  What modified difference equation models
this situation?  (Think about the derivation of \eqref{eq:Logistic} and take the fishing
amount $h$ into account.)
\item[(2)]  Investigate the solutions of your constant harvesting difference equation from part
(1) if the fishing term is each of these values:  $h = 5, 10, 14,  20$, one at a time.  
Choose enough different $P(0)$ values for each so that you think you see the whole picture and then
describe what is happening in words.  In particular, for each $h$
how many different equilibrium solutions are there?  Where are they located?  How
do they change as $h$ increases?  Are they
stable or unstable?  
\item[(3)]  By rewriting your difference equation from part (1) in the form 
$$P(n+1) - P(n) = \cdots ,$$
what is the \emph{maximum value} of $h$ for which the equation still has a stable equilibrium?
(This question can be answered by means of algebra alone if you think about it the right way!)
\item[(4)]  What should it mean to say that a fishing level $h$ is \emph{sustainable}?
\index{sustainable harvesting}
\index{harvesting!sustainable}
\index{harvesting!constant}
\index{harvesting!proportional}
\index{equilibrium!solution}
What is the maximum sustainable constant fishing level?  Does the answer depend on what the initial value $P(0)$ at the
start of the fishing intervention is?
\item[(5)] What would be the \emph{average fish amount
taken per year} if constant harvesting at the maximum sustainable level is done repeatedly over a long period?
\end{enumerate}
\item[(C)] {\it Proportional harvesting.}   Instead of taking a constant amount of fish, we
could also take a constant proportion of whatever fish biomass is present.
\begin{enumerate}
\item[(1)]  Next, suppose that everything remains as in \eqref{eq:Halibut}
above, but instead of a constant amount, suppose that a constant \emph{proportion} $p$
of the halibut biomass (whatever it is) is removed each year via fishing.\footnote{Think $0 < p < 1$ with $p = 1$ meaning
all of the fish are removed.}  
What modified difference equation models
this situation?  (Think about the derivation of \eqref{eq:Logistic} and take the proportion removed by fishing into account.)
\item[(2)]  Investigate the solutions of your constant harvesting differential equation from part
(1) if the fishing term is each of these values:  $p = 0.1, 0.3, 0.5, 0.8$, one at a time.  
Choose enough different $P(0)$ values so that you think you see the whole picture and then
describe what is happening in words.  In particular, for each value of $p$
how many different equilibrium solutions are there?  Where are they located?  How
do they change as $h$ increases?  Are they stable or unstable?  
\item[(3)]  By rewriting your difference equation from part (1) in the form 
$$P(n+1) - P(n) = \cdots ,$$
what is the $p$ for which the halibut population starts to ``crash'' for all $P(0)$?
(This question can be answered by means of algebra alone if you think about it the right way. And the answer
should make biological sense too!)
\item[(4)]  What should it mean to say that a fishing proportion $p$ is \emph{sustainable}?
What values of $p$ are sustainable?  Does the answer depend on what the initial value $P(0)$ at the
start of the fishing intervention is?
\item[(5)] What would be the \emph{average fish amount
taken per year} if proportional harvesting at the level $p = .3$ is done repeatedly over a long period?
\end{enumerate}
\end{enumerate}
\subsection*{Assignment} Compare the strategies in parts (A), (B), (C) from the point of view of their effect on the
halibut fishery and the average amounts taken per year.   If you were going to recommend one, which
would it be?  Explain how you are making your determination.
\index{logistic growth model!with harvesting|)}

\begin{xcb}{Chapter Exercises}
\vskip 5pt
\begin{enumerate}

\item 
\label{ExpPctChange}
Suppose a quantity $Q(t)$ satisfies the property that for all $n\ge 0$,
\emph{the percentage change in $Q$ between
\index{percent change}
$t = n$ and $t = n + 1$ is always the same}, say $r \%$.  Show that $Q(t)$ satisfies the difference
equation 
$$Q(n+1) =\left(1 + \frac{r}{100}\right)Q(n) \quad {\rm for\ all}\ n \ge 0.$$
Deduce that $Q(n) = Q(0) \cdot \left(1 + \frac{r}{100}\right)^n$ for all $n\ge 0$.   

\vskip 5pt
\item Continue the calculation begun after Example~\ref{SecondOrder} to find the values $Q(5)$, $Q(6)$,
and $Q(7)$
if $Q(n)$ satisfies \eqref{eq:ExSecondOrder} and $Q(0) = 1$, $Q(1) = 2$.

\vskip 5pt
\item Follow the calculation begun after Example~\ref{SecondOrder} to find the values 
$$Q(2), Q(3), Q(4), Q(5), Q(6), Q(7)$$
if $Q(n)$ satisfies \eqref{eq:ExSecondOrder}, but now use different intiial conditions $Q(0) = 3$ and $Q(1) = 1$.  
Your values should be completely different from what you saw in the previous Exercise.

\vskip 5pt
\item
Solve the following first order difference equations with the given initial conditions.
\begin{enumerate}
\item[(a)]  $Q(n+1) = (1.8)\cdot Q(n)$ with $Q(0) = 3.4$. \vskip 5pt
\item[(b)]  $Q(n+1) = (.78)\cdot Q(n) - .03$ with $Q(0) = 4.3$ 
\end{enumerate}

\vskip 5pt  
\item The first order difference equation $Q(n+1) = (Q(n))^2/4$ does
not fall into any of the general patterns we discussed in the text.  
\begin{enumerate}
\item[(a)]  Compute the values $Q(1),\ldots, Q(4)$ if $Q(0) = 5$. \vskip 5pt
\item[(b)]  Compute the values $Q(1),\ldots, Q(4)$ if $Q(0) = 1/2$.  \vskip 5pt
\item[(c)]  By examining the values of $Q(n)$ for a general initial condition $Q(0) = a$, guess
a formula for the general solution. \vskip 5pt
\item[(d)]  Does this differential equation have any equilibrium solutions?  If so, what
are the equilibrium values?  What appears to be true about their stability?
\end{enumerate}

\vskip 5pt
\item (For the optional \S 7.3.)  Consider the difference equation 
$$Q(n+2) - 2\cdot a\cdot Q(n+1) + a^2 Q(n) = 0.$$  
Show that 
the characteristic equation has $a$ as a double root and that every function 
of the form $Q(n) = c_1 \cdot a^n + c_2 \cdot n \cdot a^n$, with $c_1,c_2$ 
constant, is a solution.

\vskip 5pt
\item 
\label{ex:InhomogHomog}
(For the optional \S 7.3.)  Show that if $Q_1(n)$ and $Q_2(n)$ are any two solutions of the 
inhomogeneous difference equation $Q(n+2) + r\cdot Q(n+1) + s\cdot Q(n) = f(n)$, then the
difference $Q(n) = Q_1(n) - Q_2(n)$ solves the associated homogeneous difference equation
$Q(n+2) + r\cdot Q(n+1) + s\cdot Q(n) = 0$.  

\vskip 5pt
\item (For the optional \S 7.3.)  Solve the following difference equations and initial conditions.
\begin{enumerate}
\item $Q(n+2) + 7\cdot Q(n+1) + 6\cdot Q(n) = 0$, $Q(0) = 4$, $Q(1) = 2$.\vskip 5pt
\item $Q(n+2) + 6\cdot Q(n+1) + 9\cdot Q(n) = 0$, $Q(0) = 1$, $Q(1) = 1$.\vskip 5pt
\item $Q(n+2) - 6\cdot Q(n+1) + 8\cdot Q(n) = n+3$, $Q(0) = 1$, $Q(1) = 3$ \vskip 5pt 
\item $Q(n+2) + 4\cdot Q(n+1) + 3\cdot Q(n) = 5^n$, $Q(0) = 2$, $Q(1) = 1$.
\end{enumerate}

\vskip 5pt
\item (For the optional \S 7.3.)  Consider the inhomogeneous second order linear difference
equation with constant coefficients:
$$Q(n+2) + r\cdot Q(n+1) + s\cdot Q(n) = c.$$
\begin{enumerate}
\item[(a)] If $c$ is constant and $1 + r + s \le 0$, then show that
$Q(n) = \frac{c}{1 + r + s}$ is an equilibrium solution. \vskip 5pt
\item[(b)]  Assume the characteristic equation has two distinct real roots or  a real double root. 
Explain why this equilibrium is \emph{stable} only in the case that the roots of the
characteristic equation are all less than 1 in absolute value.
\end{enumerate}

\vskip 5pt
\item
\label{ex:MultAcc}  (For the optional \S 7.3.)
\index{multiplier-accelerator model}
\index{Samuelson, Paul}
In 1939, the economist Paul Samuelson (1915-2009) developed the \emph{multiplier-accelerator} 
model,\footnote{``Interactions Between the Multiplier Analysis and the Principle of Acceleration," Review of Economic Statistics. 21 (2): 75--78.}
a simple difference equation macroeconomic model.  This was a major
advance because in some cases (i.e. for some values of the parameters $\alpha, \beta$ in the coefficients)
it gave solutions exhibiting \emph{cyclical} behavior like the periodic boom-bust cycles
that are observed in real-world economic systems.  In this problem, you will work through
the derivation of the multiplier-accelerator model, a second-order linear difference
equation.  The cyclical behavior occurs when the characteristic equation has complex
conjugate roots as discussed in the text.  The function $Q(n)$ in the model represents the total 
level of activity at time $t = n$ in the economy of a whole nation.  By assumption, this
exactly matches the spending intentions
of the government, the consumption intentions $C(n)$ of households, and the investment 
intentions $I(n)$ of businesses.  For simplicity, say the government spending is constant $= 1$,
then
\begin{equation}
\label{eq:TotalAct}
Q(n) = 1 + C(n) + I(n).
\end{equation}
\begin{enumerate}
\item[(a)]  The ``multiplier effect'' is the statement that $C(n)$ is proportional to the economic
activity, but with a time lag:  $C(n) = \alpha\cdot Q(n-1)$ for some constant $\alpha$.  The ``accelerator
effect'' is the statement that the business investment reacts to how consumption is \emph{changing}:
$I(n) = \beta\cdot(C(n) - C(n-1))$, for some constant $\beta$.  Substitute these into 
\eqref{eq:TotalAct}
to obtain the \emph{multiplier-accelerator model}:
$$Q(n) = 1 + \alpha\cdot (1 + \beta)\cdot Q(n-1) - \alpha\cdot \beta\cdot Q(n-2).$$
Reindex and rearrange algebraically to put this in our standard form:
$$Q(n+2) - \alpha(1 + \beta)\cdot Q(n+1) + \alpha\cdot \beta\cdot Q(n) = 1.$$
\item[(b)]  In the rearranged form in part (a), suppose $\alpha = 0.4$ and $\beta = 2$.  Show
that the characteristic equation of the difference equation has no real roots.
\item[(c)]  Continuing with the values of $\alpha,\beta$ in part (b), and initial conditions $Q(0) = 1$, $Q(1) = 1.1$ 
compute the values of $Q(n)$ for $n = 2,\ldots, 20$.  (You may want to use Excel for this.) Describe what the solution is doing in words.
\end{enumerate}

\vskip 5pt
\item 
\index{Moore's Law}
\label{Moore}
Table~\ref{MooreTable} gives the number of transistors on some CPU chips as a function of time.
\begin{table}[ht]
\caption{``Moore's Law''}\label{MooreTable}
\renewcommand\arraystretch{1.5}
\noindent\[
\begin{array}{|c|c|c|}
\hline
{\rm CPU} & {\rm Year} & {\rm Number\ of\ Transistors} \\
\hline
{\rm 4004}& 1971 & 2250\\
\hline
{\rm 8008}& 1972 &2500\\
\hline
{\rm 8080}& 1974 &5000\\
\hline
{\rm 8086}& 1978 &29,000\\
\hline
{\rm 286}& 1982 & 120,000\\
\hline
{\rm 386}& 1985 & 275,000\\
\hline
{\rm 486\ DX}& 1989 & 1,180,000\\
\hline
{\rm Pentium}& 1993&1 3,100,000\\
\hline
{\rm Pentium\ II}& 1997 & 7,500,000\\
\hline
{\rm Pentium\ III}& 1999 & 24,000,000\\
\hline
{\rm Pentium\ 4}& 2000 & 42,000,000\\
\hline
{\rm Xeon}& 2008 & 1,900,000,000\\
\hline
\end{array}
\]
\end{table}
Fit an exponential model to this data and compare with \eqref{eq:MooreModel} in Example~\ref{ExpExample} in the text.

\vskip 5pt
\item  Suppose that in 2017, the population of a country was $34,000,000$.  The death rate exceeds the birth rate by 
$0.3\%$ per year, but each year $100,000$ more people are entering the country from the outside than leaving.\vskip 5pt
\begin{enumerate}
\item Express the information above as a difference equation model.  \vskip 5pt
\item Using your model, compute the projected population each year until the year 2037.  Describe what is happening in 
words.  \vskip 5pt
\item What is the equilibrium level of your difference equation model?  
\end{enumerate}

\vskip 5pt
\item For each of the following logistic models and initial conditions, 
\begin{itemize}
\item[(i)] Identify the $r,M$ parameters from the model,
\item[(ii)] Plot the solution using Excel for $n = 1,\ldots, 50$,
\item[(iii)]  Discuss the results.
\end{itemize}
\vskip 5pt
\begin{itemize}
\item[(a)]  $Q(n+1) = (1.03)\cdot Q(n) - (.006)\cdot(Q(n))^2$, $Q(0) = 0.8$. \vskip 5pt
\item[(b)]  $Q(n+1) = (1.34)\cdot Q(n) - (.0009)\cdot(Q(n))^2$, $Q(0) = 420$. \vskip 5pt
\item[(c)]  $Q(n+1) = (1.86)\cdot Q(n) - (.0048)\cdot(Q(n))^2$, $Q(0) = 1.3$.
\end{itemize}

\vskip 5pt
\item
Many biologists are not convinced that logistic models are the best choices for population modeling
in limited environments and a number of other sorts of models have been proposed as substitutes.\footnote{Technical note: One such
type is the class of so-called Gompertz models.  These are most commonly used in the continuous time case as 
differential equation models, but discrete-time versions have also appeared in the literature.}
Some of the objections involve point (a) in Assumptions~\ref{LogAss} -- that there is no age structure in the population.  In most
animal species for instance, immature juvenile individuals cannot reproduce and adults can live long enough
that they can no longer reproduce.  More realistic models would take that age stratification into account
by subdividing the population into several groups and tracking them separately.  We will study examples
of such models in the next chapter.  But there are also criticisms based on point (c)
in Assumptions~\ref{LogAss}.   We consider the logistic model 
in the form
$$Q(n+1) - Q(n) = r\cdot Q(n) - \frac{r (Q(n))^2}{M}.$$
\begin{enumerate}
\item[(a)]  Explain why the $\frac{r (Q(n))^2}{M}$ can be interpreted as the \emph{number of deaths per unit time due
to overcrowding, competition for resources, etc.} (i.e. excess deaths in addition to the natural deaths that would occur in an unlimited habitat). 
\item[(b)]  Explain why it is plausible that this number of excess deaths is proportional to $Q(n)\cdot Q(n)$.
\item[(c)]  Discuss whether it is plausible that this number of excess deaths should be also proportional
to the natural net growth rate $r$.
\end{enumerate}

\vskip 5pt
\item 
National censuses are also taken every 10 years in the United Kingdom, in years ending in 1.  
Follow what we did in Example~\ref{LogisticFit} in the text to fit a logistic model to the data at
\vskip 5pt
\centerline{\tt https://en.wikipedia.org/wiki/Demography$\_$of$\_$the$\_$United$\_$Kingdom\footnote{consulted July 12, 2017.}}
\vskip 5pt
\noindent
to fit a logistic model to the population of the United Kingdom, using the data from the table
marked {\it Population at Census Dates}.  Use data for the years 1851, 1861, 1871, 1881, 1891, 1901, 1911, 1921
(in the column marked {\it at start of period}).  What are the estimated $r,M$ for your model?
How well does your model fit the actual population over that time?
How well does it fit in the period following 1921?  

\vskip 5pt
\item 
The biologist G.F. Gause
\index{Gause, G.F.}
 published a well-known book called {\it The Struggle for Existence} in 1934.  Part
this was devoted to studies of one-celled organisms such as yeasts and paramecia in limited environments
demonstrating the effects of resource limitations and competition.  One of his experiments yielded 
data similar to that in Table~\ref{ParTable} for the combined numbers of two species of paramecia:\footnote{These numbers are
somewhat different than his from for the purposes of this problem.   He also continued the experiment to 25 days and eventually
observed oscillations about an equilibrium value.}
\begin{table}[ht]
\caption{Paramecium populations}\label{ParTable}
\renewcommand\arraystretch{1.5}
\noindent\[
\begin{array}{|c|c|}
\hline
{\rm Day} & {\rm Population}  \\
\hline
0 & 21\\
\hline
1 & 67\\
\hline
2 & 104\\
\hline
3 & 137\\
\hline
4 & 165\\
\hline
5 & 170\\
\hline
\end{array}
\]
\end{table}
\begin{itemize}
\item[(a)]  Following what we did in Example~\ref{LogisticFit}, fit a logistic model to this data set.
\item[(b)]  Use your model to predict the paramecium population out to 25 days.
\item[(c)]  Gause wrote ``At a certain moment the possibility of continued growth in a given
microcosm is apparently exhausted, and with a continuously maintained level of nutritive
resources, a certain equilibrium of population is established.'' Where does your model
predict that occurs here?
\end{itemize}

\vskip 5pt
\item
\label{ex:Chaos}
{\it Logistic Models and ``Chaos.''}
\index{logistic growth model!and ``chaos''}
\index{May, Robert}
The biologist Robert May pointed out in 1976\footnote{``Simple mathematical models with very complicated dynamics'' Nature 261(5560):459--467.}
that the solutions of logistic models can exhibit surprisingly complicated behavior when the $r$ parameter in \eqref{eq:Logistic}
is larger than the small values we have studied in the examples in the text.  Moreover, large values of $r$ can certainly occur
for species of insects, microorganisms, etc.  So this complicated behavior is not only of theoretical interest; it is something
that might be observed ``in the wild'' in some cases.  In this exercise, you 
will investigate some of this complicated behavior.  Consider the logistic equation
$$Q(n+1) = (1 + r)\cdot Q(n) - r\cdot (Q(n))^2,$$
where we have taken $M = 1$ for simplicity.  Using the initial condition $Q(0) = 0.3$, investigate the following cases by computing and
plotting solutions using Excel.  You will probably want to continue until $n = 100$ or so in all cases to see what is going on.\vskip 5pt
\begin{itemize}
\item[(a)]  Take $r = 2$ first.  What do the solution values do as $n$ increases? \vskip  5pt
\item[(b)]  Now repeat for $r = 2.5$.  Look at the computed values carefully in addition to the plot.  What is happening here? \vskip 5pt
\item[(c)]  Now repeat for $r = 2.5441$.  Again look at the computed values carefully. \vskip 5pt
\item[(d)]  Repeat for $r = 2.7$.  \vskip 5pt
\end{itemize}
The reasons for this cascade of more and more complicated behavior and a complete description of what is happening here (which is 
a LOT more complicated than the small number of different cases seen above!) have been rigorously established.\footnote{i.e. with full mathematical proofs
of precise statements of what is going on}
What you are seeing here is a few steps in the so-called \emph{period-doubling cascade} and the solutions for $r \ge 2.7$
are said to exhibit \emph{chaotic dynamics}.  Based on what you saw in part (d), that should seem like a reasonably descriptive name!  
\index{dynamic modeling|)}
\index{difference equation|)}
\index{model!dynamic|)}
\index{model!difference equation|)}

\end{enumerate}
\end{xcb}
\endinput
