[Numpy-discussion] problems with numdifftools

Pauli Virtanen pav@iki...
Tue Oct 26 17:59:43 CDT 2010


Tue, 26 Oct 2010 14:24:39 -0700, Nicolai Heitz wrote:
> >  http://mail.scipy.org/mailman/listinfo/scipy-user
>
> I contacted them already but they didn't responded so far and I was
> forwarded to that list which was supposed to be more appropriated.

I think you are thinking here about some other list -- scipy-user
is the correct place for this discussion (and I don't remember seeing
your mail there).

[clip]
> 1) Can I make it run/fix it, so that it is also going to work for the SI
> scaling?

Based on a brief look, it seems that uniform scaling will not help you,
as you have two very different length scales in the problem,

	1/sqrt(m w^2) >> C

If you go to CM+relative coordinates you might be able to scale them 
separately, but that's fiddly and might not work for larger N.

In your problem, things go wrong when the ratio between the 
length scales approaches 1e-15 which happens to be the machine epsilon. 
This implies that the algorithm runs into some problems caused by the 
finite precision of floating-point numbers.

What exactly goes wrong and how to fix it, no idea --- I didn't look into 
how Numdifftools is implemented.

> 2) How can I be sure that increasing the number of ions or adding a
> somehow more complicated term to the potential energy is not causing the
> same problems even in natural units?
>
> 3) In which range is numdifftools working properly.

That depends on the algorithm and the problem. Personally, I wouldn't 
trust numerical differentiation if the problem has significantly 
different length scales, it is important to capture all of them 
accurately, and it is not clear how to scale them to the same size.
Writing ND software that works as expected all the time is probably
not possible even in theory.

Numerical differentiation is not the only game in the town. I'd look 
into automatic differentiation (AD) -- there are libraries available
for Python also for that, and it is numerically stable.

E.g.

http://en.wikipedia.org/wiki/Automatic_differentiation#Software

has a list of Python libraries. I don't know which of them would be
the best ones, though.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list