numpoly.polynomial_from_roots

numpoly.polynomial_from_roots(seq_of_zeros: Sequence[int], dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None)numpoly.baseclass.ndpoly[source]

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

Returns the coefficients of the polynomial whose leading coefficient is one for the given sequence of zeros (multiple roots must be included in the sequence as many times as their multiplicity; see Examples). A square matrix (or array, which will be treated as a matrix) can also be given, in which case the coefficients of the characteristic polynomial of the matrix are returned.

Args:
seq_of_zeros:

A sequence of polynomial roots, or a square array or matrix object. Either shape (N,) or (N, N).

dtype:

Any object that can be interpreted as a numpy data type.

Return:

1-D polynomial which have seq_of_zeros as roots. Leading coefficient is always 1.

Raise:
ValueError:

If input is the wrong shape (the input must be a 1-D or square 2-D array).

Example:
>>> numpoly.polynomial_from_roots((0, 0, 0))
polynomial(q0**3)
>>> numpoly.polynomial_from_roots((-0.5, 0, 0.5))
polynomial(q0**3-0.25*q0)