numpy.polynomial.polynomial.Polynomial#

class numpy.polynomial.polynomial.Polynomial(coef, domain=None, window=None, symbol='x')[source]#

A power series class.

The Polynomial class provides the standard Python numerical methods ‘+’, ‘-’, ‘*’, ‘//’, ‘%’, ‘divmod’, ‘**’, and ‘()’ as well as the attributes and methods listed below.

Parameters:
coefarray_like

Polynomial coefficients in order of increasing degree, i.e., (1, 2, 3) gives 1 + 2*x + 3*x**2 when domain and window are equal, which is the default. Otherwise, the coefficients are with respect to the variable obtained by mapping x from domain to window. p.convert() returns an equivalent series with the default domain and window, whose coefficients are with respect to x. Note that the conversion generally loses precision.

domain(2,) array_like, optional

Domain to use. The interval [domain[0], domain[1]] is mapped to the interval [window[0], window[1]] by shifting and scaling. The default value is [-1., 1.].

window(2,) array_like, optional

Window, see domain for its use. The default value is [-1., 1.].

symbolstr, optional

Symbol used to represent the independent variable in string representations of the polynomial expression, e.g. for printing. The symbol must be a valid Python identifier. Default value is ‘x’.

Added in version 1.24.

Attributes:
basis_name
symbol

Methods

__call__(arg)

Call self as a function.

basis(deg[, domain, window, symbol])

Series basis polynomial of degree deg.

cast(series[, domain, window])

Convert series to series of this class.

convert([domain, kind, window])

Convert series to a different kind and/or domain and/or window.

copy()

Return a copy.

cutdeg(deg)

Truncate series to the given degree.

degree()

The degree of the series.

deriv([m])

Differentiate.

fit(x, y, deg[, domain, rcond, full, w, ...])

Least squares fit to data.

fromroots(roots[, domain, window, symbol])

Return series instance that has the specified roots.

has_samecoef(other)

Check if coefficients match.

has_samedomain(other)

Check if domains match.

has_sametype(other)

Check if types match.

has_samewindow(other)

Check if windows match.

identity([domain, window, symbol])

Identity function.

integ([m, k, lbnd])

Integrate.

linspace([n, domain])

Return x, y values at equally spaced points in domain.

mapparms()

Return the mapping parameters.

roots()

Return the roots of the series polynomial.

trim([tol])

Remove trailing coefficients

truncate(size)

Truncate series to length size.