Home »
Python »
Python Programs
numpy.polyval() Method with Example
Python | numpy.polyval(): Learn about the numpy.polyval() method, its usages and example.
Submitted by Pranit Sharma, on February 27, 2023
NumPy is an abbreviated form of Numerical Python. It is used for different types of scientific operations in python. Numpy is a vast library in python which is used for almost every kind of scientific or mathematical operation. It is itself an array which is a collection of various methods and functions for processing the arrays.
numpy.polyval() Method
A mathematical expression generally composed of more than one variable where the degree of the variable is usually a whole number is said to be a polynomial.
It takes an array like input p which is the polynomial coefficient. It takes another array like parameter x which can be a number or an array of numbers at which to evaluate the p. If p is of length N, the polyval() method returns the values in terms of p, x, and N.
Syntax:
numpy.polyval(p, x)
Parameter(s):
- p: polynomial coefficients
- x: specific point/points at which to evaluate p.
Let us understand with the help of an example,
Python code to demonstrate the example of numpy.polyval() method
import numpy as np
# Using numpy.polyval
res = np.polyval([3,0,1], 5)
# Display result
print("Result:\n",res)
Output:
Python NumPy Programs »