Open In App

Add one Laguerre series to another in Python

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will be looking at the method to add one Laguerre series to another in Python.

The product of the exponential of a matrix by a vector is computed using Laguerre polynomials and a Filtered Conjugate Residual (FCR) framework. In Python, we take the Numpy library, and use the polynomial.laguerre.lagadd() method to combine two Laguerre series. The method returns an array that represents their sum’s Laguerre series.

Syntax : np.lagadd(c1, c2)
Parameters:

  • c1, c2 :[ array_like ] 1-D arrays of Laguerre series coefficients ordered from low to high.

Return : [ndarray] Array representing the Laguerre series of their sum.

Numpy.polynomial.Laguerre function includes a Laguerre class that incorporates the normal arithmetic operations, as well as a number of objects (mainly functions) helpful for dealing with the Laguerre series. The sum of two Laguerre series (series1 + series2) is returned. The arguments are ordered sequences of coefficients from lowest to highest order term, e.g., [1,2,3] represents the series P 0 + 2*P 1 + 3*P 2. 1-D arrays of Laguerre series coefficients arranged from low to high, parameters series1, series2array like.

The Laguerre series of their sum is returned as an out array Array. 

Example  #1 :

In this example, we are simply creating two series of 5 integers, and further, with the call of the np.lagadd() function passed with the series as the parameters, we are printing the lagadd series in python.

Python3




import numpy as np
import numpy.polynomial.laguerre as geeks
  
# Laguerre series coefficients
series1 = (10, 20, 30, 40, 50)
series2 = (1, 2, 3, 4, 5)
  
# using np.lagadd() method
result = geeks.lagadd(series1, series2)
  
# Resulting laguerre series
print(result)


Output:

[11. 22. 33. 44. 55.]

Example  #2 :

Under this example, we have created two series variables of 4 unique data point integer type , and further, with the call of the np.lagadd() function we are getting in the return of the function the lagadd series in python.

Python




import numpy as np
import numpy.polynomial.laguerre as geeks
  
# Laguerre series coefficients
series1 = (8, 7, 6, 5)
series2 = (2, 3, 4, 5)
  
# using np.lagadd() method
result = geeks.lagadd(series1, series2)
  
# Resulting laguerre series
print(result)


Output:

[10. 10. 10. 10.]


Last Updated : 21 Apr, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads