numpy.polyval() Method with Example

Python | numpy.polyval(): Learn about the numpy.polyval() method, its usages and example. By Pranit Sharma Last updated : December 24, 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.

Python 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.

Syntax

numpy.polyval(p, x)

Parameter(s)

  • p: polynomial coefficients
  • x: specific point/points at which to evaluate p.

Return Value

The polyval() method returns the values in terms of p, x, and N.

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

Example: numpy.polyval() Method with Example

Python NumPy Programs »


Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.