Finding the nth Coefficient of Polynomial

Say I have a polynomial of degree 26, one that I obtain when I expand $(X-a)(X-b)(X-c)*...*(X-z)$ (x and X aren't the same so $(X-x)$ isn't 0),

How could I find coefficient $a_{14}$ without going through the painstaking multiplication?

For example I would start with $(X-a)(X-b) = X^2 -(a+b)X + ab$,

and then do $(X^2 -(a+b)X + ab)(X-c) = X^3 - (a+b+c)X^2 - (ab-ac-cb)X -abc$ and so on, but is there an easier way to find $a_{14}$? Should there be some sort of pattern?


Solution 1:

There is: these are given by Vieta's formulae. In the case of a degree-$26$ polynomial and the coefficient of $a_{14}$, it is given by the symmetric polynomial of degree $26-14=12$ in $-a,-b,\dotsc,-z$, which itself is the sum of all the products of $12$ distinct elements of this set, i.e. $$ (-1)^{12} (abcefghijkl + abcefghijkm + abcefghijkln + \dotsc + abcefghijlm + \dotsc + opqrstuvwxyz ) . $$

Another way to see this is to multiply out all the brackets at once: the products with $14$ $X$'s must contain $12$ factors that aren't $X$, so must each contain $12$ distinct elements of $-a,-b,\dotsc,-z$. All such factors are included, so again the result follows. You can see the same patterns in the quadratic and the cubic you calculated explicitly.

(Yes, there are an awful lot of terms here, roughly 9.6 million. This is unfortunately inevitable, although simplifications may be possible if they have specific values rather than being general.)

Solution 2:

There's a lot of multiplication you can't avoid, but it is not as much as all the multiplication, if you only need the one coefficient: you can enumerate the combinations of roots of a particular order.

For instance: In the degree-$4$ case, while getting all the coefficients would require adding up the results of $2^4 = 16$ multiplications, you only need to do $\binom{4}{2} = 6$ of those multiplications to get the $x^2$ term, namely the ones where we multiply together $4-2 = 2$ different roots: $a_2 = ab + ac + ad + bc + bd + cd$.

Similarly, for the $x^{14}$ term in a degree-$26$ polynomial, we must do $\binom{26}{14} = 9\,657\,700$ multiplications of piles of $26-14 = 12$ items each, which sounds terrible but it's a fair sight better than the $2^{26} = 67\,108\,864$ multiplications to get the full result.