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

คำนวณรากของอนุกรมเชบิเชฟใน Python

ใช้ chebroots() คำนวณรากของอนุกรมเชบิเชฟที่มีรากจริง

ขั้นตอน

from numpy.polynomial import chebyshev as C

print("Result (roots)...\n", C.chebroots((-1, 0, 1)))
print("\nType...\n", C.chebroots((-1, 0, 1)).dtype)
print("\nShape...\n", C.chebroots((-1, 0, 1)).shape)

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

from numpy.polynomial import chebyshev as C

print("Result (roots)...\n", C.chebroots((-1, 0, 1)))
print("\nType...\n", C.chebroots((-1, 0, 1)).dtype)
print("\nShape...\n", C.chebroots((-1, 0, 1)).shape)

ผลลัพธ์

Result (roots)...   [-1. 1.]
Type... float64
Shape... (2,)