Open In App

Divide one Hermite series by another in Python using NumPy

Last Updated : 25 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to divide one Hermite series by another in Python using NumPy.

The numpy hermdiv() method helps us divide one Hermite series by another. The quotient and remainder of two Hermite series, c1 / c2, are returned. The arguments are a series of coefficients from lowest to highest order “term,” for example, [1,4,3] stands for P 0 + 4*P 1 + 3*P 2.

Syntax: numpy.polynomial.hermite.hermdiv(c1, c2)

parameters:

  • c1, c2: array like objects. Hermite series coefficients are arranged from low to high in a 1-D array.

Return: quotient, remainder: ndarrays. The quotient and remainder are represented using Hermite series coefficients.

Example 1:

In this example,  we created two arrays of numbers that represent coefficients using the np.array() method. coefficients should go from low to high The shape of the array is defined by the .shape attribute and the dimension of the array is defined by .ndim, the datatype of the array is returned by .dtype attribute. The hermite.hermdiv() method is used to divide two Hermite series and the result is returned. two arrays are returned. first the quotient array then the remainder array.

Python3




# import package
import numpy as np
 
# Creating arrays of coefficients
array = np.array([1, 5, 7])
array2 = np.array([2, 3, 5])
print(array)
print(array2)
 
# shape of the array is
print("Shape of the array1 is : ",
      array.shape)
print("Shape of the array2 is : ",
      array2.shape)
 
# dimension of the array
print("The dimension of the array1 is : ",
      array.ndim)
print("The dimension of the array2 is : ",
      array2.ndim)
 
# Datatype of the array
print("Datatype of our Array is : ",
      array.dtype)
print("Datatype of our Array2 is : ",
      array2.dtype)
 
# dividing two hermite series
print("Division of two hermite series : ",
      np.polynomial.hermite.hermdiv(array,
                                    array2))


Output:

[1 5 7]

[2 3 5]

Shape of the array1 is :  (3,)

Shape of the array2 is :  (3,)

The dimension of the array1 is :  1

The dimension of the array2 is :  1

Datatype of our Array is :  int64

Datatype of our Array2 is :  int64

Division of two hermite series :  (array([1.4]), array([-1.8,  0.8]))

Example 2:

In this example, we give the same arrays as coefficients, as the anticipated quotient is 1 and the remainder is 0. 

Python3




# import package
import numpy as np
 
# Creating arrays of coefficients
array = np.array([1, 5, 7])
array2 = np.array([2, 3, 5])
print(array)
print(array2)
 
# shape of the array is
print("Shape of the array1 is : ",
      array.shape)
print("Shape of the array2 is : ",
      array2.shape)
 
# dimension of the array
print("The dimension of the array1 is : ",
      array.ndim)
print("The dimension of the array2 is : ",
      array2.ndim)
 
# Datatype of the array
print("Datatype of our Array is : ",
      array.dtype)
print("Datatype of our Array2 is : ",
      array2.dtype)
 
# dividing two hermite series
print("Division of two hermite series : ",
      np.polynomial.hermite.hermdiv(array,
                                    array2))


Output:

[1 2 3]

[1 2 3]

Shape of the array1 is :  (3,)

Shape of the array2 is :  (3,)

The dimension of the array1 is :  1

The dimension of the array2 is :  1

Datatype of our Array is :  int64

Datatype of our Array2 is :  int64

Division of two hermite series :  (array([1.]), array([0.]))



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads