Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Assuming I have two elements of the permutation group algebra $a_1$, $a_2$ such that $a_i=\sum_{p\in S_n}\alpha_pp$, I want to define a linear product $\odot$ that distributes over the sum and pulls out scalars: $a_1\odot a_2=\sum_{p\in S_n}\sum_{q\in S_n}\alpha_p\alpha_qp\odot q$, where $p\odot q\equiv PermutationProduct[p,q]$. If I try for example

Distribute[PermutationProduct[Cycles[{{}}] + Cycles[{{1, 2}}], Cycles[{{}}] - Cycles[{{1, 2}}]]}

The result is

Cycles[{}] +PermutationProduct[Cycles[{{1, 2}}],(-Cycles[{{1, 2}}])]

but I'm not sure how to make it take "constants" outside the product.

share|improve this question

Try this:

In[1]:= Unprotect[PermutationProduct];
        PermutationProduct[left___, sum_Plus, right___] := PermutationProduct[left, #, right] & /@ sum;
        PermutationProduct[left___, c_ perm_?PermutationCyclesQ, right___] := c PermutationProduct[left, perm, right];
        PermutationProduct[left___, 0, right___] := 0;

The first definition expands sums automatically, without the need of calling Distribute. The second definition extracts anything that is not a valid Cycles object (the "constants"). The third one deals with 0, a special case not covered by those two previous definitions.

Then you can do something like this:

In[6]:= {g1, g2, g3} = RandomPermutation[5, 3]
Out[6]= {Cycles[{{1, 5}, {2, 4, 3}}], Cycles[{{1, 2, 4, 3, 5}}], Cycles[{{2, 3, 5}}]}

In[7]:= ((2 + a) g1 + Sqrt[3] b g2) \[PermutationProduct] (-g3 + Pi g1/2)
Out[7]= 1/2 (2 + a) \[Pi] Cycles[{{2, 3, 4}}] - (2 + a) Cycles[{{1, 2, 4, 5}}] + 1/2 Sqrt[3] b \[Pi] Cycles[{{1, 4, 2, 3}}] - Sqrt[3] b Cycles[{{1, 3, 2, 4, 5}}]

And your example is now:

In[8]:= PermutationProduct[Cycles[{}] + Cycles[{{1, 2}}], Cycles[{}] - Cycles[{{1, 2}}]]
Out[8]= 0
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.