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