บทนำ
เมธอด chebyshev.chebval() ประเมินอนุกรม Chebyshev ที่จุด x รองรับทั้งสเกลาร์และอาร์เรย์
พารามิเตอร์
- x: จุดที่ประเมิน แปลงเป็น ndarray หากเป็นลิสต์/ทูเพิล
- c: สัมประสิทธิ์ c[n] สำหรับดีกรี n
- tensor: ค่าเริ่มต้น True ขยายรูปร่าง c สำหรับแต่ละมิติของ x
ตัวอย่าง: ประเมินที่ x = 1 (สเกลาร์)
import numpy as np
from numpy.polynomial import chebyshev as C
c = np.array([1, 2, 3])
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", C.chebval(1, c))
ผลลัพธ์
Our Array... [1 2 3]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (3,)
Result... 6.0
อนุกรม T₀ + 2T₁ + 3T₂ ที่ x=1: T₀(1)=1, T₁(1)=1, T₂(1)=1 → 1 + 2 + 3 = 6