首頁 >後端開發 >Python教學 >將一個多項式轉換為Python中的Hermite_e級數

將一個多項式轉換為Python中的Hermite_e級數

WBOY
WBOY轉載
2023-09-08 08:25:021202瀏覽

將一個多項式轉換為Python中的Hermite_e級數

要將多項式轉換為Hermite級數,請在Python中使用hermite_e.poly2herme()方法

Numpy. Convert an array representing the coefficients of a polynomial ordered from lowest degree 到最高點,到等效Hermite級數的係數數組,從低到高排序 最高次數。此方法傳回一個包含等效係數的一維數組 Hermite系列。參數pol是一個包含多項式係數的1-D陣列

步驟

首先,導入所需的函式庫−

import numpy as np
from numpy.polynomial import hermite_e as H

使用numpy.array()方法建立一個陣列−

c = np.array([1, 2, 3, 4, 5])

顯示陣列−

print("Our Array...\n",c)

檢查尺寸−

print("\nDimensions of our Array...\n",c.ndim)

取得資料類型−

print("\nDatatype of our Array object...\n",c.dtype)

取得形狀−

print("\nShape of our Array object...\n",c.shape)

要將多項式轉換為Hermite級數,請在Python中使用hermite_e.poly2herme()方法

Numpy. Convert an array representing the coefficients of a polynomial ordered from lowest degree 到最高點,到等效Hermite級數的係數數組,從低到高排序 最高學位 −
print("\nResult (polynomial to hermite_e)...\n",H.poly2herme(c))

Example

import numpy as np
from numpy.polynomial import hermite_e as H

# Create an array using the numpy.array() method
c = np.array([1, 2, 3, 4, 5])

# Display the array
print("Our Array...\n",c)

# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)

# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)

# Get the Shape
print("\nShape of our Array object...\n",c.shape)

# To convert a polynomial to a Hermite series, use the hermite_e.poly2herme() method in Python Numpy
print("\nResult (polynomial to hermite_e)...\n",H.poly2herme(c))

輸出

Our Array...
   [1 2 3 4 5]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(5,)

Result (polynomial to hermite_e)...
   [19. 14. 33. 4. 5.]

以上是將一個多項式轉換為Python中的Hermite_e級數的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除