numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
polyval(p, x)
note

This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in :None:None:`numpy.polynomial` is preferred. A summary of the differences can be found in the :None:doc:`transition guide </reference/routines.polynomials>`.

If p is of length N, this function returns the value:

p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1]

If x is a sequence, then p(x) is returned for each element of x . If x is another polynomial then the composite polynomial p(x(t)) is returned.

Notes

Horner's scheme is used to evaluate the polynomial. Even so, for polynomials of high degree the values may be inaccurate due to rounding errors. Use carefully.

If x is a subtype of ndarray the return value will be of the same type.

Parameters

p : array_like or poly1d object

1D array of polynomial coefficients (including coefficients equal to zero) from highest degree to the constant term, or an instance of poly1d.

x : array_like or poly1d object

A number, an array of numbers, or an instance of poly1d, at which to evaluate p.

Returns

values : ndarray or poly1d

If x is a poly1d instance, the result is the composition of the two polynomials, i.e., x is "substituted" in p and the simplified result is returned. In addition, the type of x - array_like or poly1d - governs the type of the output: x array_like => :None:None:`values` array_like, x a poly1d object => :None:None:`values` is also.

Evaluate a polynomial at specific values.

See Also

poly1d

A polynomial class.

Examples

>>> np.polyval([3,0,1], 5)  # 3 * 5**2 + 0 * 5**1 + 1
76
>>> np.polyval([3,0,1], np.poly1d(5))
poly1d([76])
>>> np.polyval(np.poly1d([3,0,1]), 5)
76
>>> np.polyval(np.poly1d([3,0,1]), np.poly1d(5))
poly1d([76])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.roots numpy.polynomial.polynomial.polyfit numpy.polynomial.polynomial.polygrid2d numpy.ma.extras.polyfit numpy.poly numpy.polynomial.polynomial.polyvalfromroots numpy.polyfit numpy.polymul numpy.polynomial.polynomial.polygrid3d numpy.vectorize numpy.polynomial.polynomial.polyval2d numpy.polydiv numpy.polyadd numpy.polynomial.polynomial.polyval3d numpy.polysub

Local connectivity graph

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


GitHub : /numpy/lib/polynomial.py#704
type: <class 'function'>
Commit: