Evaluate a 2-D Laguerre series on the Cartesian product of x and y with 1d array of coefficient in Python

To evaluate a 2-D Laguerre series on the Cartesian product of x and y, use the polynomial.laguerre.laggrid2d() method in Python. The method returns the values of the two dimensional Laguerre series at points in the Cartesian product of x and y.

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 + y.shape. The 1st parameter, x and y, defines where the two dimensional series is evaluated at the points in the Cartesian product. 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.

The 2nd parameter, c, is an 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.

Syntax

numpy.polynomial.laguerre.laggrid2d(x, y, c)

Parameters

x, y: Array-like coordinates where the 2-D series is evaluated

c: Array of coefficients for the 2-D Laguerre series

Example

Let's create a simple example to evaluate a 2-D Laguerre series ?

import numpy as np
from numpy.polynomial import laguerre as L

# Create a 1d array of coefficients
c = np.array([3, 5])

# Display the array
print("Our Array...")
print(c)

# Check the Dimensions
print("\nDimensions of our Array...")
print(c.ndim)

# Get the Datatype
print("\nDatatype of our Array object...")
print(c.dtype)

# Get the Shape
print("\nShape of our Array object...")
print(c.shape)

# Evaluate 2-D Laguerre series on Cartesian product
print("\nResult...")
print(L.laggrid2d([1,2],[1,2], c))
Our Array...
[3 5]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(2,)

Result...
[3. 5.]

How It Works

The laggrid2d() function evaluates the 2-D Laguerre series at each point in the Cartesian product of the input arrays. Since we provided a 1-D coefficient array [3, 5], it's treated as a 2-D array with shape (2, 1) representing the polynomial 3*L?(x) + 5*L?(x).

Advanced Example with 2-D Coefficients

Here's an example using a proper 2-D coefficient array ?

import numpy as np
from numpy.polynomial import laguerre as L

# Create a 2D array of coefficients
c = np.array([[1, 2], [3, 4]])

print("2D Coefficient Array:")
print(c)

# Evaluate on Cartesian product
x_points = [0, 1]
y_points = [0, 1]
result = L.laggrid2d(x_points, y_points, c)

print("\nResult shape:", result.shape)
print("Result values:")
print(result)
2D Coefficient Array:
[[1 2]
 [3 4]]

Result shape: (2, 2)
Result values:
[[10.  7.]
 [ 7.  4.]]

Conclusion

The laggrid2d() method efficiently evaluates 2-D Laguerre series on Cartesian products. Use 1-D coefficient arrays for simple cases or 2-D arrays for full multi-dimensional polynomial evaluation.

Updated on: 2026-03-26T20:20:16+05:30

200 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements