Let $f$ be a degree $n$ univariate polynomial in $Z[x]$, defined as $f = \sum\limits_{i=0}^{i=n} f_i x^i$. Let $$g = f^2 = f \cdot f = \sum\limits_{k=0}^{i=2n} g_k x^k$$ be the square of $f$. I am trying to find an expression for the coefficients $g_k$. So far, I have the standard expression: $$g_k = \sum\limits_{i+j=k,0 \le i,j \le n} f_i f_j.$$ But while playing with polynomials in Maple, I noticed that there is (seemingly) more structure in the coefficients. Is there a nicer formula for raising a polynomial to arbitrary powers? (and more specifically to power 2?)
Raising a polynomial to a power
-
3Well, a generalization to arbitrary powers is given by the multinomial theorem. – 2011-02-18
-
3@Calle: Only sort of; the multinomial theorem gives you the coefficients of the monomials in $(a_0+\cdots+a_m)^k$, but to get the coefficient of $x^r$ you would need to add over all monomials whose "index sum" equals $r$. – 2011-02-18
-
0@Arturo, ah, yes. That's true. – 2011-02-18
2 Answers
I've written this for the more general case of the p'th power of a powerseries $ f(x)=1+ax+bx^2+... $ You can just set all non-wanted coefficients to zero. Here is a screenshot:
The numerical coefficients at some term $ a^{e_1}*b^{e_2}*c^{e_3} $depends on the occurences of the exponents and the number of factors (multinomials)
At least you can do it faster, using discrete Fourier transform.
Let $a$ be a vector with $2n$ elements whose first $n$ elements are the coefficients of the polynomial $f$, the rest zero. Let $c$ be the vector with the coefficients for $g$. Then $c$ is the cyclic convolution of $a$ with itself:
$$c = a * a$$
But convolution turns to multiplication under the Fourier transform $\mathcal F$:
$$\mathcal F (c) = \mathcal F(a) \mathcal F(a)$$
using the inverse Fourier transform you get:
$$c = \mathcal F^{-1} \left( \mathcal F(a) \mathcal F(a) \right)$$
This can of course be generalized to arbitrary powers and polynomials which are not equal.
-
0Would FFT work over $\mathbb{Z}$? What would be the $n^{th}$-PRU? – 2011-02-18
-
2Just do as you would when you work over $\mathbb C$. Now you just happen to have integers. – 2011-02-18
-
0See http://everything2.com/title/Multiplication+using+the+Fast+Fourier+Transform. Time complexity is $O(n\log n)$. – 2011-02-18