Contents | Previous | Next | Subchapters |

Syntax |
`fordiff(function ` f`, ` x`, ` h`)` |

See Also | cendiff , coldiff , testder |

Returns the forward difference approximation for the Jacobian of

*f*(*x*)

returns a column vector with the same type as

A matrix valued function *J*(*x*)

is the Jacobian of *f*(*x*)

if the *J*(*x*)

is the partial of the *f*(*x*)

with respect to the *x*

.
The return value of `fordiff`

has the same type as *f*(*x*)

,
and the same number of columns as

If *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.

The functions `fordiff`

and
cendiff
can be used to approximate derivatives for both
optimization and zero-finding algorithms.
The `cendiff`

function is more accurate,
but it requires more function evaluations.
The derivative of the function

2

*f*(*x*) = *x*

has the value 2 at *x* = 1

.
This example approximates this derivative using a forward difference
with a .01 step size.

If you enter
```
```

function f(x) begin

return x^2

end

x = 1.

h = .01

print fordiff(function f, x, h)

O-Matrix will respond
```
```

2.01