MSCA 37016 Assignment 2
#Question 1
#a. 3. Because the left part of second equation equals to
# the two times the left part of the first equation, any number other than
# 2*1 will give no solution,
#b. 2. For the same reason as in part a, if q = 2, two equations will be the same.
# Two variables and one equation give infinte solution.
#Question 2
#[[2,3,1|12],[-2,3,-2 | 1],[1,-1,4 |16]]
#2*L3 + L2 => L3 = [0,1,6 | 33]
#L2 + L1 => L2 = [0,6,-1 | 13]
#L2 <=> L3
#L3 -6*L2 => L3 = [0,0,-37 | -185]
#z = -185/(-37) = 5
#y+5*6 = 33 => y =3
#2*x +3*3+1*5 = 12 => x = -1
#x = -1, y = 3, z = 5
#Code for question 2
import numpy as np
a = np.array([[2,3,1],[-2,3,-2],[1,-1,4]])
b = np.array([12,1,16])
x = np.linalg.solve(a, b)
x
#Question 3
#Rank is the number of pivot columns
#a. L4 - L3 => L4 = [0,0,0,0,-3], so the rank(A) = 4
#b. L2 - 2*L1 => L2 = [0,0,1,-2]
#L3 - L1 => L3 = [0,0,-2,5]
#L3 + 2*L2 => L3 = [0,0,0,1], so the rank(A) = 3
#Code for the question 3a
Aa = np.array([[1,3,1,2,0],[0,0,2,1,3],[0,0,0,3,2],[0,0,0,3,1]])
np.linalg.matrix_rank(Aa)
#Code for the question 3b
Ab = np.array([[-1,1,0,-1],[-2,2,1,-4],[-1,1,2,3]])
np.linalg.matrix_rank(Ab)
#Question 4
#They are linearly dependent, because there are three vectors in R2.