Thursday, October 23, 2025
HomeLanguagesEvaluate a 2D Laguerre series at points (x,y) using NumPy in Python

Evaluate a 2D Laguerre series at points (x,y) using NumPy in Python

In this article, we will discuss how to evaluate a 2D Laguerre series at points (x,y) using NumPy in Python.

Example

Input: [[[ 0  1  2]
  [ 3  4  5]
  [ 6  7  8]]

 [[ 9 10 11]
  [12 13 14]
  [15 16 17]]

 [[18 19 20]
  [21 22 23]
  [24 25 26]]]

Output: [[[1920.  522.]
  [ 414.  108.]]

 [[2020.  552.]
  [ 444.  117.]]

 [[2120.  582.]
  [ 474.  126.]]]

Explanation: Two dimensional Laguerre series.

NumPy.polynomial.laguerre.lagval2d method

To perform Laguerre differentiation, NumPy provides a function called laguerre.lagval2d which can be used to evaluate the cartesian product of the 2D Laguerre series. This function converts the parameters x and y to arrays only if they are tuples or a list and of the same shape, otherwise, it is left unchanged and, if it is not an array, it is treated as a scalar. If c has a dimension greater than 2 the remaining indices enumerate multiple sets of coefficients.

Syntax: laguerre.lagval2d(x,y, c)

Parameters:

  • x,y: Input array.
  • c: Array of coefficients ordered

Returns: Two dimensional Laguerre series at points in the Cartesian product of x and y.

Example 1:

In the first example. let us consider a 3D array c of size 27 and a series of [2,2],[2,2] to evaluate against the 2D array.

Python3




import numpy as np
from numpy.polynomial import laguerre
  
# co.efficient array
c = np.arange(27).reshape(3, 3, 3)
  
print(f'The co.efficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
  
# evaluating coeff array with a laguerre series
res = laguerre.lagval2d([2, 2], [2, 2], c)
  
# resultant array
print(f'Resultant series ---> {res}')


Output:

The co.efficient array is [[[ 0  1  2]
  [ 3  4  5]
  [ 6  7  8]]

 [[ 9 10 11]
  [12 13 14]
  [15 16 17]]

 [[18 19 20]
  [21 22 23]
  [24 25 26]]]
The shape of the array is (3, 3, 3)
The dimension of the array is 3D
The datatype of the array is int64
Resultant series ---> [[36. 36.]
 [37. 37.]
 [38. 38.]]

Example 2:

In the second example. let us consider a 2D array c of size 10  and a series of [2,2],[2,2] to evaluate against the 2D array.

Python3




import numpy as np
from numpy.polynomial import laguerre
  
# co.efficient array
c = np.array([[1,2,3,4,5],[45,56,65,55,55]])
  
print(f'The co.efficient array is {c}')
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
  
# evaluating coeff array with a laguerre series
res = laguerre.lagval2d([2, 2], [2, 2], c)
  
# resultant array
print(f'Resultant series ---> {res}')


Output:

The co.efficient array is [[ 1  2  3  4  5]
 [45 56 65 55 55]]
The shape of the array is (2, 5)
The dimension of the array is 2D
The datatype of the array is int64
Resultant series ---> [72.33333333 72.33333333]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS