h(j)is 0, partials with respect to
x(j)are not approximated and 0 is returned in the corresponding column of the Jacobian.
A matrix function
J(x)is the Jacobian of a column vector function
J(x)is the partial of the
ith element of
f(x)with respect to the
jth element of
Given a real or double precision vector with the same dimension as x, the function f returns a real, double-precision, or complex column vector. The return value of
cendiffhas the type that results from coercion between the type of x, h and
f(x). It has the same number of rows as
f(x)and its column dimension is equal to the length of x.
cendiffand fordiff can be used to approximate derivatives for an optimization or zero-finding algorithm. The
cendifffunction is more accurate, but it requires more function evaluations.
function f(x) begin
x = 1.
h = .1
cendiff(function f, x, h)