Python | The numpy np.hermcompanion () method



Using the np.hermcompanion() method, we can get the companion matrix from the Hermite series using np.hermcompanion () .

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

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

# numpy and hermcompanion imports

import numpy as np

from numpy. polynomial.hermite import hermcompanion

 

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

# using the np.hermcompanion () method

gfg = hermcompanion (series)

 

print (gfg)

Output:

[[0. 0.70710678 0. -0.04330127]
[0.70710678 0. 1. -0.07144345]
[0. 1. 0. 1.06144556]
[0. 0 . 1.22474487 -0.45]]

Example # 2:

# numpy and hermcompanion imports

import numpy as np

from numpy.polynomial.hermite import hermcompanion

 

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

# using the np.hermcompanion () method

gfg = herm companion (series)

 

print (gfg)

Output:

[[0. 0.70710678 0. -0.01443376]
[0.70710678 0. 1. -0.04082483]
[0. 1. 0. 1.10227038]
[0. 0. 1.22474487 -0.4]]