help-octave
[Top][All Lists]

## numerical differentiation function

 From: etienne grossmann Subject: numerical differentiation function Date: Tue, 21 Mar 2000 16:00:30 +0000 (WET)

```
Hello,

this is just to say that I added a numerical differentiation
function to the archive of 'Miscellaneous' functions, at

http://anonimo.isr.ist.utl.pt:8080/~etienne/octave/

Cheers,

Etienne

The help text goes like this : (comments, suggestions etc are welcome)

======================================================================

df = ndiff( func [, options], argument(s) )

Numerical differentiation of 'func'.

By default, differentiation is with respect to the first argument
found after the eventual options.

If this variable (call it 'x') is of size RxC, and the output 'y' of
'func' is SxD, then 'df' will be (S*D)x(R*C).

df(i,j) = dy(i)/dx(j)

OPTIONS :
---------
"dx"    , small_value     : value of the small perturbation in 'x'.
Default = 1e-6

"varnum", integer         : Number, in argument list, of the
differentiation variable.   Default = 1

"rstack"  : allow stacking of arguments in rows. This means that

[ func(x1) ; func(x2) ] == func( [ x1 ; x2 ] )

(for differentiation of a one-arg function). When this
option is passed, a 'func' is called once only.

"cstack"  : allow stacking of arguments in columns. This means that

[ func(x1) , func(x2) ] == func( [ x1 , x2 ] )

(for differentiation of a one-arg function). When this
option is passed, a 'func' is called once only.

"assym:   : Perform calculation using an assymetric finite difference
scheme rather than the symmetric scheme. With this
option, 'func' is evaluated at R*C+1 points rather than
the 2*R*C that are necessary for the symmetric scheme.
Beware that error is then linear in the value of 'dx'

EXAMPLES :
----------
function y = foo(x,y,z) ... end

df = ndiff("foo","varnum",2,x0,y0,z0)
## Returns an approximation of the differential of 'foo' wrt. 'y', at
## (x0,y0,z0).

df = ndiff("foo",x0,y0,z0)
## Returns an approximation of the differential of 'foo' wrt. 'x', at
## (x0,y0,z0).

-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------

```