# Alex Moberg, Introduction to Linear Algebra in Sage# (1) Solve the following systems of linear equations by putting them in row reduced echelon form: x-2y+z=0, 2xy-8z=8, -4x+5y+9z=-9A=matrix(3,4,[1,-2,1,0,0,2,-8,8,-4,5,9,-9])printA.rref()
[ 1 0 0 29]
[ 0 1 0 16]
[ 0 0 1 3]
# (2) Let A equal the following matrix and let B equal the vector <6, 15, 24>. Use Sage to find all solutions to the equation Ax=B.A=matrix(3,3,[1,2,3,4,5,6,7,8,9]);show(A)B=vector([6,15,24])A\BC=matrix(3,4,[1,2,3,6,4,5,6,15,7,8,9,24]);show(C.rref())
147258369
(0, 3, 0)
100010−120030
# (3) Let A and B equal the following matrices. Compute A+3B, B-2A, AB, and B-3I.A=matrix(2,2,[1,2,-2,1]);show(A);B=matrix(2,2,[3,5,-1,4]);show(B)A+3*BB-2*AA*BI=identity_matrix(2)B-3*I
# (4) Let U equal the vector <1,1,0> and V equal the vector <2,0,-1>. Compute the dot product of U*V, the cross product of U x V and the magnitude of V.U=vector([1,1,0])V=vector([2,0,-1])U.dot_product(V)U.cross_product(V)norm(V)
2
(-1, 1, -2)
sqrt(5)
# (5) Let V equal the vector <-2,4,2,2> and W equal the vector <0,3,5,2>. Combine vector operations to compute the angle theta between V and W.V=vector([-2,4,2,2])W=vector([0,3,5,2])dotProductVW=V.dot_product(W)cosOftheta=dotProductVW/(norm(V)*norm(W))theta=arccos(cosOftheta)print(n(theta))