HomeLanguagesPython | SymPy Permutation.commutator() method

Python | SymPy Permutation.commutator() method

Permutation.commutator() : commutator() is a sympy Python library function that returns the commutator of the partition. Suppose ‘a’ and ‘b’ are part of ‘C’, then the commutator of a and b is the ‘C’ identity iff a and b commute, i.e. ab == ba.

Syntax :
sympy.combinatorics.permutations.Permutation.commutator()

Return :
commutator of the partition

Code #1 : commutator() Example




# Python code explaining
# SymPy.Permutation.commutator()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from sympy.combinatorics.permutations.Permutation.commutator() method 
  
# creating Permutation
a = Permutation([2, 0, 3, 1, 5, 4])
  
b = Permutation([1, 3, 5, 4, 2, 0])
  
  
print ("Permutation a - commutator form : ", a.commutator(b))
print ("Permutation b - commutator form : ", b.commutator(a))


Output :

Permutation a – commutator form : Permutation([3, 1, 2, 5, 4, 0])
Permutation b – commutator form : Permutation([5, 1, 2, 0, 4, 3])

Code #2 : commutator() Example – Self Commutator




# Python code explaining
# SymPy.Permutation.commutator()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from sympy.combinatorics.permutations.Permutation.commutator() method 
  
# creating Permutation
a = Permutation([[2, 4, 0], 
                 [3, 1, 2],
                 [1, 5, 6]])
  
# SELF COMMUTATING    
print ("Permutation a - commutator form : ", a.commutator(a))


Output :

Permutation a – commutator form : Permutation([], size=7)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS