在 Python 中用自變數乘以勒讓德級數


要將勒讓德級數 c 乘以 x(其中 x 是自變數),請在 Python Numpy 中使用 polynomial.laguerre.legmulx() 方法。該方法返回一個表示乘法結果的陣列。返回兩個勒讓德級數 c1 - c2 的差。引數是按從最低階項到最高階項排序的係數序列,即 [1,2,3] 表示級數 P_0 + 2*P_1 + 3*P_2。引數 c 是一個從低到高排序的勒讓德級數係數的一維陣列。

步驟

首先,匯入所需的庫 -

import numpy as np
from numpy.polynomial import laguerre as L

建立陣列 -

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

顯示陣列 -

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)

要將勒讓德級數 c 乘以 x(其中 x 是自變數),請在 Python Numpy 中使用 polynomial.laguerre.legmulx() 方法 -

print("\nResult....\n",L.legmulx(c))

示例

import numpy as np
from numpy.polynomial import legendre as L

# Create an array
c = np.array([1, 2, 3])

# 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 multiply the Legendre series c by x, where x is the independent variable, use the polynomial.laguerre.legmulx() method in Python Numpy
print("\nResult....\n",L.legmulx(c))

輸出

Our Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

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

Result....
   [0.66666667 2.2 1.33333333 1.8 ]

更新於: 2022-03-07

137 次檢視

啟動您的 職業生涯

透過完成課程獲得認證

開始
廣告

© . All rights reserved.