Python | The numpy np.hermecompanion () method

NumPy | Python Methods and Functions

Using the np.hermecompanion() method, we can get the companion matrix of the hermiteE row using np.hermecompanion () .

Syntax: np.hermecompanion (series)
Return: Return the companion matrix.

Example # 1:
In this example we see that with np.hermecompanion () we can get the companion matrix from hermiteE row using this method.

# numpy and hermecompanion imports

import numpy as np

from numpy.polynomial .hermite_e import hermecompanion

 

  series = np.array ([ 6 , 7 , 8 , 9 , 10 ])

# using the np.hermecompanion () method

gfg = hermecompanion (series)

 

print (gfg )

Output:

[[0. 1. 0. -0.24494897]
[1. 0. 1.41421356 -0.2857738]
[0. 1.41421356 0. 1.27017059]
[0 . 0. 1.73205081 -0.9]]

Example # 2:

# numpy and hermecompanion imports

import numpy as np

from numpy.polynomial.hermite_e import hermecompanion

 

series = np.array ([ 1 , 2 , 3 , 4 , 5 ])

# using the np.hermecompanion () method

gfg = hermecompanion (series)

 

print (gfg)

Output:

[[0. 1. 0. -0.08164966]
[1. 0. 1.41421356 -0.16329932]
[0. 1.41421356 0. 1.38564065]
[0. 0. 1.73205081 -0.8]]





Get Solution for free from DataCamp guru