MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Numerical derivatives of compiled functions

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

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

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],

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[]?




Kyriakos Chourdakis
Lecturer in Financial Economics

tel: (++44) (+20) 7882 5086
Dept of Economics
University of London, QM
London E1 4NS

  • 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