I will include all parts of the algorithm that I want to be implemented, although it is really part 2 that I need help with (especially in the form discussed in the beginning of part 3).
I have homogeneous polynomials of the form say $x_1^2x_2x_3+ 2x_2^2x_3^2$. I'm looking to do the following to it:
- Find the monomial list of it, which is easily done with
MonomialList[]
. Choose a monomial say $2x_2^2x_3^2$ which is (like every other monomial) of degree $4$. Transform the monomial into $$ 2x_2^2x_3^2\to 2x_2 x_2 x_3x_3\to 2x_{2,1}x_{2,2}x_{3,3}x_{3,4} $$ where the second transform takes the $i$th variable appearing, say it is $x_k$, and transforms it into $x_{k,i}$. In other words when $x_{k,j}$ appears in the final result, it means in the original monomial at position j, the variable $x_k$ happens. The final result $2x_{2,1}x_{2,2}x_{3,3}x_{3,4}$ is supposed to be an expression NOT just a display.
In fact for the intermediate transformation $2x_2^2x_3^2\to 2x_2 x_2 x_3x_3$ it is convenient if it is done as $2x_2^2x_3^2\to \{2, \{x_2, x_2, x_3, x_3\}\}$. This is because later on in the algorithm I will need the average over over all permutations of $\{x_2, x_2, x_3,x_3\}$ in the following sense $$ 2x_2^2x_3^2\to \frac{1}{4!}\sum_{\sigma\in \mathrm{SymGrp}(4)} 2x_{2,\sigma(1)}x_{2,\sigma(2)}x_{3,\sigma(3)}x_{3,\sigma(4)} $$ I know how to do it if I have the list $\{x_2, x_2, x_3, x_3\}$.
Finally we fix an integer $n>0$, make a table
Table[Subscript[x, i, j]-> Subscript[R,j]^i Subscript[S,j]^(n - i), {i, 3},{j,4}]
And after flattening it, we make a replacement via the condition defined above, which essentially replaces $x_{i,j}\to (R_j)^i (S_j)^{n-i}$. This is the final thing I'm looking for.
All the steps are straightforward for me, except step 2. I'm asking how to do step 2. However I shared the whole process because someone might have a better idea altogether.