Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
17 views
#Names: #Zachary Bridwell #McKenzie Marquez #Creating Cosets of Z mod n where n is arbitrary and a subgroup of Z mod n is known.
def CosetofInt(G,H,n): Ans=[[mod(G[j]+H[i],n) for i in range(len(H))] for j in range(len(G))] ans=[] for k in range(len(Ans)): ans=ans+[Ans[k]] return ans
def Index(G,H): return len(G)/len(H)
G=range(15) #Z mod 15 H=[0,5,10] #Subgroup of G generated by 5 CosetofInt(G,H,len(G)) #Note that if converted to "Set" notation, will return Z mod 15 (Not the union of each element to eliminate duplicates). #The problem with this is that we have repeating subgroups. Ie. [0,5,10]=[5,10,0] in Group Theory
[[0, 5, 10], [1, 6, 11], [2, 7, 12], [3, 8, 13], [4, 9, 14], [5, 10, 0], [6, 11, 1], [7, 12, 2], [8, 13, 3], [9, 14, 4], [10, 0, 5], [11, 1, 6], [12, 2, 7], [13, 3, 8], [14, 4, 9]]
def NicePrint(alist): print "Since Z mod n is abelian, H is a normal subgroup." for i in range(Index(G,H)): print "The %s + H coset is:"%G[i] print "%s." %(alist[i]) return None
NicePrint(CosetofInt(G,H,15))
Since Z mod n is abelian, H is a normal subgroup. The 0 + H coset is: [0, 5, 10]. The 1 + H coset is: [1, 6, 11]. The 2 + H coset is: [2, 7, 12]. The 3 + H coset is: [3, 8, 13]. The 4 + H coset is: [4, 9, 14].
G=range(21) #Z mod 21 H=[0,7,14] #Subgroup generated by 7 NicePrint(CosetofInt(G,H,len(G)))
Since Z mod n is abelian, H is a normal subgroup. The 0 + H coset is: [0, 7, 14]. The 1 + H coset is: [1, 8, 15]. The 2 + H coset is: [2, 9, 16]. The 3 + H coset is: [3, 10, 17]. The 4 + H coset is: [4, 11, 18]. The 5 + H coset is: [5, 12, 19]. The 6 + H coset is: [6, 13, 20].
NicePrint(CosetofInt(range(100),[5*i for i in range(100/5)],len(range(100)))) #Note that the only problem with entering it this way is that we get the Coset 6+H=1+H, 5+H; so there is an extra element.
Since Z mod n is abelian, H is a normal subgroup. The 0 + H coset is: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]. The 1 + H coset is: [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96]. The 2 + H coset is: [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97]. The 3 + H coset is: [3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 88, 93, 98]. The 4 + H coset is: [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89, 94, 99]. The 5 + H coset is: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 0]. The 6 + H coset is: [6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 1].