# Multiplication of the factors $(x+a_i)$, what are the coefficients? [duplicate]

Possible Duplicate:
Create polynomial coefficients from its roots

When multiplying some factors $(x+a_i)$, is there a neat way to write the coefficients in $x$? I tried up to three factors, and there's definitely some pattern. My program should be able to find the factors of different powers of x without calculating symbolically.

The number of factors will be relatively small ($< 30$).

## marked as duplicate by J. M. is a poor mathematician, Asaf Karagila♦, t.b., Martin Sleziak, Zev ChonolesDec 14 '11 at 4:36

They are given by Viète's formulas, which in the case of monic polynomials are equivalent to the elementary symmetric polynomials in the $a_i$.
The coefficient of degree $k$ will be the sum of all possible products of $n-k$ distinct factors taken from $a_1,\ldots,a_n$. There are $\binom{n}{n-k} = \frac{n!}{k!(n-k)!}$ such products.
For example, if $n=7$, then the coefficient of $x^2$ will be \begin{align*} a_1a_2a_3a_4a_5 &+a_1a_2a_3a_4a_6 + a_1a_2a_3a_4a_7 + a_1a_2a_3a_5a_6 +a_1a_2a_3a_5a_7\\ &+ a_1a_2a_3a_6a_7 + a_1a_2a_4a_5a_6 + a_1a_2a_4a_5a_7 +a_1a_2a_4a_6a_7\\ &+ a_1a_2a_5a_6a_7+ a_1a_3a_4a_5a_6 + a_1a_3a_4a_5a_7 +a_1a_3a_4a_6a_7\\ &+ a_1a_3a_5a_6a_7 + a_1a_4a_5a_6a_7 + a_2a_3a_4a_5a_6 + a_2a_3a_4a_5a_7\\&+ a_2a_3a_4a_6a_7 + a_2a_3a_5a_6a_7 + a_2a_4a_5a_6a_7 + a_3a_4a_5a_6a_7. \end{align*} All $\frac{7!}{2!5!} = \frac{7\times 6}{2} = 21$ possible products of five distinct factors taken from $a_1,a_2,a_3,a_4,a_5,a_6,a_7$.