Numerical derivatives of compiled functions

• To: mathgroup at smc.vnet.net
• Subject: [mg32845] Numerical derivatives of compiled functions
• From: Kyriakos Chourdakis <k.chourdakis at qmul.ac.uk>
• Date: Fri, 15 Feb 2002 02:49:45 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Dear all,

I have a compiled function and want to find the Hessian matrix numerically
at a specific point. The function ND[] does not work even in simple cases
like:

In:  cf = Compile[{x, y}, Module[{a = 3}, Print[x, " ", y]; a x^a y]]

Out: CompiledFunction[{x, y},Module[{a = 3}, Print[x, " ", y]; a x^a y],
-CompiledCode-]

In:  ND[cf[q, 4], q, 2]

CompiledFunction::"cfsa": "Argument q at position 1 should be a
machine-size real number.
q 4
Out: 144.

My guess is that ND[] tries to evaluate the function symbolically first. In
my problem I have the product/sum of over 10000 primitive functions, and
symbolic computations for all second-order derivs will take for ever.

When plotting is concerned, I suppose that the option Compiled does the
trick. How would that work with ND[]?

Cheers,

Kyriakos

_____+*"*+____+*"*+___+*"*+__+*"*+_

Kyriakos Chourdakis
Lecturer in Financial Economics

URL: http://www.qmw.ac.uk/~te9001
tel: (++44) (+20) 7882 5086
Dept of Economics
University of London, QM
London E1 4NS
U.K.

```

• Prev by Date: Re: How to color countours in a contour Plot?
• Next by Date: Re: Nonatomic expression ? in Append command
• Previous by thread: Heat conduction equation
• Next by thread: Re: Numerical derivatives of compiled functions