[SciPy-user] Polynomial interpolation

LB berthe.loic@gmail....
Sun Apr 20 03:00:40 CDT 2008

> It appears that scipy does not have a facility for using the Lagrange
> polynomial to interpolate data. (Or did I miss it?) I am well aware of
> the numerical difficulties this poses, but it (and its generalization,
> the Hermite polynomial) does prove useful on occasion. I have written
> prototype implementations of two algorithms for evaluating this
> polynomial, and I'd like comments before submitting them for inclusion
> in scipy.

In fact, I've seen that there was a lagrange function in

In [5]: from scipy import interpolate
In [6]: interpolate.lagrange?
Type:		function
Base Class:	<type 'function'>
String Form:	<function lagrange at 0xb582a1ec>
Namespace:	Interactive
File:		/usr/lib/python2.4/site-packages/scipy/interpolate/
Definition:	interpolate.lagrange(x, w)
    Return the Lagrange interpolating polynomial of the data-points

In scipy 0.6, this seems to be broken, because numpy's poly1d is not
imported at the top of
the interpolate module :

In [16]: scipy.__version__
Out[16]: '0.6.0'

In [17]: x = array([1, 4, 5, 7])
In [18]: y = array([0, 1, 2, 1.5])
In [19]: poly = interpolate.lagrange(x,y)
NameError                                 Traceback (most recent call

/usr/lib/python2.4/site-packages/scipy/interpolate/interpolate.py in
lagrange(x, w)
     28     """
     29     M = len(x)
---> 30     p = poly1d(0.0)
     31     for j in xrange(M):
     32         pt = poly1d(w[j])

NameError: global name 'poly1d' is not defined

This is related in #626.

I don't know why this function has been put aside and do not appears
in scipy.interpolate docstring.


More information about the SciPy-user mailing list