Evaluate a 3-D Laguerre series on the Cartesian product of x, y and z in Python

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

Syntax

numpy.polynomial.laguerre.laggrid3d(x, y, z, c)

Parameters

The function takes the following parameters:

  • x, y, z: Arrays of coordinates where the series is evaluated. If a list or tuple, it's converted to ndarray. Scalars are treated as 0-D arrays.
  • c: Array of coefficients ordered so that coefficients for terms of degree i,j,k are contained in c[i,j,k]. If c has fewer than three dimensions, ones are implicitly appended to make it 3-D.

Example

Let's create a 3D coefficient array and evaluate the Laguerre series ?

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

# Create a 3D array of coefficients
c = np.arange(16).reshape(2,2,4)

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

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

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

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

# Evaluate 3-D Laguerre series on Cartesian product
print("\nResult...\n", L.laggrid3d([1,2], [1,2], [1,2], c))
Our Array...
 [[[ 0  1  2  3]
  [ 4  5  6  7]]

 [[ 8  9 10 11]
  [12 13 14 15]]]

Dimensions of our Array...
3

Datatype of our Array object...
int64

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

Result...
 [[[-3.         -4.        ]
  [ 0.66666667  5.33333333]]

 [[ 1.33333333 10.66666667]
  [ 0.          0.        ]]]

Understanding the Output

The result shape follows the pattern: x.shape + y.shape + z.shape. Since we used [1,2] for each coordinate (shape (2,)), the output has shape (2, 2, 2). Each element represents the Laguerre series value at the corresponding Cartesian product point.

Different Coordinate Arrays

You can use different arrays for x, y, and z coordinates ?

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

# Create coefficient array
c = np.ones((2, 2, 2))  # Simple 2x2x2 coefficient array

# Use different coordinate arrays
x = [0, 1]
y = [0]  
z = [1, 2, 3]

result = L.laggrid3d(x, y, z, c)
print("Result shape:", result.shape)
print("Result:\n", result)
Result shape: (2, 1, 3)
Result:
 [[[2. 2. 2.]]

 [[2. 2. 2.]]]

Conclusion

The laggrid3d() method efficiently evaluates 3-D Laguerre series on Cartesian products. The output dimensions depend on the input coordinate array shapes, making it flexible for various mathematical applications.

Updated on: 2026-03-26T20:35:52+05:30

210 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements