XX = [1, -3, 8] YY = [6, -8, -4] n = len(XX) P = 0 for i in range(0,n ): P = P + YY[i] * coefficient(XX, i) print(P) print(expand(P))