# [SciPy-user] Interpolation polynomials

Neilen Marais nmarais@sun.ac...
Wed Aug 22 07:50:51 CDT 2007

```Hi

On Tue, 21 Aug 2007 15:05:39 +0200, Matthieu Brucher wrote:

> Hi,
>
> You can can create p+1 polynomials with the poly() function, and then scale
> them by evaluating each of them at the remaining point.

I'm generating them like this at the moment:

def gen_lagrange_polys(points):
def make_poly(int_pt, zero_pts):
return N.poly1d(N.poly(zero_pts)/N.multiply.reduce(
[int_pt - p for p in zero_pts]))
return [make_poly(pi, [pz for pz in points if pz != pi]) for pi in points]

This gives the correct scaling, which means N.poly is exactly equivalent to
the product of (x - Zi) where Zi are the desired zeros. The problem I have
is that because the polynomials are represented i.t.o. monomial
coefficients, they don't evaluate to exactly zero at Zi which is quite
important for what I want to do.

Does scipy/numpy have an alternate
polynomial representation based on the product of zeros rather than
monomial coefficients? If not, is there a better way to do this than
generating code to do this?

Thanks
Neilen

> Matthieu

```