Using the cycle notation https://en.wikipedia.org/wiki/Cyclic_permutation in group theory, we obviously have (with the calculation order from left to right):
Blockquote (1,2)(2,3)=(1,3,2)=(3,4)(1,4,2)(3,4) Blockquote
But the following code in Python returns me a "False":
from sympy.combinatorics import Permutation
a = Permutation(1,2)
b = Permutation(2,3)
c = Permutation(3,4)
d = Permutation(1,4,2)
print(a*b == c*d*c)
False
print(a*b)
print(c*d*c)
(1 3 2)
(4)(1 3 2)
From the last part of code we can easily see that the problem is SymPy treats "a*b" as a permutation on the set {0,1,2,3} while treating "c*d*c" as a permutation on the set {0,1,2,3,4}.
Any simple trick can resolve this problem in general?
CodePudding user response:
You need to set the size of the set on which the Permutation operates:
In [92]: from sympy.combinatorics import Permutation
...: a = Permutation(1,2, size=5)
...: b = Permutation(2,3, size=5)
...: c = Permutation(3,4, size=5)
...: d = Permutation(1,4,2, size=5)
In [93]: print(a*b == c*d*c)
True
This is explained in the docs (see help(Permutations)
):
https://docs.sympy.org/latest/modules/combinatorics/permutations.html#sympy.combinatorics.permutations.Permutation