Python 通过一个独立变量来乘以一个切比雪夫级数
要通过一个独立变量来乘以一个切比雪夫级数,在Python的Numpy中使用polynomial.chebyshev.chebmulx()方法。该方法返回一个代表乘法结果的数组。参数c1和c2是按照从低到高排序的切比雪夫级数系数的一维数组。
步骤
首先,导入所需的库 –
import numpy as np
from numpy.polynomial import chebyshev as C
创建一个数组 –
x = np.array([1, 2, 3])
显示数组 –
print("Our Array...\n",x)
检查尺寸 –
print("\nDimensions of our Array...\n",x.ndim)
获取数据类型 –
print("\nDatatype of our Array object...\n",x.dtype)
获取形状 –
print("\nShape of our Array object...\n",x.shape)
要将Chebyshev系列与自变量相乘,请使用polynomial.chebyshev.chebmulx()方法−
print("\nResult....\n",C.chebmulx(x))
示例
import numpy as np
from numpy.polynomial import chebyshev as C
# Create an array
x = np.array([1, 2, 3])
# Display the array
print("Our Array...\n",x)
# Check the Dimensions
print("\nDimensions of our Array...\n",x.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",x.dtype)
# Get the Shape
print("\nShape of our Array object...\n",x.shape)
# To multiply a Chebyshev series by an independent variable, use the polynomial.chebyshev.chebmulx() method in Python Numpy
# The method returns an array representing the result of the multiplication.
print("\nResult....\n",C.chebmulx(x))
输出
Our Array...
[1 2 3]
Dimensions of our Array...
1
Datatype of our Array object...
int64
Shape of our Array object...
(3,)
Result....
[1. 2.5 1. 1.5]