MCPcopy Create free account
hub / github.com/numpy/numpy / poly

Function poly

numpy/lib/polynomial.py:46–165  ·  view source on GitHub ↗

Find the coefficients of a polynomial with the given sequence of roots. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :d

(seq_of_zeros)

Source from the content-addressed store, hash-verified

44
45@array_function_dispatch(_poly_dispatcher)
46def poly(seq_of_zeros):
47 """
48 Find the coefficients of a polynomial with the given sequence of roots.
49
50 .. note::
51 This forms part of the old polynomial API. Since version 1.4, the
52 new polynomial API defined in `numpy.polynomial` is preferred.
53 A summary of the differences can be found in the
54 :doc:`transition guide </reference/routines.polynomials>`.
55
56 Returns the coefficients of the polynomial whose leading coefficient
57 is one for the given sequence of zeros (multiple roots must be included
58 in the sequence as many times as their multiplicity; see Examples).
59 A square matrix (or array, which will be treated as a matrix) can also
60 be given, in which case the coefficients of the characteristic polynomial
61 of the matrix are returned.
62
63 Parameters
64 ----------
65 seq_of_zeros : array_like, shape (N,) or (N, N)
66 A sequence of polynomial roots, or a square array or matrix object.
67
68 Returns
69 -------
70 c : ndarray
71 1D array of polynomial coefficients from highest to lowest degree:
72
73 ``c[0] * x**(N) + c[1] * x**(N-1) + ... + c[N-1] * x + c[N]``
74 where c[0] always equals 1.
75
76 Raises
77 ------
78 ValueError
79 If input is the wrong shape (the input must be a 1-D or square
80 2-D array).
81
82 See Also
83 --------
84 polyval : Compute polynomial values.
85 roots : Return the roots of a polynomial.
86 polyfit : Least squares polynomial fit.
87 poly1d : A one-dimensional polynomial class.
88
89 Notes
90 -----
91 Specifying the roots of a polynomial still leaves one degree of
92 freedom, typically represented by an undetermined leading
93 coefficient. [1]_ In the case of this function, that coefficient -
94 the first one in the returned array - is always taken as one. (If
95 for some reason you have one other point, the only automatic way
96 presently to leverage that information is to use ``polyfit``.)
97
98 The characteristic polynomial, :math:`p_a(t)`, of an `n`-by-`n`
99 matrix **A** is given by
100
101 :math:`p_a(t) = \\mathrm{det}(t\\, \\mathbf{I} - \\mathbf{A})`,
102
103 where **I** is the `n`-by-`n` identity matrix. [2]_

Callers 2

test_symbolFunction · 0.90
__init__Method · 0.85

Calls 10

atleast_1dFunction · 0.90
eigvalsFunction · 0.90
mintypecodeFunction · 0.90
onesFunction · 0.90
arrayFunction · 0.90
astypeMethod · 0.80
sortMethod · 0.80
conjugateMethod · 0.80
allMethod · 0.45
copyMethod · 0.45

Tested by 1

test_symbolFunction · 0.72