I want to generate a polynomial equation by giving values and get an equaiton. However when I control it with given x values I get different values from equation here is my code and outputs:
points = np.array([(1, 1), (2, 4), (3, 1), (9, 3)])
x = points[:,0]
y = points[:,1]
# calculate polynomial
z = np.polyfit(x, y, 2)
f = np.poly1d(z)
It gives me this equation: -0.001416*x^2 + 0.1504*x + 1.72
OUTPUTS
x expected(y) returned(y)
1 1 1.868984
2 4 2.015136
3 1 2.158456
9 3 2.9589040000000004
Am I wrong or I read them wrong?