Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

ยกระดับ Laguerre ให้เป็นพลังใน Python


ในการยกชุด Laguerre ให้เป็นกำลัง ให้ใช้เมธอด polynomial.laguerre.lagpow() ใน PythonNumpy วิธีการส่งคืนชุด Laguerre c ยกขึ้นสู่อำนาจ อาร์กิวเมนต์ c คือลำดับของสัมประสิทธิ์ที่เรียงลำดับจากต่ำไปสูง นั่นคือ [1,2,3] คือชุดข้อมูล P_0 + 2*P_1 + 3*P_2.

ส่งกลับชุด Laguerre c ยกขึ้นสู่อำนาจ อาร์กิวเมนต์ c คือลำดับของสัมประสิทธิ์ที่เรียงลำดับจากต่ำไปสูง นั่นคือ [1,2,3] คืออนุกรม P_0 + 2*P_1 + 3*P_2 พารามิเตอร์ c คือค่าสัมประสิทธิ์อนุกรม 1-Darray ของ Laguerre เรียงจากต่ำไปสูง พารามิเตอร์ pow คือ พลังเพื่อซึ่งซีรีส์จะถูกยกขึ้น พารามิเตอร์ maxpower คือกำลังสูงสุดที่อนุญาต นี่คือจุดประสงค์หลักเพื่อจำกัดการเติบโตของซีรีส์ให้มีขนาดที่ไม่สามารถจัดการได้ ค่าเริ่มต้นคือ 16

ขั้นตอน

ขั้นแรก นำเข้าไลบรารีที่จำเป็น -

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

สร้างอาร์เรย์ 1-D ของสัมประสิทธิ์อนุกรม Laguerre -

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

แสดงอาร์เรย์สัมประสิทธิ์ -

print("Our coefficient 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)

ในการยกชุด Laguerre ให้เป็นกำลัง ให้ใช้เมธอด polynomial.laguerre.lagpow() ใน PythonNumpy -

print("\nResult....\n",L.lagpow(c, 3))

ตัวอย่าง

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

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

# Display the coefficient array
print("Our coefficient 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 raise a Laguerre series to a power, use the polynomial.laguerre.lagpow() method in Python Numpy
print("\nResult....\n",L.lagpow(c, 3))

ผลลัพธ์

Our coefficient Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

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

Result....
   [ 150. -1116. 4590. -9672. 11934. -8100. 2430.]