Python
 Computer >> コンピューター >  >> プログラミング >> Python

Pythonで1つのチェビシェフシリーズを別のシリーズに乗算します


あるチェビシェフ系列を別の系列に乗算するには、Pythonでpolynomial.chebyshev.chebmul()メソッドを使用します。このメソッドは、それらの積を表すチェビシェフ級数係数の配列を返します。 2つのチェビシェフシリーズc1*c2の積を返します。引数は、最低次の「項」から最高次までの係数のシーケンスです。たとえば、[1,2,3]は系列T_0 + 2 * T_1 + 3*T_2を表します。パラメータc1とc2は、低から高の順に並べられたチェビシェフ級数係数の1次元配列です。

ステップ

まず、必要なライブラリをインポートします-

import numpy as np
from numpy.polynomial import chebyshev as C

チェビシェフ級数係数の1次元配列を作成する-

c1 = np.array([1,2,3])
c2 = np.array([3,2,1])

係数の配列を表示する-

print("Array1...\n",c1)
print("\nArray2...\n",c2)

データ型を表示する-

print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)

両方のアレイの寸法を確認してください-

print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)

両方のアレイの形状を確認してください-

print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)

あるチェビシェフ系列を別の系列に乗算するには、Python Numpyのpolynomial.chebyshev.chebmul()メソッドを使用します-

print("\nResult (multiplication)....\n",C.chebmul(c1,c2))

import numpy as np
from numpy.polynomial import chebyshev as C

# Create 1-D arrays of Chebyshev series coefficients
c1 = np.array([1,2,3])
c2 = np.array([3,2,1])

# Display the arrays of coefficients
print("Array1...\n",c1)
print("\nArray2...\n",c2)

# Display the datatype
print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)

# Check the Dimensions of both the arrays
print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)

# Check the Shape of both the arrays
print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)

# To multiply one Chebyshev series to another, use the polynomial.chebyshev.chebmul() method in Python Numpy
print("\nResult (multiplication)....\n",C.chebmul(c1,c2))

出力

Array1...
[1 2 3]

Array2...
[3 2 1]

Array1 datatype...
int64

Array2 datatype...
int64

Dimensions of Array1...
1

Dimensions of Array2...
1

Shape of Array1...
(3,)

Shape of Array2...
(3,)

Result (multiplication)....
[ 6.5 12. 12. 4. 1.5]

  1. Pythonで1つの多項式を別の多項式に乗算する

    ある多項式を別の多項式に乗算するには、Pythonでnumpy.polynomial.polynomial.polymul()メソッドを使用します。 2つの多項式c1+c2の乗算を返します。引数は、最低次の項から最高次の項までの係数のシーケンスです。つまり、[1,2,3]は多項式1 + 2 * x + 3 * x**2を表します。 このメソッドは、それらの合計を表す係数配列を返します。パラメータc1とc2は、「標準」基底を基準にして、多項式を表す係数の1次元配列であり、最低次の項から最高の項の順に並べられています。 このnumpy.polynomial.polynomialモジュールは、通

  2. Python-あるリストが別のリストに最初に出現する

    あるリストが別のリストで最初に出現する場所を見つける必要がある場合は、「set」属性と「next」メソッドが使用されます。 例 以下は同じもののデモンストレーションです my_list_1 = [23, 64, 34, 77, 89, 9, 21] my_list_2 = [64, 10, 18, 11, 0, 21] print("The first list is :") print(my_list_1) print("The second list is :") print(my_list_2) my_list_2 = set(my_list_