next up previous contents
Next: Defining Labels and Initial Up: Installing a New Dynamical Previous: Defining Information About an   Contents


Defining Auxiliary Functions

We continue with the above example. Suppose that there is some scalar function of the phase space variables, time, and parameters which we wish to monitor. The scalar function may be a physically meaningful quantity such as the total energy of an (almost) conservative system, or it could be a mathematically interesting quantity such as the largest eigenvalue of the Jacobian matrix. Sometimes it is useful to have functions which represent coordinate transformations. For example, a particular dynamical system may be best described in terms of spherical coordinates. Auxiliary functions can also be used to monitor the distance from some set of interest. For example, if a system spends most of its time close to the sphere $\vert x\vert=1$ then it may be interesting to define a function $\vert x\vert$.

For our bouncing ball example, we will monitor the quantity $v^2$. Since $v_j$ is proportional to the ball's velocity just after it strikes the table for the $j$th time, we can think of $v_j^2$ as being a measure of the ball's kinetic energy at time $j$. To define this function, find the location in the file bball_def.c which reads

/* ------------------------------------------------------------------------
   function used to define aux functions of the varbs, time, or params
   ------------------------------------------------------------------------ */
/*
int user_aux_func(f,x,p)
double *f,*x,*p;
{
}
*/
and edit it to produce
/* ------------------------------------------------------------------------
   function used to define aux functions of the varbs, time, or params
   ------------------------------------------------------------------------ */
int bball_aux(f,x,p)
double *f,*x,*p;
{
   f[0] = x[1] * x[1];
}
The number of auxiliary functions is completely arbitrary; it is not necessary to have any auxiliary functions. When this equation is called, the calling routine passes in the current state of the phase space variables (in x), the current parameters (in p), and an array (f) which is filled up by this function.


next up previous contents
Next: Defining Labels and Initial Up: Installing a New Dynamical Previous: Defining Information About an   Contents
2008-05-14