I'm at a loss here.

I'm trying to describe the following, but I'll use an example to illustrate.

Given variables X, Y, and Z.

You have an equation, E1, such that

E1 = X2Y + X2Z + Y2X + Y2Z + Z2X + Z2Y

As you can see, the right hand side is the summation of all combinations of 2 elements taken from the group (X,Y,Z) Where one element is raised to the 2nd power, while the second element is to the first.

So, I'd like to ascribe a symbolic description to this, something along the lines of

E1 = Sum{X,Y,Z}2,1,0
Of course, the 0 is superfluous, so this could also be said to be identical to:
E1 = Sum{X,Y,Z}2,1

However, is this the best way? How would you do it?


Next:

lets say you had the following:

E1 = Sum{X1,X2,X3}1,1

and E2 = E1, thus
E1 x E2 = Sum{X1,X2,X3}2,2 + 2*Sum{X1,X2,X3}2,1,1

How would you approach developing a program to input E1 and E2, and outputing their product?