บทนำ
เมธอด legendre.legval() รองรับ x เป็นลิสต์ Python แปลงเป็น ndarray อัตโนมัติ
ตัวอย่าง: x = [5, 10, 15]
import numpy as np
from numpy.polynomial import legendre as L
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)
x = [5, 10, 15]
print("\nResult...\n", L.legval(x, c))
ผลลัพธ์
Our Array... [1 2 3]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (3,)
Result... [ 122. 469.5 1042. ]
อนุกรม P₀ + 2P₁ + 3P₂ ประเมินที่ x = 5, 10, 15 ให้ค่าตามลำดับ