I want to generate all the possible combinations (commutative) of a few variables but also raised to some fixed powers.
Lets take the following example:
I have three variables x,y,z
.
The list I want to generate will have all these variables and also their combinations of two of them, three of them, any of them raised to power 2,
{x y z, x y,x z,y z, x,y,z,
x^2 y^2 z^2, x^2 y^2 z,x^2 y z^2,x y^2 z^2,
x^2 y z,x y^2 z,x y z^2,
x^2 y^2,y^2 z^2,x^2 z^2,
x^2 y,x y^2,x^2 z,x z^2,y^2 z,y z^2,
x^2,y^2,z^2}
Basically all possible combinations of any number of multiplications along with they can take two powers.
Is there any easier way without incorporating nested Do
loop?