[SciPy-user] interpolate
Paul Barrett
barrett at stsci.edu
Fri Aug 1 09:17:10 EDT 2003
Nils Wagner wrote:
> Hi all,
>
> Let us consider a curve which is given by m points (x_1,y_1) ...
> (x_m,y_m).
> How can I find the first and second derivative of this curve in
> x_1,...,x_m ?
> A small example illustrating the solution to this task would be
> appreciated.
>
> Thanks in advance
>
> Nils
I'd suggest using Neville's algorithm, which allows you to fit an exact
polynomial of degree N-1 to a set of N points. Finding the first and
second derivatives should then be straight forward. Usually it isn't
necessary to fit all N points, but to take 2 (3) points on either side
of the region that you want to interpolate and then fit the 4 (6) points
using a 3rd (5th) order polynomial. I've attached a Python version of
the algorithm.
I learned about this algorithm a couple of years ago and have wondered
how I did with out for so long. This is real forgotten gem as far as
I'm concerned.
Cheers,
Paul
--
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Group
FAX: 410-338-4767 Baltimore, MD 21218
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: neville.py
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20030801/93406589/attachment.ksh>
More information about the SciPy-User
mailing list