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

หาอนุพันธ์อนุกรม Chebyshev ใน Python

บทนำ

เมธอด chebyshev.chebder() ใน NumPy ใช้หาอนุพันธ์ของอนุกรม Chebyshev ส่งคืนสัมประสิทธิ์ของอนุกรม Chebyshev ที่เป็นอนุพันธ์

พารามิเตอร์หลัก

  • c: อาร์เรย์สัมประสิทธิ์จากดีกรีต่ำไปสูง
  • m: จำนวนอนุพันธ์ (ค่าเริ่มต้น 1) ต้องไม่ติดลบ
  • scl: ตัวคูณสเกล (ค่าเริ่มต้น 1) ผลคูณด้วย scl**m
  • axis: แกนที่หาอนุพันธ์ (ค่าเริ่มต้น 0)

ตัวอย่าง: อนุพันธ์ของอนุกรม 1 มิติ

1. เตรียมข้อมูล

import numpy as np
from numpy.polynomial import chebyshev as C

c = np.array([1, 2, 3, 4])
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)

2. หาอนุพันธ์

print("\nResult...\n", C.chebder(c))

ผลลัพธ์

Our coefficient Array... [1 2 3 4]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (4,)
Result... [14. 12. 24.]

อาร์เรย์ [1,2,3,4] แทนอนุกรม 1*T₀ + 2*T₁ + 3*T₂ + 4*T₃ อนุพันธ์ให้ผลลัพธ์ [14, 12, 24]