numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
roots(p)
note

This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in :None:None:`numpy.polynomial` is preferred. A summary of the differences can be found in the :None:doc:`transition guide </reference/routines.polynomials>`.

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]

Notes

The algorithm relies on computing the eigenvalues of the companion matrix .

Parameters

p : array_like

Rank-1 array of polynomial coefficients.

Raises

ValueError

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

Returns

out : ndarray

An array containing the roots of the polynomial.

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

See Also

poly

Find the coefficients of a polynomial with a given sequence of roots.

poly1d

A one-dimensional polynomial class.

polyfit

Least squares polynomial fit.

polyval

Compute polynomial values.

Examples

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

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.polynomial.hermite.hermfromroots numpy.polynomial.polynomial.polyfromroots numpy.polynomial.chebyshev.chebfromroots numpy.polynomial.hermite_e.hermefromroots numpy.poly numpy.polynomial.legendre.legfromroots numpy.polynomial.laguerre.lagfromroots

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/lib/polynomial.py#171
type: <class 'function'>
Commit: