Polynomial functions

There are two interfaces for dealing with polynomials: a class-based interface, and a collection of functions to deal with a polynomials represented as a simple list of coefficients. This latter representation results from the is a one-to-one correspondence between a length-(n + 1) sequence of coefficients an = a[n] and an nth order polynomial:

Most of the functions below operate on and return a simple sequence of coefficients representing a polynomial. There is, however, a simple polynomial class that provides some utility for doing simple algebra on polynomials.

This construction returns an instance of a simple polynomial class. It can take either a list of coefficients on polynomial powers, or a sequence of roots (if r=1). The returned polynomial can be added, subtracted, multiplied, divided, and taken to integer powers, resulting in new polynomials.

.r roots of the polynomial .o order of the polynomial

.c polynomial coefficients as an array (also__array__() )

__call__(x) evaluate the polynomial at x (can be an array)

__getitem__(x) p[k] returns the coefficient on the kth power of x (backwards from indexing the coefficient array)

>>> p=poly1d( [2,5,7] ) >>> print p 2

poly (roots_or_matrix)

Return a sequence of coefficients representing a polynomial given the sequence of roots as an argument. Alternatively, if the argument is a 2-d array, then return the characteristic polynomial of the matrix.

roots (poly)

Return the roots of the polynomial represented by coefficients in poly polyint (poly, m=1, k=None)

Return an exact mth-order integral of the polynomial represented in poly. If k is None, then use 0 for the integrating constants. Otherwise, use the scalars in the sequence k as integrating constants. Also available as .integ (m=1,k=0) method of polyld objects.