Evaluate a 2D Laguerre series at points (x,y) with 1D array of coefficient in Python

To evaluate a 2D Laguerre series at points (x,y), use the polynomial.laguerre.lagval2d() method in Python NumPy. The method returns the values of the two-dimensional polynomial at points formed with pairs of corresponding values from x and y.

The 1st parameter is x, y. 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.

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.lagval2d(x, y, c)

Parameters

  • x, y: Array-like coordinates where the series is evaluated
  • c: Array of coefficients arranged so that c[i,j] contains the coefficient of the term of multi-degree i,j

Example

Let's create a simple example to evaluate a 2D 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)

# To evaluate a 2D Laguerre series at points (x,y)
print("\nResult...")
print(L.lagval2d([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.]

Example with 2D Coefficient Array

Here's an example using a 2D coefficient array for a more complex polynomial ?

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("Coefficient array:")
print(c)

# Evaluate at specific points
x = [0, 1]
y = [0, 1]
result = L.lagval2d(x, y, c)

print("\nEvaluating at points (0,0) and (1,1):")
print(result)
Coefficient array:
[[1 2]
 [3 4]]

Evaluating at points (0,0) and (1,1):
[1. 4.]

Key Points

  • The function evaluates a 2D Laguerre series at given coordinate pairs
  • Input arrays x and y must have the same shape
  • The coefficient array c determines the polynomial structure
  • Returns an array of evaluated values at the specified points

Conclusion

The lagval2d() function provides an efficient way to evaluate 2D Laguerre series at multiple points simultaneously. It's particularly useful for mathematical computations involving orthogonal polynomials in two dimensions.

Updated on: 2026-03-26T20:49:39+05:30

255 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements