Previous: cdiff, Up: Gradient functions


4.6 Complex step derivatives

— Function File: Df = jacobs (x, f)
— Function File: Df = jacobs (x, f, hook)

Calculate the jacobian of a function using the complex step method.

Let f be a user-supplied function. Given a point x at which we seek for the Jacobian, the function jacobs returns the Jacobian matrix d(f(1), ..., df(end))/d(x(1), ..., x(n)). The function uses the complex step method and thus can be applied to real analytic functions.

The optional argument hook is a structure with additional options. hook can have the following fields:

For example:

          f = @(x) [x(1)^2 + x(2); x(2)*exp(x(1))];
          Df = jacobs ([1, 2], f)