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

หาอนุพันธ์อนุกรม Chebyshev กำหนดจำนวนอนุพันธ์และสเกลใน Python

บทนำ

เมธอด chebyshev.chebder() รองรับการกำหนดจำนวนครั้งของการหาอนุพันธ์ (m) และตัวคูณสเกล (scl) พร้อมกัน

พารามิเตอร์ m และ scl

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

ตัวอย่าง: m=2, scl=-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 ครั้ง พร้อม scl = -1
print("\nResult...\n", C.chebder(c, 2, scl=-1))

ผลลัพธ์

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... [12. 96.]

scl=-1 ทำให้เครื่องหมายสลับกันทุกครั้งของการหาอนุพันธ์ ผลคูณด้วย (-1)² = 1 แต่ส่งผลต่อค่าระหว่างทาง