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

สร้างความแตกต่างให้กับชุด Laguerre ด้วยสัมประสิทธิ์หลายมิติใน Python


หากต้องการแยกความแตกต่างของซีรีส์ Laguerre ให้ใช้เมธอด laguerre.lagder() ใน Python วิธีการส่งกลับค่าสัมประสิทธิ์อนุกรม Laguerre c แตกต่าง m ครั้งตามแกน ในการทำซ้ำแต่ละครั้ง ผลลัพธ์จะคูณด้วย scl อาร์กิวเมนต์ c คืออาร์เรย์ของสัมประสิทธิ์จากระดับต่ำถึงสูงในแต่ละแกน เช่น [1,2,3] แทนชุดข้อมูล 1*L_0 + 2*L_1 + 3*L_2 ขณะที่ [[1,2],[1 ,2]] หมายถึง1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y) ) ถ้า axis=0 คือ x และ axis=1 คือ y

พารามิเตอร์ที่ 1 c คืออาร์เรย์ของสัมประสิทธิ์อนุกรมลากูแยร์ ถ้า c เป็นหลายมิติ ดิฟเฟอเรนซ์แกนจะสัมพันธ์กับตัวแปรต่างๆ โดยมีระดับในแต่ละแกนที่กำหนดโดยดัชนีที่สอดคล้องกัน พารามิเตอร์ตัวที่ 2 m คือจำนวนอนุพันธ์ที่หามาได้ จะต้องไม่เป็นค่าลบ (ค่าเริ่มต้น:1). พารามิเตอร์ตัวที่ 3 scl คือสเกลาร์ ดิฟเฟอเรนติเอชันแต่ละตัวคูณด้วย scl ผลลัพธ์ที่ได้คือการคูณด้วย scl**m ใช้สำหรับการเปลี่ยนแปลงเชิงเส้นของตัวแปร (ค่าเริ่มต้น:1). พารามิเตอร์ตัวที่ 4 แกนคือ anAxis ที่นำอนุพันธ์มา (ค่าเริ่มต้น:0).

ขั้นตอน

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

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

สร้างอาร์เรย์หลายมิติของสัมประสิทธิ์ -

c = np.arange(4).reshape(2,2)

แสดงอาร์เรย์ -

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)

หากต้องการแยกความแตกต่างของชุด Laguerre ให้ใช้วิธีการ laguerre.lagder() ใน Python -

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

ตัวอย่าง

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

# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)

# 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 differentiate a Laguerre series, use the laguerre.lagder() method in Python
print("\nResult...\n",L.lagder(c))

ผลลัพธ์

Our Array...
   [[0 1]
   [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

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

Result...
   [[-2. -3.]]