CoCalc Public FilesQuiz 3 / Sage application presentation.sagewsOpen with one click!
Authors: Laura Gross, Christian LaChance
Views : 66
Compute Environment: Ubuntu 20.04 (Default)
# Christian LaChance # using coding to produce vectors and matricies # solve simple linear algebra equations with coding # problem 1 produce a code that creates a vector using any numbers of choice v = vector(QQ,[ 5, 7, -2]) print(v)
(5, 7, -2)
# problem 2 produce a code that adds 2 vectors to create a vector x = vector(QQ,[ 5, 7, -2]) y = vector(QQ,[ 3, -3, 9]) m = x + y print(m)
(8, 4, 7)
# problem 3 produce a code that creates a 3 by 3 matrix using any numbers of choice m = matrix(QQ, [[1,-12, 0], [8,-2, 3], [13, 4, -1]]) print(m)
[ 1 -12 0] [ 8 -2 3] [ 13 4 -1]
# problem 4 produce a code that adds two 3 by 3 matrices together m1 = matrix(QQ, [[1,-12, 0], [8,-2, 3], [13, 4, -1]]) m2 = matrix(QQ, [[-4,2, 6], [6,7, -3], [-3, 7, 5]]) m = m1 + m2 print(m)
[ -3 -10 6] [ 14 5 0] [ 10 11 4]
# problem 5 produce a code that multiplies three 3 by 3 matrices together m1 = matrix(QQ, [[1,-12], [8,-2]]) m2 = matrix(QQ, [[-4,2], [6,7]]) m3 = matrix(QQ, [[1,-5, -2], [3,2, 7], [8, -4, 2]]) m = m1*m2 print(m)
[-76 -82] [-44 2]