numpy.polynomial.polynomial.polyval

numpy.polynomial.polynomial.polyval(x, cs)

Evaluate a polynomial.

If cs is of length n, this function returns :

p(x) = cs[0] + cs[1]*x + ... + cs[n-1]*x**(n-1)

If x is a sequence or array then p(x) will have the same shape as x. If r is a ring_like object that supports multiplication and addition by the values in cs, then an object of the same type is returned.

Parameters :

x : array_like, ring_like

If x is a list or tuple, it is converted to an ndarray. Otherwise it must support addition and multiplication with itself and the elements of cs.

cs : array_like

1-d array of Chebyshev coefficients ordered from low to high.

Returns :

values : ndarray

The return array has the same shape as x.

See also

polyfit

Notes

The evaluation uses Horner’s method.

Previous topic

numpy.polynomial.polynomial.Polynomial.truncate

This Page