63 ms·
Pieter Wuille pointed out to me that you can: def coeffs_from_roots(roots): coefs=[1] for r in roots: coefs=[-r*coefs[0]] + [coefs[i]-r*coefs[i
by nullc 4y ago
Pieter Wuille pointed out to me that you can:
def coeffs_from_roots(roots):
coefs=[1]
for r in roots:
coefs=[-r*coefs[0]] + [coefs[i]-r*coefs[i+1] for i in range(len(coefs)-1)] + [1]
coefs.reverse()
return coefs
That's merely quadratic, rather than taking exponentially many multiplications.