\documentclass[12pt]{article}
\usepackage{graphics}
\newcommand{\mw}{{\bf Main Window}}
\newcommand{\pw}{{\bf Parameter Window}}
\newcommand{\icw}{{\bf Initial Data Window}}
\newcommand{\dw}{{\bf Data Viewer}}
\newcommand{\aw}{{\bf AUTO window}}
\newcommand{\bw}{{\bf Boundary Cnd window}}
\newcommand{\diw}{{\bf Delay ICs window}}
\newcommand{\XPP}{{\em XPPAUT \,}}
\newcommand{\ppc}[1]{\fbox{{\tt #1}}}
\newcommand{\ppl}[1]{\fbox{{\bf #1}}}
\newcommand{\user}[1]{{\tt #1}}
\newcommand{\file}[1]{{\tt #1}}
\newcommand{\dbe}[2]{{\tt #1:} #2}
\begin{document}
{\bf NOTATION.} In this tutorial, menu items and dialog box names
will be boxed like
\ppc{this}, single letter commands are like \ppl{u},
and the \XPP windows will be in boldface like {\bf
this}. Numbers etc that are entered into dialog will appear like
\user{this}.
\section{Entering an equation}
To use \XPP, you must first create an equation file which tells the
program what the equations, functions, and parameters are. Typically,
these files have names like \file{myfile.ode}.The extension ``ode'' is
not important, but it reminds you that it is an \XPP file. We will
start with the logistic equation
\[
x_{n+1} = rx_n(1-x_n).
\]
Here is the ODE file for it
\begin{verbatim}
# logistic equation
x'=r*x*(1-x)
# parameter
par r=2.5
# initial condition
init x=.2
# tell XPP it is a discrete equation
@ meth=discrete
# tell it to use 200 points
@ total=200
done
\end{verbatim}
Type this file as an ASCII text file and save it. The lines starting
with \# are comments. Most everything can be changed from within the
program. However, the dimensions, names, etc cannot be altered.
The file is typed in pretty much the same way you would if you were
writing the equations; XPP is too stupid to recognize spaces for
multiplication, so you have to put the ``*'' sign between
quantities. {\bf Functions} such as {\tt am(V)} are defined in the obvious
fashion. {\bf Parameters} are declared with the {\tt par}
statement. They can be separated by spaces or commas. {\em The
``='' sign, the parameter name, and its starting value must have NO
spaces between them.}
THIS IS WRONG:
\begin{verbatim}
par gl = .3
\end{verbatim}
THIS IS RIGHT:
\begin{verbatim}
par gl=.3
\end{verbatim}
{\bf Initial data} can be defined with the {\tt init} statement. Each
file must end with a {\tt done} statement. Any line that starts with
a \# is a comment and ignored.
\section{Running a simulation}
Once you have enetered an ODE file, you can run XPPAUT on it with the
command (it varies from system to system).
To run \XPP in UNIX type {\tt xpp logistic.ode} at the command line. In
Winpp, click on the Winpp icon and load the equation. I have assumed
you have named the file \file{logistic.ode}.
If
everything was typed correctly, a main window and several other
windows appear. Three of these other windows are of interest:
\begin{itemize}
\item \icw. In this window, you can type in initial data
and then click on \ppc{Go} to run the simulation.
\item \pw. Here you can set the parameters. The \ppc{
Default} button puts the original parameters back in the slots.
\item {\bf Data Viewer.} This lets you see all the data computed.
\end{itemize}
{\bf Note:} If any of the windows appear ``dead'', then iconify them and
reopen them. This happens on some window managers.
The \mw has all the menus etc and the one we will work
from the most.
Click on \ppc{Initialconds} and then \ppc{Go} or tap \ppl{i} \ppl{g} and the
equations will be iterated for 200 steps.
Click on \ppc{Window} \ppc{window} ot tap \ppl{w} \ppl{w} to change
the window size. Fill in as follows
\begin{center}
\fbox{\begin{tabular}{ll|ll }
{\tt X Lo:}& 0 & {\tt Y Lo:} & 0 \\
\hline
{\tt X Hi:}& 200 & {\tt Y Hi:}& 1
\end{tabular}
}
\end{center}
and click on \ppc{Ok} or tap \ppl{Tab} to accept the values.
In the \icw, change the initial value to .01
and click on \ppc{Go}.
Change the parameter $r$ from 2.5 to 3.2 in the parameter window and click
on \ppc{Go}. Note that you have a period 2 solution. This may be hard
to see with this many points. Rewindow to expand around a small
region, for example
\begin{center}
\fbox{\begin{tabular}{ll|ll }
{\tt X Lo:}& 50 & {\tt Y Lo:} & 0 \\
\hline
{\tt X Hi:}& 100 & {\tt Y Hi:}& 1
\end{tabular}
}
\end{center}
Now change $r$ to 3.5. Click on \ppc{Erase} or tap \ppl{e} to clear
the window and click on either \ppc{Go} in the \pw or tap \ppl{i}
\ppl{g} in the \mw. What do you see now? A period 4 solution should
be clearly evident. Choose $r=3.75$ and look again. You might want to
make the window cover more iterates.
Exit the simulation now by clicking on \ppc{File} \ppc{Quit}
\ppc{Yes}.
\subsection{Homework}
Use \XPP to study the map
\[
x_{n+1} = r x_n e^{-x_n}
\]
by copying the old ODE file and replacing the function by
\begin{verbatim}
x' = r*x*exp(-x)
\end{verbatim}
Alternately, here is an easier way. Run \file{logistic.ode} but click
on \ppc{File} \ppc{Edit} \ppc{RHS's} to replace the right hand
side. Fill it in as
\begin{center}
\fbox{
X(n+1)=r*x*exp(-x)
}
\end{center}
and click on \ppc{Ok}. Change the Window size so that the Yrange is
between 0 and 8. Increase $r$ up to 20. For what value of $r$ do you
first see period doubling? period 4?
\section{Cobwebbing}
\XPP does not do cobwebbing, but you can make it do it by using a
special ODE file that I have created. You are welcome to look at the
file, but I do not include the code here as it is quite
baroque. However, it is instructive to use it. Run it my typing {\tt
xpp cobweb.ode} at the prompt. Before running it, click on
\ppc{Graphics} \ppc{Add Curve} (or tap \ppl{g} \ppl{a})
and fill in the resulting dialog box as
\begin{center}
\fbox{
\begin{tabular}{l|l|l}
{\tt X-axis:} st & {\tt Z-axis:} X & {\tt Line type:} 1\\
\hline
{\tt Y-axis:} map & {\tt Color:} 1 & {}
\end{tabular}
}
\end{center}
Click on \ppc{Ok}.
Repeat the above (that is, add a new curve), filling the dialog box
as:
\begin{center}
\fbox{
\begin{tabular}{l|l|l}
{\tt X-axis:} st & {\tt Z-axis:} X & {\tt Line type:} 1\\
\hline
{\tt Y-axis:} st & {\tt Color:} 5 & {}
\end{tabular}
}
\end{center}
Click on \ppc{Ok}.
You have added two graphs to the picture on the screen; a plot of
$f(x)$ vs $x$ and a plot of $x$ vs $x$, which is just a diagonal
line.
Now click on \ppc{Initial conds} \ppc{Go} (\ppl{i} \ppl{g}) and you
will get a nice cobweb. Change the parameter $r$ to 2.95, erase the
screen (\ppc{Erase} or \ppl{e}), and rerun the simulation. (Either
click on \ppc{Go} in the \pw, or tap \ppl{i} \ppl{g} in the \mw.)
Try $r=3.1$ and $r=3.5$.
Ok, now lets use this cobweb to look at the Ricker model
\[
x_{n+1} = r x_n e^{-x_n}
\]
To examine this model, you must change three things.
\begin{itemize}
\item Change the
function definition. Click on \ppc{File} \ppc{Edit}
\ppc{Functions} (\ppl{f} \ppl{e} \ppl{f}). Change {\tt F(X)} from {\tt r*x*(1-x)} to {\tt
r*x*exp(-x)} and then click on \ppc{Ok}.
\item Change the dimensions of the window using \ppc{Window}
\ppc{Window} and making the X and Y range between 0 and 8. (Change
{\tt X Hi}, {\tt Y Hi} to 8.)
\item Change the parameter {\tt scale} to 8.
\end{itemize}
Now run the Ricker model with $r=5,10,14,18.$
For the last cobwebbing example, try the function $f(x)=r\sin(2\pi x)$
with $0