If derivative information is not provided by the
user, then DsTool will use finite difference-approximations. This section will describe
how to write a function which provides an explicit Jacobian for Equation .
Because time is discrete for maps, it does not make sense to define a derivative with
respect to time.
Currently, DsTool does not make use of derivatives with respect to time and parameters,
but we include them for the convenience of the user who wishes to extend the capabilities
of DsTool.
We now continue with the bouncing ball example by defining the Jacobian of f.
At the jth instant of time, the Jacobian is
/* ------------------------------------------------------------------------ function used to define the Jacobian ------------------------------------------------------------------------ */ /* int user_jac(m,x,p) double **m, *x, *p; { } */Using a text editor, modify this code segment to read
/* ------------------------------------------------------------------------ function used to define the Jacobian ------------------------------------------------------------------------ */ int bball_jac(m,x,p) double **m, *x, *p; { double temp; temp = p[1] * sin( x[0] + x[1] ); m[0][0] = 1.0; m[0][1] = 1.0; m[1][0] = temp; m[1][1] = p[0] + temp; }
The routine which calls bball_jac() sends in a matrix and two arrays which contain the current state and the current parameters for 72#72. When bball_jac() returns, it has filled the matrix with the numerical Jacobian for 73#73 evaluated at the current state. As remarked previously, writing a Jacobian routine is optional.