`> `
**with(linalg):**

`> `
**M := matrix([[5, 1, 3, 2, 1], [1, 0, 1, 1, 0], [7, 2, 3, 1, 2], [-1, -1, 1, 2, -1]]);**

`> `
**rowspace(M);#This finds a basis for the row space. Hence also the row rank of the matrix. **

`> `
**#We may find the rank directly by using**

`> `
**rank(M);**

`> `
**colspace(M);#This finds a basis for the column space. Hence also the column rank of the matrix. **

`> `
**#The function linsolve(A, b) finds the vector x which satisfies the matrix equation A x = b. If A has n rows and m columns, then vectdim(b) must be n and vectdim(x) will be m, if a solution exists. If A x = b has no solution, then the null sequence NULL is returned. If A x = b has many solutions, then the result will use global names (see below) to describe the family of solutions parametrically. **

`> `
**linsolve(M, vector( [0,0, 0, 0]));**

`> `
**#The answer above is a bit hard to read. One may want to use Kernel(A) that gives a basis for the solutions of the homogeneous system.**

`> `
**kernel(M);**

`> `
**#One may also wish to find first the reduced echelon form. This may be obtained by**

`> `
**gaussjord(M);**

`> `
**linsolve(M, vector([1, 0, 0, 0]));#We get no result. Meaning there is no solution.**

`> `
**linsolve(M, vector([3, 1, 3, 1]));**

`> `
**#********************************

`> `
**#Here is how we may solve exercise 1 in Assignment 5. Recall that one wants to compute the intersection of the subspaces W1 = Span {(1, 1, 0, 0), (0, 1, 1, -1)}, W2 = Span{(3, 2, 1, 0), (4, 4, 2, -1)}. We first express W1 and W2 as solutions to systems of linear equations. For W1 we look for solutions of the linear equations defined by the generators of W1. (The same with W2). Then W1 will be the solutions of this system. (Why does that work?!!) In pratctice we may do:**

`> `
**M1:= matrix([[1, 1, 0, 0], [0, 1, 1, -1]]);**

`> `
**K1:=kernel(M1);**

`> `
**#Then W1 is the solutions of the system defined by those vectors. Lets verify that. Let**

`> `
**N1:= matrix([[1, -1, 1, 0],[-1, 1, 0, 1]]);**

`> `
**multiply(N1, vector([1, 1, 0, 0]));**

`> `
**multiply(N1, vector([0, 1, 1, -1]));**

`> `
**#We continue with the calculation. We let**

`> `
**M2:= matrix([[3, 2, 1, 0], [4, 4, 2, -1]]);**

`> `
**K2:=kernel(M2);**

`> `
**#Then W2 is the solutions of the system defined by those vectors. We create a matrix whose rows are the rows of kernel(M1) and kernel(M2);**

`> `

`> `
**M3:=matrix([K1[1], K1[2], K2[1], K2[2]]);**

`> `
**kernel(M3);**

`> `
**#That is the vector whose span is the intersection of W1 and W2.**

`> `
**#*******************************

`> `
**#Similarly, exercise 2 can be verified (not solved !!) as follows:**

`> `
**A:= matrix([[5, 1, 3, 2, 1], [1, 0, 1, 1, 0], [7, 2, 3, 1, 2], [-1, -1, 1, 2, -1]]);**

`> `
**rank(A);gaussjord(A);**

`> `
**linsolve(A, vector([1, 0, 0, 0]));**

`> `
**linsolve(A, vector([0, 1, 0, 0]));**

`> `
**linsolve(A, vector([0, 0, 1, 0]));**

`> `
**B:=matrix([row(A,1..4), vector([1, 0, 0, -1, 0])]);**

`> `
**kernel(B);**

`> `