Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

sage presentation

Views: 63
#Matrices in Sage #1.Define a Matrix A & Matrix B A = matrix( [ [3, 6, 9], [7, 2, 4], [6, 8, 5] ])
print(A)
[3 6 9] [7 2 4] [6 8 5]
B = matrix( [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ])
print(B)
[1 2 3] [4 5 6] [7 8 9]
#Notice with this method of writing it in Sage we do not need to define the size of the matrix. #2. Simple Operations to the Matrix A & Matrix B. #Multiplication A*B
[ 90 108 126] [ 43 56 69] [ 73 92 111]
#Exponants A^3
[1605 1602 1833] [1269 1238 1298] [1622 1696 1859]
A*A*A
[1605 1602 1833] [1269 1238 1298] [1622 1696 1859]
#3. Reducing a matrix C= matrix([[3,2,1,4] , [2, 1, 5, 8] , [3,6,9,12]])
print C
[ 3 2 1 4] [ 2 1 5 8] [ 3 6 9 12]
print C.rref()
[ 1 0 0 6/5] [ 0 1 0 -2/5] [ 0 0 1 6/5]
#4. Inverse of a Matrix C= matrix([[5,2,3] , [4, 9, 6] , [7,8,12]])
print"Before:" print C
Before: [ 5 2 3] [ 4 9 6] [ 7 8 12]
print "After:" C.inverse()
After: [ 4/13 0 -1/13] [ -2/65 1/5 -6/65] [-31/195 -2/15 37/195]
C^(-1)
[ 4/13 0 -1/13] [ -2/65 1/5 -6/65] [-31/195 -2/15 37/195]
#Using the Commands BEFORE and AFTER really help us be organized when typing our work. #Instead of typing C.inverse(), we can use a different format. #5. Determinants D = matrix( [ [1, 2] , [3, 4]] )
print D
[1 2] [3 4]
det(D)
-2
#Determinants are useful , not only linear algebra, but also to do such things as finding out if a matrix is a group in Abstract Algebra. #det= ad-bc, which in our case was det=(1*4)-(2*3)