Open In App

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

Last Updated : 11 May, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will Evaluate a 2D Laguerre series at points (x,y) with a 1D array of coefficient 

Laguerre.lagval2d method

In Python, laguerre.lagval2d() is used to evaluate a 2D Laguerre series at points (x,y). where coefficient_array is the input NumPy 1D array with coefficients and points referred to as x and y. The first parameter can be a list of points so we have to provide two lists such that each list has an x-point and y-point. The second parameter is a NumPy array of coefficients ordered such that it is of 3 Dimensions.

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

Parameters:

  • x,y: array_like, compatible objects
  • c: Array of coefficients.

Return: The values of the two dimensional polynomial at points

Example 1:

In this example, we are creating a NumPy array with 5 coefficients to evaluate Laguerre Series at points [3,4],[1,2].

Python3




# import numpy module
import numpy
 
# import laguerre
from numpy.polynomial import laguerre
 
# Create 1d array of 5 elements
coefficient_array = numpy.array([45, 67, 54, 53, 15])
 
# Display
print(coefficient_array)
 
# display the Dimensions
print(coefficient_array.ndim)
 
# display Shape
print(coefficient_array.shape)
 
# Evaluate a 2D Laguerre series at points
# (x,y) - [3,4],[1,2]
print(laguerre.lagval2d([3, 4], [1, 2], coefficient_array))


Output:

[45 67 54 53 15]
1
(5,)
[-42.375      -79.04166667]

Example 2:

In this example, we are creating a NumPy array with 6 coefficients and evaluating Laguerre Series at points [1,4],[1,2].

Python3




# import numpy module
import numpy
 
# import laguerre
from numpy.polynomial import laguerre
 
# Create 1d array of 6 elements
coefficient_array = numpy.array([45,67,54,53,67, 15])
 
# Display
print(coefficient_array)
 
# display the Dimensions
print(coefficient_array.ndim)
 
# display Shape
print(coefficient_array.shape)
 
# Evaluate a 2D Laguerre series at points
# (x,y) - [1,4],[1,2]
print(laguerre.lagval2d([1,4],[1,2],coefficient_array))


Output:

[45 67 54 53 67 15]
1
(6,)
[ -66.20833333 -141.875]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads