Evaluate a 3D Laguerre series at points (x,y,z) in Python

To evaluate a 3D Laguerre series at points (x,y,z), use the numpy.polynomial.laguerre.lagval3d() method. This function computes the values of a multidimensional Laguerre polynomial at specified coordinate points.

Syntax

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

Parameters

x, y, z: Array-like coordinates where the series is evaluated. Must have the same shape. Lists or tuples are converted to ndarrays, scalars are treated as scalars.

c: Array of coefficients ordered so that the coefficient of term with multi-degree i,j,k is in c[i,j,k]. If c has fewer than 3 dimensions, ones are implicitly appended to make it 3D.

Example

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

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

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

print("Coefficient Array:")
print(c)
print(f"\nShape: {c.shape}")
print(f"Dimensions: {c.ndim}")
Coefficient Array:
[[[ 0  1  2  3  4  5]
  [ 6  7  8  9 10 11]]

 [[12 13 14 15 16 17]
  [18 19 20 21 22 23]]]

Shape: (2, 2, 6)
Dimensions: 3

Evaluating the 3D Laguerre Series

Now evaluate the series at points (1,1,1) and (2,2,2) ?

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

c = np.arange(24).reshape(2, 2, 6)

# Evaluate at points (1,1,1) and (2,2,2)
result = L.lagval3d([1, 2], [1, 2], [1, 2], c)

print("Result at points (1,1,1) and (2,2,2):")
print(result)
Result at points (1,1,1) and (2,2,2):
[-7.83333333  0.        ]

Single Point Evaluation

You can also evaluate at a single point ?

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

c = np.arange(8).reshape(2, 2, 2)

# Evaluate at single point (0.5, 0.5, 0.5)
result = L.lagval3d(0.5, 0.5, 0.5, c)

print("Coefficient array:")
print(c)
print(f"\nResult at point (0.5, 0.5, 0.5): {result}")
Coefficient array:
[[[0 1]
  [2 3]]

 [[4 5]
  [6 7]]]

Result at point (0.5, 0.5, 0.5): 2.4375

How It Works

The function evaluates the 3D Laguerre series using the formula where each coefficient c[i,j,k] is multiplied by the corresponding Laguerre basis polynomials L_i(x), L_j(y), and L_k(z). The result shape is c.shape[3:] + x.shape, meaning additional dimensions in the coefficient array are preserved.

Conclusion

Use lagval3d() to evaluate 3D Laguerre series at coordinate points. The function handles multiple evaluation points efficiently and preserves the structure of higher-dimensional coefficient arrays.

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

259 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements