# How to gather terms into Elementary Symmetric Polynomials?

I would like to gather the terms of this polynomial (and much higher order ones):

$$q = 1-3 c+c^2+p[1]-2 c p[1]+p[2]-2 c p[2]+p[1] p[2]-c p[1] p[2]+p[3]-2 c p[3]+p[1] p[3]-c p[1] p[3]+p[2] p[3]-c p[2] p[3]+p[1] p[2] p[3]+p[4]-2 c p[4]+p[1] p[4]-c p[1] p[4]+p[2] p[4]-c p[2] p[4]+p[1] p[2] p[4]+p[3] p[4]-c p[3] p[4]+p[1] p[3] p[4]+p[2] p[3] p[4]+p[1] p[2] p[3] p[4]+p[5]-2 c p[5]+p[1] p[5]-c p[1] p[5]+p[2] p[5]-c p[2] p[5]+p[1] p[2] p[5]+p[3] p[5]-c p[3] p[5]+p[1] p[3] p[5]+p[2] p[3] p[5]+p[1] p[2] p[3] p[5]+p[4] p[5]-c p[4] p[5]+p[1] p[4] p[5]+p[2] p[4] p[5]+p[1] p[2] p[4] p[5]+p[3] p[4] p[5]+p[1] p[3] p[4] p[5]+p[2] p[3] p[4] p[5]$$

Into a much more convenient form like this:

$$q = 1 - 3c+c^2+(1-2c)e[1] + e[2] + e[3] + e[4]$$

Where the e[]'s are the Elementary Symmetric Polynomials of the p[]'s. How might I do this?

You can use SymmetricReduction[] for this. In particular, if you want the elementary symmetric polynomials to be represented symbolically instead of explicitly, you can use the three-argument form like so:

SymmetricReduction[q, Array[p, 5], Array[e, 5]] // Total
1 - 3 c + c^2 + (1 - 2 c) e[1] + (1 - c) e[2] + e[3] + e[4]

• Perfect! Thank you. – Jerry Guern Feb 13 '16 at 3:46