在 Python 中将切比雪夫级数乘以一个自变量


要通过一个自变量将切比雪夫级数相乘,请在 Python Numpy 中使用 polynomial.chebyshev.chebmulx() 方法。该方法返回一个表示乘法结果的数组。c1 和 c2 参数是从低到高排列的切比雪夫级数系数的 1 维数组。

步骤

首先导入需要的函数库 -

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)

要通过一个自变量将切比雪夫级数相乘,请使用 polynomial.chebyshev.chebmulx() 方法 −

print("\nResult....\n",C.chebmulx(x))

範例

Open Compiler
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))

Learn Python in-depth with real-world projects through our Python certification course. Enroll and become a certified expert to boost your career.

输出

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]

最后更新于: 2022 年 2 月 28 日

108 次浏览

开启你的职业生涯

通过完成课程获得认证

开始
广告