|See Also||cendiff , coldiff , testder|
f(x)returns a column vector with the same type as x, x is a real or double-precision column vector specifying the point at which to approximate the Jacobian of f, and h is a column vector, with the same type and dimension as x, that specifies the step size for approximating partials of f.
A matrix valued function
J(x)is the Jacobian of
f(x)if the (i,j)-th element of
J(x)is the partial of the i-th element of
f(x)with respect to the j-th element of
x. The return value of
fordiffhas the same type as x, the same number of rows as
f(x), and the same number of columns as x has rows.
h(j)is 0, partials with respect to
x(j)are not approximated, and 0 is returned in the corresponding column of the return value.
fordiffand cendiff can be used to approximate derivatives for both optimization and zero-finding algorithms. The
cendifffunction is more accurate, but it requires more function evaluations.
has the value 2 at
f(x) = x
x = 1. This example approximates this derivative using a forward difference with a .01 step size.
If you enter
O-Matrix will respond
function f(x) begin
x = 1.
h = .01
print fordiff(function f, x, h)