Worksheets related to Applied Discrete Structures
a=2017
b=561
[q,r]=[a//b,a%b]
[q,r]

[3, 334]
a=2017
b=561
print gcd(a,b)
print xgcd(a,b)

1 (1, -173, 622)
G=AbelianGroup(1,[14])
G.list()


(1, f, f^2, f^3, f^4, f^5, f^6, f^7, f^8, f^9, f^10, f^11, f^12, f^13)

for g in G:
print str(g)+" has order "+str(g.order())

1 has order 1 f has order 14 f^2 has order 7 f^3 has order 14 f^4 has order 7 f^5 has order 14 f^6 has order 7 f^7 has order 2 f^8 has order 7 f^9 has order 14 f^10 has order 7 f^11 has order 14 f^12 has order 7 f^13 has order 14
G= AdditiveAbelianGroup([2,2,2])
G.list()

[(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), (0, 0, 1), (1, 0, 1), (0, 1, 1), (1, 1, 1)]


G.is_cyclic()

False
 G= AdditiveAbelianGroup([23]); G

Additive abelian group isomorphic to Z/23
G2=AdditiveAbelianGroup([2,4]);G2

Additive abelian group isomorphic to Z/2 + Z/4


+ (0, 0) (0, 1) (0, 2) (0, 3) (1, 0) (1, 1) (1, 2) (1, 3) +-------------------------------------------------------- (0, 0)| (0, 0) (0, 1) (0, 2) (0, 3) (1, 0) (1, 1) (1, 2) (1, 3) (0, 1)| (0, 1) (0, 2) (0, 3) (0, 0) (1, 1) (1, 2) (1, 3) (1, 0) (0, 2)| (0, 2) (0, 3) (0, 0) (0, 1) (1, 2) (1, 3) (1, 0) (1, 1) (0, 3)| (0, 3) (0, 0) (0, 1) (0, 2) (1, 3) (1, 0) (1, 1) (1, 2) (1, 0)| (1, 0) (1, 1) (1, 2) (1, 3) (0, 0) (0, 1) (0, 2) (0, 3) (1, 1)| (1, 1) (1, 2) (1, 3) (1, 0) (0, 1) (0, 2) (0, 3) (0, 0) (1, 2)| (1, 2) (1, 3) (1, 0) (1, 1) (0, 2) (0, 3) (0, 0) (0, 1) (1, 3)| (1, 3) (1, 0) (1, 1) (1, 2) (0, 3) (0, 0) (0, 1) (0, 2)


G2.is_cyclic()


False
a=[1878,1384,84,2021,784,1509,1740,1201,2363,1774,1865,33,1477,894,690,520,198,1349,1278,650]
s =0
for t in a:
s+=t
s

23692


G=cartesian_product([Integers(32),Integers(27),Integers(25)])
def theta(x):
return G((x%32,x%27,x%25))

theta(1000)

(8, 1, 0)
[theta(1878)+theta(1384),theta(1878+1384)]

[(30, 22, 12), (30, 22, 12)]
sum=G((0,0,0))
for t in a:
sum+=theta(t)
sum

(12, 13, 17)
l=list(sum)

(7425*12 + 6400*13+ 7776* 17)%21600

2092
isum=crt([12,13,17],[32,27,25])
[isum,(s-isum)%(32*27*25)]


[2092, 0]
32*27*25

21600
s =0
for t in a:
s+=t
s

(s-isum)%21600

0
u=[crt([1,0,0],[32,27,25]),crt([0,1,0],[32,27,25]),crt([0,0,1],[32,27,25])]
u


[7425, 6400, 7776]
G=DihedralGroup(5)
gr=G.cayley_graph(simple="True")
gr.plot(vertex_size=2)









g=DiGraph({2:[1],1:[2,3]})
g.plot()

triangle = SymmetricGroup(3)
triangle.list()

[(), (1,2), (1,2,3), (1,3,2), (2,3), (1,3)]
triangle.cayley_graph(generators=[(1,2),(1,2,3)]).show()

triangle.cayley_graph(generators=[(1,2),(1,3)]).show()