In-Class use of Matlab 3/7/2012 Is A invertible? If so, what is its inverse? >> A=[1 2 3 4; 5 6 7 8; 1 0 1 0; 0 1 0 1] A = 1 2 3 4 5 6 7 8 1 0 1 0 0 1 0 1 >> I4=eye(4) I4 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 >> A1=[A I4] A1 = 1 2 3 4 1 0 0 0 5 6 7 8 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 >> A2=rref(A1) A2 = Columns 1 through 7 1.0000 0 0 -1.0000 0 -0.5000 3.5000 0 1.0000 0 1.0000 0 0 0 0 0 1.0000 1.0000 0 0.5000 -2.5000 0 0 0 0 1.0000 -1.0000 4.0000 Column 8 3.0000 1.0000 -3.0000 4.0000 This A was not invertible. Let's ask the same question for another A. >> A=[1 2 3 4; 5 -6 7 -8; 1 0 1 0; 0 -1 0 1] A = 1 2 3 4 5 -6 7 -8 1 0 1 0 0 -1 0 1 >> A1=[A I4] A1 = 1 2 3 4 1 0 0 0 5 -6 7 -8 0 1 0 0 1 0 1 0 0 0 1 0 0 -1 0 1 0 0 0 1 >> A2=rref(A1) A2 = Columns 1 through 7 1.0000 0 0 0 -0.3500 -0.1500 2.1000 0 1.0000 0 0 0.0500 -0.0500 0.2000 0 0 1.0000 0 0.3500 0.1500 -1.1000 0 0 0 1.0000 0.0500 -0.0500 0.2000 Column 8 0.2000 -0.6000 -0.2000 0.4000 This A was invertible. Its inverse was the right-hand side of the matrix. Let's check to be sure the inverse works. that is: Ainv*A=A*Ainv=I4. >> Ainv=A2(1:4,5:8) Ainv = -0.3500 -0.1500 2.1000 0.2000 0.0500 -0.0500 0.2000 -0.6000 0.3500 0.1500 -1.1000 -0.2000 0.0500 -0.0500 0.2000 0.4000 >> A*Ainv ans = 1.0000 -0.0000 -0.0000 0 -0.0000 1.0000 -0.0000 -0.0000 0 0 1.0000 0 0 0 0 1.0000 >> Ainv*A ans = 1.0000 -0.0000 0.0000 0.0000 0 1.0000 0 0.0000 0 0.0000 1.0000 -0.0000 0 0 0 1.0000 So that worked. Now lets look at that 4x2 matrix of maximal rank and compute its left-inverse >> B=[1 -1; 1 1; 1 -1; 1 1] B = 1 -1 1 1 1 -1 1 1 >> B1=[B I4] B1 = 1 -1 1 0 0 0 1 1 0 1 0 0 1 -1 0 0 1 0 1 1 0 0 0 1 >> B2=rref(B1) B2 = 1.0000 0 0 0 0.5000 0.5000 0 1.0000 0 0 -0.5000 0.5000 0 0 1.0000 0 -1.0000 0 0 0 0 1.0000 0 -1.0000 We want to use the left four columns (C). >> C=B2(1:4,3:6) C = 0 0 0.5000 0.5000 0 0 -0.5000 0.5000 1.0000 0 -1.0000 0 0 1.0000 0 -1.0000 Now we want a matrix D:=[I2|X] where X is *any* 2x2 matrix. >> I2=eye(2) I2 = 1 0 0 1 >> X=rand(2,2) X = 0.9501 0.6068 0.2311 0.4860 >> D=[I2 X] D = 1.0000 0 0.9501 0.6068 0 1.0000 0.2311 0.4860 The left-inverse of B should be the product D*C. >> Binv=D*C Binv = 0.9501 0.6068 -0.4501 -0.1068 0.2311 0.4860 -0.7311 0.0140 Now we check that the left-inverse works. >> Binv*B ans = 1 0 0 1 It worked. Now I said it would not be a right-inverse, because of something having to do with the rank of B being too small. Was I correct? >> B*Binv ans = 0.7190 0.1209 0.2810 -0.1209 1.1813 1.0928 -1.1813 -0.0928 0.7190 0.1209 0.2810 -0.1209 1.1813 1.0928 -1.1813 -0.0928 Yes I was. Now our true objective was to determine the B-coordinates of the vector b=[5; -7; 5; -7]. That is, we wanted to solve B*x=b. Multiplying: Binv*B*x=Binv*b, I2*x=Binv*b, and x=Binv*b. So we can use Binv to find the solution. >> Binv*[5;-7;5;-7] ans = -1.0000 -6.0000 >> x1=-1 x2=-6 is the solution.