SequenceTools Package
![f[x_]:=1-x^2/2;](images/SequenceToolsPics_gr_1.gif)
![Cobweb[f, .4, 12]](images/SequenceToolsPics_gr_2.gif)

Synopsis
This package provides several commands for dealing with sequences
and recursion in a mathematics classroom. There are commands for
calcuating tables and for plotting sequences, as well as commands
for visualizing 'cobwebbing', i.e. iterating a function. There is
also a command to produce a bifurcation plot.
Commands
The following commands are provided in this package:
BifurcationPlot[f, x0, {a, amin, amax}]
produces a bifurcation diagram for a
function f[x] which is defined in terms of the parameter a. (A good example
function to start with is f[x_]:= a*x*E^-x, with amin=2 and amax=20, and x0
between them). For each of many sampled values of the parameter a between
amin and amax, the plot shows the long-term orbit of x0 under repeated
iteration of f. By default, above each a-value on the horizontal axis
appears the values Nest[f,x0,100] through Nest[f,x0,200]. This can be
adjusted with the option Iterations, whose default setting is
Iterations->{100,200}. By default, the interval from amin to amax is
subdivided into 99 subintervals of equal width, and the 100 endpoints of the
subintervals are sampled. This can be adjusted in either of two ways: the
first is to use the option Subintervals, whose default setting is 99. The
second is to use the syntax BifurcationPlot[f, x0, {a, amin, amax, da}],
where da is the width of a single subinterval (the distance between
successive sample points).For the true control freaks, the option
Subintervals may also be set to a list of values that are to be sampled.
BifurcationPlot will accept any options accepted by ListPlot. A different
use of BifurcationPlot is also possible. What if the parameter a is fixed at
the value a0 and the intitial value x0 is permitted to vary? Simply adjust
the syntax to reflect this change: BifurcationPlot[f, {x0min, x0max}, {a,
a0}] does the job. In this case the horizontal axis represents the varying
values of the initial point x0. The options Iterations and Subintervals work
as above. One can also proceed in this investigation for a function f defined
without a parameter (such as f[x]=2*x*E^-x). In this case, use the even
simpler syntax BifurcationPlot[f, {x0min, x0max}] to get the plot.
Cobweb[f, x0, n]
gives a visual representation of the sequence {x0, f[x0], f[f[x0]], ...}
where each term is obtained from the previous term by applying
the function f, and where the last term is obtained by applying f precisely n
times. The command requires that f be a real-valued function of a single
variable, x0 be a real number, and n be a nonnegative integer. The sequence
itself can be generated with the command NestList[f, x0, n]. The Cobweb
command produces a plot of f togther with the line y=x, and the `cobweb'
comprised of the horizontal and vertical segments between these graphs. Also
displayed are red dots on the x axis indicating the values of the sequence
produced. Cobweb will accept any option accepted by the Plot command; in
particular, the setting AspectRatio->Automatic can be used to give both axes
the same scale. Also, the PlotRange option can be used to adjust the range of
values on each axis.
CobwebMovie[f, x0, n]
gives a visual representation of the sequence {x0,
f[x0], f[f[x0]], ...} where each element is obtained from the previous
element by applying the function f, and where the last member is obtained by
applying f precisely n times. The command requires that f be a real-valued
function of a single variable, x0 be a real number, and n be a nonnegative
integer. The sequence itself can be generated with the command NestList[f,
x0, n]. The CobwebMovie command produces a movie, that is a sequence of
graphics frames. Each frame shows a plot of f togther with the line y = x,
and the emerging `cobweb' comprised of the horizontal and vertical segments
between these graphs. Also displayed are dots on the x axis indicating the
values of the emerging sequence. CobwebMovie will accept any option accepted
by the Plot command; in particular, the setting AspectRatio->Automatic can be
used to give both axes the same scale, and the PlotRange option can be used
to adjust the range of values on each axis. There is one frame in the movie
for each of the n+1 members of the sequence.
DeltaTable[y, n]
produces a table of first through n-th differences for the
values of the sequence y. To use the command, the first argument y must be a
list of the first several values of a sequence. If the values are empirical
data, be sure that the corresponding x-values are evenly spaced (i.e. the
first differencs of the x data should be constant).
SequencePlot[s[n], {n, nmin, nmax}]
produces a plot of the sequence s, as n
ranges from nmin to nmax. SequencePlot[s[n], {n, nmin, nmax, step}] produces
a plot of the sequence s, as n ranges from nmin to nmax in increments of
step. SequencePlot will accept any option that ListPlot does. In particular,
you can connect the dots by adding the option PlotJoined->True. SequencePlot
will also accept a list of sequences as its first argument.
SequenceTable[s, {n, nmin, nmax}]
produces a table of values for the
sequence s as n ranges from nmin to nmax. SequenceTable[s, {n, nmin, nmax,
step}] produces a table of values where n ranges from nmin to nmax in
increments of step. SequenceTable will accept any options that TableForm
does. SequenceTable will also accept a list of sequences as its first
argument.
LogisticFit[xdata,ydata]
gives the coefficients for the `best fitting'
logistic growth sequence for the list of values ydata. The best fit sequence
is given by the difference equation p[n]=a*p[n-1]-b*p[n-1]^2, with initial
value corresponding to the first value in ydata. LogisticFit[data], where
data is a list of two-tuples {{x1,y1},{x2,y2},...}, will give the same
result. LogisticFit assumes the members of xdata are evenly spaced, and will
give poor results when this is not the case. The output also includes a
scatterplot of the original data, with the best fitting sequence
superimposed in blue.
Last Updated: June 20, 2002