在 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))

範例

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]

最後更新於: 2022 年 2 月 28 日

108 次瀏覽

開啟你的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.