numpy.roots

numpy.roots(p)

Return the roots of a polynomial with coefficients given in p.

The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is described by p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]

Parameters:

p : array_like of shape(M,)

Rank-1 array of polynomial co-efficients.

Returns:

out : ndarray

An array containing the complex roots of the polynomial.

Raises:

ValueError: :

When p cannot be converted to a rank-1 array.

Examples

>>> coeff = [3.2, 2, 1]
>>> print np.roots(coeff)
[-0.3125+0.46351241j -0.3125-0.46351241j]

Previous topic

numpy.poly

Next topic

numpy.polyfit

This Page

Quick search