address power of polynomial overflow via FFT

38 Views Asked by At

I'm interested in all the n-th elementary symmetric polynomials coefficients of some coefficients, and using the FFT approach leads to some strange overflow issue, wondering how can I address them.

The interested polynomail:$f(x) = (1+ax)^n$, I am using $a=1$ and $n=100$ for example. And i was using two different approach.

The correct but not efficient one: reduce(numpy.polymul, [[1, 1] for _ in range(100)])

and the "efficient" but incorrect one: numpy.fft.irfft(numpy.prod([numpy.fft.rfft([1, 1]+[0 for _ in range(98)]) for _ in range(100)], axis=0))[:101]

But if i reduce the $n$ to $3$, then both approaches would have the same result.

I have tested the range of $n$ to have both approaches match, which is around $34$, for $2 \leq n \leq 33$, both approaches would have the same result.

Wondering what's off for the second efficient approach.