Professional Documents
Culture Documents
Horner Suy R NG
Horner Suy R NG
....
Ví dụ:
+ Với , xét đa thức
Ta sẽ tính .
1 -1 -1 1 2
-1 1 -2
0 -2 -1
1 -1 0
2 0 2
Vậy .
+ Với , xét đa thức
Ta sẽ tính .
2 0 -2 1 0 81
-5 2 -10
-3 -10 28
-1 28 -27
1 -27 -27
3 -27 0
Vậy .
Bài 2:
list=list(())
def horner(poly, n, x, h):
result = poly[0]
list.append(poly[0])
for i in range(1, n):
result = result*(x-(n-i-1)*h) + poly[i]
list.append(result)
return result
poly = [1,-1,-1,1,2]
x=2
n = len(poly)
h=1
print("Value of polynomial is " , horner(poly, n, x, h))
print(list)