2.3 Applications to Systems
In-class demo by Russell Blyth.
> restart: with(linalg): with(plots): with(plottools):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
Warning, the name arrow has been redefined
Some computations
We start with a random 4 x 6 matrix.
> A := randmatrix(4,6,entries=rand(-5..5)); rank(A);
Does the vector (3,7,-5,3,2,-10) belong to the row space of A?
We need to solve the following system:
> B:=vector(6,[3,7,-5,3,2,-10]);
> k1*row(A,1)+k2*row(A,2)+k3*row(A,3)+k4*row(A,4)=evalm(B);
We get the augmented matrix as follows:
> AAug := augment(transpose(A),B);
Put in reduced echelon form:
> AAugGJ := gaussjord(AAug);
We see that the system is inconsistent, so B does not lie in the row space of A.
Now let's find a basis for the row space of A - find the reduced row echelon form for A itself:
> AGJ := gaussjord(A);
Explicitly check that each original row of A is the appropriate linear combination of the rows of AGJ:
>
row(A,1);
evalm(A[1,1]*row(AGJ,1)+A[1,2]*row(AGJ,2)+A[1,3]*row(AGJ,3)+A[1,4]*row(AGJ,4));
>
row(A,2);
evalm(A[2,1]*row(AGJ,1)+A[2,2]*row(AGJ,2)+A[2,3]*row(AGJ,3)+A[2,4]*row(AGJ,4));
>
row(A,3);
evalm(A[3,1]*row(AGJ,1)+A[3,2]*row(AGJ,2)+A[3,3]*row(AGJ,3)+A[3,4]*row(AGJ,4));
>
row(A,4);
evalm(A[4,1]*row(AGJ,1)+A[4,2]*row(AGJ,2)+A[4,3]*row(AGJ,3)+A[4,4]*row(AGJ,4));
Check again to see why B is not in the row space, using the coefficients that would make the first four entries correct:
>
evalm(B);
evalm(B[1]*row(AGJ,1)+B[2]*row(AGJ,2)+B[3]*row(AGJ,3)+B[4]*row(AGJ,4));
Now let's find a basis for the column space of A
>
At := transpose(A);
AtGJ := gaussjord(At);
rank(At);
Now look at the null space of A. Actually, we get a better basis if we use the reduced row echelon form:
> evalm(AGJ);
>
BasisNS1 := nullspace(A);
BasisNS2 := nullspace(AGJ);
>
In either case the null space has dimension two, that is, nullity(A)=2. The second basis clearly shows the basis elements corresponding to the nonpivot columns of AGJ. It is also clear that these two vectors are independent. Check that any linear combination of the basis vectors lies in the null space:
>
x := c1*BasisNS2[1]+c2*BasisNS2[2];
evalm(A &* x);
>
>
Finally, note that rank(A) + nullity(A) = 4 + 2 = 6 = # columns of A.