The pow() variant further improves accuracy (GH-102866)

This commit is contained in:
Raymond Hettinger 2023-03-21 00:02:14 -05:00 committed by GitHub
parent 4075fe1d8d
commit 1a5a14183e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -876,7 +876,7 @@ which incur interpreter overhead.
n = len(coefficients)
if n == 0:
return x * 0 # coerce zero to the type of x
powers = accumulate(repeat(x, n - 1), operator.mul, initial=1)
powers = map(pow, repeat(x), range(n))
return math.sumprod(reversed(coefficients), powers)
def polynomial_from_roots(roots):