bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / polynomial / polynomial / polyvalfromroots
function
numpy.polynomial.polynomial:polyvalfromroots
source: build-install/usr/lib/python3.14/site-packages/numpy/polynomial/polynomial.py :761
Signature
def polyvalfromroots ( x , r , tensor = True ) Summary
Evaluate a polynomial specified by its roots at points x.
Extended Summary
If r is of length N, this function returns the value
The parameter x is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either case, either x or its elements must support multiplication and addition both with themselves and with the elements of r.
If r is a 1-D array, then p(x) will have the same shape as x. If r is multidimensional, then the shape of the result depends on the value of tensor. If tensor is True the shape will be r.shape[1:] + x.shape; that is, each polynomial is evaluated at every value of x. If tensor is False, the shape will be r.shape[1:]; that is, each polynomial is evaluated only for the corresponding broadcast value of x. Note that scalars have shape (,).
Parameters
x: array_like, compatible objectIf
xis a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case,xor its elements must support addition and multiplication with with themselves and with the elements ofr.r: array_likeArray of roots. If
ris multidimensional the first index is the root index, while the remaining indices enumerate multiple polynomials. For instance, in the two dimensional case the roots of each polynomial may be thought of as stored in the columns ofr.tensor: boolean, optionalIf True, the shape of the roots array is extended with ones on the right, one for each dimension of
x. Scalars have dimension 0 for this action. The result is that every column of coefficients inris evaluated for every element ofx. If False,xis broadcast over the columns ofrfor the evaluation. This keyword is useful whenris multidimensional. The default value is True.
Returns
values: ndarray, compatible objectThe shape of the returned array is described above.
Examples
from numpy.polynomial.polynomial import polyvalfromroots
✓polyvalfromroots(1, [1, 2, 3])
✗a = np.arange(4).reshape(2, 2) a✓
polyvalfromroots(a, [-1, 0, 1])
✗r = np.arange(-2, 2).reshape(2,2) # multidimensional coefficients r # each column of r defines one polynomial b = [-2, 1]✓
polyvalfromroots(b, r, tensor=True)
✗polyvalfromroots(b, r, tensor=False)
✓See also
Aliases
-
numpy.polynomial.polynomial.polyvalfromroots