Return the Scaled Companion Matrix of a 1-D Array of Chebyshev Series Coefficients using NumPy in Python

chebyshev.chebcompanion() Method:

chebyshev. chebcompanion() method is used to provide the eigenvalues that estimate the unscaled case and for the basis polynomials. Always, we can say that if we use the numpy.linalg.eigvalsh to obtain the eigenvalues, then the eigenvalues are destined to be real. In this method, we take the input as a coefficient array as a parameter, and the input array should be a 1-D array of the Chebyshev series coefficient ordered, and its order should be from low degree to high degree. This will return the Scaled companion matrix of dimensions.

Syntax for chebyshev.chebcompanion() Method:

Parameters:

  • Coefficient_array: In the chebyshev.chebcompanion() method will take the parameter as the coefficient array, and the array will be a 1-D array of Chebyshev series coefficient ordered, and its order should be from low degree to high degree.

Return value:

After the execution, it will return the Scaled companion matrix of dimensions(deg, deg)

Example:

In the below example, we are going to create a one-dimensional array by taking five coefficients, and it will return the scaled companion matrix along with the shape, dimensions, and datatype of the given array. The output will be a 2D-scaled companion matrix.

Output:

[ 4 5  6  8 10]
The Shape of the array is: (5,)
The dimension of the array is: 1
The Datatype of our Array is: int32
[[ 0.          0.70710678   0.         -0.28284271]
 [ 0.70710678   0.          0.5        -0.25      ]
 [ 0.          0.5         0.          0.2      ]
 [ 0.          0.          0.5        -0.4       ]]

Example 2:

In the below example, we are going to create a one-dimensional array by taking six coefficients, and it will return the scaled companion matrix along with the shape, dimensions, and datatype of the given array. The output will be a 2D-scaled companion matrix.

Output:

[ 4   5   6   8 10 12]
The Shape of the array is: (6,)
The dimension of the array is:  1
The Datatype of our Array is:  int32
[[ 0.012          0.70710678   0.021          0.014         -0.23570226]
 [ 0.70710678    0.021          0.5         0.03         -0.20833333]
 [ 0.02          0.5         0.04          0.5        -0.25      ]
 [ 0.01          0.03          0.5         0.04          0.16666667]
 [ 0.03          0.06          0.04          0.5        -0.41666667]]





Latest Courses