Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polyval for multiple variable

Tags:

python

numpy

I'm looking for a function to calculate the value of a polynomial with multiple variables. For 2d polynomials, I use numpy.polyval, I have values of coefficients as a list and value for x.

I wonder if there is a similar function for x, y, z space so that my input was values of coefficients and value for x, y.

like image 635
MarkAlanFrank Avatar asked Dec 06 '25 06:12

MarkAlanFrank


1 Answers

Are you looking for this?

link

Evaluate a 2-D polynomial at points (x, y).

This function returns the value

p(x,y) = \sum_{i,j} c_{i,j} * x^i * y^j

The parameters x and y are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the same shape after conversion. In either case, either x and y or their elements must support multiplication and addition both with themselves and with the elements of c.

If c has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape.

Parameters:

x, y : array_like, compatible objects

The two dimensional series is evaluated at the points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and, if it isn’t an ndarray, it is treated as a scalar.

c : array_like

Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in c[i,j]. If c has dimension greater than two the remaining indices enumerate multiple sets of coefficients.

Returns:

values : ndarray, compatible object The values of the two dimensional polynomial at points formed with pairs of corresponding values from x and y.

like image 94
Istvan Avatar answered Dec 08 '25 18:12

Istvan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!