Contents | Previous | Next | Subchapters |

Syntax |
`testder(function ` fval`, ` x0`, ` h`)` |

See Also | testgrad , testhess |

Given a routine

*f*(*x*)

,
`testder`

compares this calculation
with a central difference approximation.
The results of the comparison are printed in the command window.
The column vector *x*

at which to check the calculation of the derivative.
The column vector *x*

when
computing the central difference approximations to the
derivative of *f*(*x*)

.

`(`

`, `

`)`

`(`

`, `

`, `

`)`

The column vector *f*(*x*)

.
The input value of *f*(*x*1)

.
If

*d* *f* (*x*) |

*i* |

*dfout* = -------- |

*i*,*j* *d* *x* | *x* = *x*1

*j*

For each component of *x*

,
the partials returned by The following program checks the derivative calculation for the function

*f*(*x*)

where

/ *x* \ *d* *f*(*x*) | / 1 \

*f*(*x*) = | | , ------ | = | |

\ *x*^2 / *d* *x* |*x* = 1 \ 2 /

```
```

clear

function fval(x1, fout, dfout) begin

fout = {x1, x1^2}

if arg(0) == 3 then ...

dfout = {1, 2 * x1}

end

x0 = 1.

h = .001

testder(function fval, x0, h)