On this page
numpy.roots
numpy.roots(p)[source]- 
    
Return the roots of a polynomial with coefficients given in p.
Note
This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in
numpy.polynomialis preferred. A summary of the differences can be found in the transition guide.The values in the rank-1 array
pare coefficients of a polynomial. If the length ofpis n+1 then the polynomial is described by:p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]- Parameters
 - 
      
parray_like- 
        
Rank-1 array of polynomial coefficients.
 
 - Returns
 - 
      
outndarray- 
        
An array containing the roots of the polynomial.
 
 - Raises
 - 
      
- ValueError
 - 
        
When
pcannot be converted to a rank-1 array. 
 
See also
Notes
The algorithm relies on computing the eigenvalues of the companion matrix [1].
References
1- 
      
R. A. Horn & C. R. Johnson, Matrix Analysis. Cambridge, UK: Cambridge University Press, 1999, pp. 146-7.
 
Examples
>>> coeff = [3.2, 2, 1] >>> np.roots(coeff) array([-0.3125+0.46351241j, -0.3125-0.46351241j]) 
© 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.20/reference/generated/numpy.roots.html