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

สร้างอนุกรมเชบิเชฟด้วยรากเชิงซ้อนใน Python

ใช้ chebyshev.chebfromroots() สร้างอนุกรมเชบิเชฟจากรากเชิงซ้อน ผลลัพธ์จะเป็นอาร์เรย์ชนิดเชิงซ้อน

ขั้นตอน

from numpy.polynomial import chebyshev as C

j = complex(0, 1)
print("Result...\n", C.chebfromroots((-j, j)))
print("\nType...\n", C.chebfromroots((-j, j)).dtype)
print("\nShape...\n", C.chebfromroots((-j, j)).shape)

ตัวอย่างโค้ดสมบูรณ์

from numpy.polynomial import chebyshev as C

j = complex(0, 1)
print("Result...\n", C.chebfromroots((-j, j)))
print("\nType...\n", C.chebfromroots((-j, j)).dtype)
print("\nShape...\n", C.chebfromroots((-j, j)).shape)

ผลลัพธ์

Result...   [1.5+0.j 0. +0.j 0.5+0.j]
Type... complex128
Shape... (3,)