cdiff (optim_doc)

Next: jacobs, Previous: numhessian, Up: Gradient functions [Index]

### 4.5 A string, yielding the numerical gradient if evaluated

#### Helptext:

    c = cdiff (func,wrt,N,dfunc,stack,dx) - Code for num. differentiation
      = "function df = dfunc (var1,..,dvar,..,varN) .. endfunction

    Returns a string of octave code that defines a function 'dfunc' that
    returns the derivative of 'func' with respect to it's 'wrt'th
    argument.

    The derivatives are obtained by symmetric finite difference.

    dfunc()'s return value is in the same format as that of  ndiff()

    func  : string : name of the function to differentiate

    wrt   : int    : position, in argument list, of the differentiation
                     variable.                                Default:1

    N     : int    : total number of arguments taken by 'func'.
                     If N=inf, dfunc will take variable argument list.
                                                            Default:wrt

    dfunc : string : Name of the octave function that returns the
                      derivatives.                   Default:['d',func]

    stack : string : Indicates whether 'func' accepts vertically
                     (stack="rstack") or horizontally (stack="cstack")
                     arguments. Any other string indicates that 'func'
                     does not allow stacking.                Default:''

    dx    : real   : Step used in the symmetric difference scheme.
                                                     Default:10*sqrt(eps)

    See also : ndiff, eval, todisk