บทนำ
การหาอนุพันธ์ของอนุกรมเลจันเดอร์ใช้เมธอด polynomial.legendre.legder() (หมายเหตุ: ไม่ใช่ laguerre) เมธอดคืนค่าสัมประสิทธิ์ c ที่หาอนุพันธ์ m ครั้งตาม axis แต่ละรอบผลลัพธ์คูณ scl
พารามิเตอร์
- c: อาร์เรย์สัมประสิทธิ์อนุกรมเลจันเดอร์
- m: จำนวนอนุพันธ์ ต้องไม่ติดลบ (Default: 1)
- scl: สเกลาร์ แต่ละอนุพันธ์คูณ scl ผลลัพธ์สุดท้ายคูณ scl**m (Default: 1)
- axis: แกนที่หาอนุพันธ์ (Default: 0)
ขั้นตอนการทำงาน
1. นำเข้าไลบรารี
import numpy as np from numpy.polynomial import legendre as L
2. สร้างอาร์เรย์สัมประสิทธิ์
c = np.array([1, 2, 3, 4])
3. แสดงอาร์เรย์
print("Our Array...\n", c)
4. ตรวจสอบมิติ
print("\nDimensions of our Array...\n", c.ndim)
5. ตรวจสอบชนิดข้อมูล
print("\nDatatype of our Array object...\n", c.dtype)
6. ตรวจสอบรูปร่าง
print("\nShape of our Array object...\n", c.shape)
7. หาอนุพันธ์ (m=2, scl=-1)
print("\nResult...\n", L.legder(c, 2, scl=-1))
ตัวอย่างโค้ดสมบูรณ์
import numpy as np
from numpy.polynomial import legendre as L
c = np.array([1, 2, 3, 4])
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)
print("\nResult...\n", L.legder(c, 2, scl=-1))
ผลลัพธ์ที่คาดหวัง
Our Array... [1 2 3 4] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) Result... [ 9. 60.]