Suppose that a user wishes to study Equation 4.1 numerically using DsTool. The first task is to define the equations. First, copy the file GENERIC.c to the file that you want to edit. For this example, call the target file bball_def.c. You can use any text editor to edit bball_def.c. The beginning of the file looks like:
#include <model_headers.h> /* ------------------------------------------------------------------------ function used to define the vector field or map ------------------------------------------------------------------------ */ int user_ds_func(f,x,p) double *f,*x,*p; { }
First change the name of this function from user_ds_func() to bball(). Then edit the function so that it properly defines the mapping. When you are finished, the function should look like:
#include <model_headers.h> /* ------------------------------------------------------------------------ function used to define the map ------------------------------------------------------------------------ */ int bball(f,x,p) double *f,*x,*p; { f[0] = x[0] + x[1]; f[1] = p[0] * x[1] - p[1] * cos(x[0] + x[1]); }
The mapping is now defined. We remind novice C-programmers that arrays in C are indexed from 0. When bball() is called, the calling routine is expected to pass in arrays f, x, and p. The input variables are the current state of variables (x) and the current parameters (p):
This function must be defined in order to begin exploration of dynamics. If the user does not wish to input information about the system's derivative or inverse, and if no auxiliary functions are desired, the user could proceed to Section 4.2.5. For the purpose of illustration, however, we encourage the reader to continue reading.
We remark at this point that although this system is a two-dimensional mapping,
the value contains the current ``time.'' In general, if there are
dependent variables, then x[0],
, x[k-1] contain these variables and
x[k] contains the independent variable.
This is true both for maps and for vector fields.
Adrian Bunk 2001-08-22