บทนำ
ในการหาอนุพันธ์ของอนุกรม Laguerre สามารถใช้เมธอด laguerre.lagder() จาก NumPy เมธอดนี้คืนค่าสัมประสิทธิ์ที่หาอนุพันธ์แล้ว m ครั้งตามแกน axis ในแต่ละรอบ ผลลัพธ์จะถูกคูณด้วย scl
พารามิเตอร์สำคัญ
- c: อาเรย์สัมประสิทธิ์อนุกรม Laguerre
- m: จำนวนครั้งของการหาอนุพันธ์ (ค่าเริ่มต้น: 1)
- scl: ตัวคูณสเกล (ค่าเริ่มต้น: 1)
- axis: แกนที่หาอนุพันธ์ (ค่าเริ่มต้น: 0)
ขั้นตอนการทำงาน
1. นำเข้าไลบรารี
import numpy as np from numpy.polynomial import laguerre as L
2. สร้างอาเรย์สัมประสิทธิ์แบบหลายมิติ
c = np.arange(4).reshape(2, 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)
4. หาอนุพันธ์ตามแกน 1
print("\nResult...\n", L.lagder(c, axis=1))
ตัวอย่างโค้ดสมบูรณ์
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)
# หาอนุพันธ์ตามแกน 1
print("\nResult...\n", L.lagder(c, axis=1))
ผลลัพธ์ที่คาดหวัง
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... [[-1.]
[-3.]]