MSCA 37106 Assignment3 Zewen Li

#Question 1
#x = (ATA)**-1ATb
#A = [[1,0],[0,1],[1,1]], AT = [[1,0,1],[0,1,1]], b = [[-1],[1],[0]]
#ATA = [[2,1],[1,2]]
#(ATA)**-1 = (1/(2*2-1*1))*[[2,-1],[-1,2]] = [[2/3,-1/3],[-1/3,2/3]]
#(ATA)**-1AT = [[2/3,-1/3,1/3],[-1/3,2/3,1/3]]
#(ATA)**-1ATb = [[-1],[1]]

# Code for Question 1
import numpy as np
A = np.array([[1,0],[0,1],[1,1]])
b = np.array([-1,1,0])
AT = A.transpose()
Z = np.dot(AT, A)
InverseZ = np.linalg.inv(Z)
P = np.dot(InverseZ, AT)
X = np.dot(P,b)
X

#Question 2
#It is not a linear transformation because it does not satisfy the rule of
# T(0) = 0. In this case, T(0,0,0)= (1,0,0).

#3Question 3
#a. T(e1)=T([1,0])=[2,0], T(e2) = T([0,1]) = [0,3],
# so the martix = [[2,0],[0,3]]
#b. Yes, an T2, [[1/2,0],[0,1/3]], is identified as the inverse of the T,
# so T is invertible.
#c. Ker(T) = span{(0,0)}
#d. Range(T) = R2