Sharedex_intro.sagewsOpen in CoCalc
Author: Susan Margulies
Views : 3
A = matrix([ [2,0,0,0,0,89], [0,2,0,0,0,243], [0,0,2,0,0,212], [0,0,0,2,0,150], [0,0,0,0,2,245], [1,1,1,1,1,546] ]) #A #type(A) A.LLL()
[-1 1 -1 1 -1 0] [ 1 -1 -1 1 -1 -1] [-1 -1 -1 1 1 2] [ 1 -1 -1 -1 -1 2] [-2 -2 4 0 -2 0] [-6 -4 -6 -6 0 -3]
2 + 2 2*2 a = 2 b = 4 a*b type(b) # just adding a comment p = "this is a string" p t = "r" type(t) t
4 4 8 <type 'sage.rings.integer.Integer'> 'this is a string' <type 'str'> 'r'
a = 3 b = 5 c = 0 if a > b: c = 2*(a+b) # indented in the if statement elif a == b: c = 3*(a + b) else: c = -2*(a+b) # end if # not indented not in the if statement c
-16
# observe the upper bound for i in range(1,7): print "the value of i = " + str(i) + "and the value of i + 1 = " + str(i+1)
the value of i = 1and the value of i + 1 = 2 the value of i = 2and the value of i + 1 = 3 the value of i = 3and the value of i + 1 = 4 the value of i = 4and the value of i + 1 = 5 the value of i = 5and the value of i + 1 = 6 the value of i = 6and the value of i + 1 = 7
a = 0 while a <= 7: a = a + 1 print a print "I have exited the while loop"
1 2 3 4 5 6 7 8 I have exited the while loop
gcd(7, 26) inverse_mod(7, 26) mod(7*15, 26)
1 15 1
#G = graphs.DiamondGraph() #G.show() # long time #G = graphs.LollipopGraph(13,4); #G = graphs.StarGraph(23) #g = graphs.TadpoleGraph(13, 4); g #g.show() G = graphs.PetersenGraph() G.plot().show() # or G.show() M = G.adjacency_matrix() M
[0 1 0 0 1 1 0 0 0 0] [1 0 1 0 0 0 1 0 0 0] [0 1 0 1 0 0 0 1 0 0] [0 0 1 0 1 0 0 0 1 0] [1 0 0 1 0 0 0 0 0 1] [1 0 0 0 0 0 0 1 1 0] [0 1 0 0 0 0 0 0 1 1] [0 0 1 0 0 1 0 0 0 1] [0 0 0 1 0 1 1 0 0 0] [0 0 0 0 1 0 1 1 0 0]
A = matrix([ [3,2], [4,3] ]) A B = matrix([ [3,1], [7,2] ]) B AB = A*B print "AB = " AB AB.transpose() print "B^T = " B.transpose() print "A^T = " A.transpose() B.transpose()*A.transpose()
[3 2] [4 3] [3 1] [7 2] AB = [23 7] [33 10] [23 33] [ 7 10] B^T = [3 7] [1 2] A^T = [3 4] [2 3] [23 33] [ 7 10]