polyvalfromroots(x, r, tensor=True)
If r
is of length :None:None:`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 :None:None:`p(x)`
will have the same shape as x
. If r
is multidimensional, then the shape of the result depends on the value of :None:None:`tensor`
. If :None:None:`tensor is ''True'`
the shape will be r.shape[1:] + x.shape; that is, each polynomial is evaluated at every value of x
. If :None:None:`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 (,).
If x
is a list or tuple, it is converted to an ndarray, otherwise it is left unchanged and treated as a scalar. In either case, x
or its elements must support addition and multiplication with with themselves and with the elements of r
.
Array of roots. If r
is 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 of r
.
If 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 in r
is evaluated for every element of x
. If False, x
is broadcast over the columns of r
for the evaluation. This keyword is useful when r
is multidimensional. The default value is True.
The shape of the returned array is described above.
Evaluate a polynomial specified by its roots at points x.
>>> from numpy.polynomial.polynomial import polyvalfromroots
... polyvalfromroots(1, [1,2,3]) 0.0
>>> a = np.arange(4).reshape(2,2)
... a array([[0, 1], [2, 3]])
>>> polyvalfromroots(a, [-1, 0, 1]) array([[-0., 0.], [ 6., 24.]])
>>> r = np.arange(-2, 2).reshape(2,2) # multidimensional coefficients
... r # each column of r defines one polynomial array([[-2, -1], [ 0, 1]])
>>> b = [-2, 1]
... polyvalfromroots(b, r, tensor=True) array([[-0., 3.], [ 3., 0.]])
>>> polyvalfromroots(b, r, tensor=False) array([-0., 0.])See :
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