Octave for Chapters 5-6

The templates in this section provide sample Octave code for finding subspaces associated with matrices as well as the kernel and image of a linear transformation. You can access our code through the link at the bottom of each template. Feel free to modify the code and experiment to learn more!

You can write your own code using Octave software or online Octave cells. To access Octave cells online, go to the Sage Math Cell Webpage, select OCTAVE as the language, enter your code, and press EVALUATE.

To ”save” or share your online code, click on the Share button, select Permalink, then copy the address directly from the browser window. You can store this link to access your work later or share this link with others. You will need to get a new Permalink every time you modify the code.

Octave Tutorial

Column Space of a Matrix (Image of a Linear Transformation)

Recall that the column space of a matrix is the span of the columns of the matrix. In Subspaces of Associated with Matrices we introduced the following procedure for finding the column space.

We will implement this procedure in Octave.

When you study linear transformations, you will learn that the column space of a matrix is the image of the linear transformation induced by the matrix. So, Template temp:colSpace can be used to find the image of a linear transformation.

Null Space of a Matrix (Kernel of a Linear Transformation)

Recall the following definition of the null space of a matrix from Subspaces of Associated with Matrices.

We can use the reduced row-echelon form (rref function) to find the null space, as shown in Example ex:dimnull of Subspaces of Associated with Matrices. We will omit the details here.

We can also use the null function to find a basis for the null space of a matrix. This function finds an orthonormal basis for the null space. An orthonormal set of vectors consists of unit vectors that are pairwise orthogonal. We demonstrate the null function below.

The basis for the null space we found in Template temp:nullSpace looks different from what you would have found by hand using the rref function. In Problem prob_oct_Rn1 you will verify that in Template temp:nullSpace spans the null space of .

If you are familiar with linear transformations, you may recall that the kernel of a linear transformation induced by a matrix is the null space of the matrix. The null function gives us a way to compute the kernel.

Octave Exercises

For Problems prb:5.1 and prb:5.3, use Octave to find , , and their respective dimensions. Verify that the Rank-Nullity Theorem (th:matrixranknullity) holds for .

Let
Let
Let Find the dimension of and determine a basis.
Find the rank of the following matrix. Also find a basis for the row and column spaces.

% Find a basis for row(A) and column(A)
 
A=[1 3 0 -2 0 3;  
3 9 1 -7 0 8;  
1 3 1 -3 1 -1;  
1 3 -1 -1 -2 10]  
% We can answer all of these questions by finding rref(A).  
rref(A)
Find the rank of the following matrix. Also find a basis for the row and column spaces.

Find the rank of the following matrix. Also find a basis for the row and column spaces.

In Template temp:nullSpace we used the null function to find a basis for the null space of matrix
(a)
Verify that the product of with of each element of the basis is .
(b)
Use to find another basis for the null space.
(c)
The basis we found using the null function and the basis you found in part (b) look very different. How do we know that they span the same subspace?
Use some of our earlier matrices, together with their null spaces, for the following experiment.
  • Given a matrix, find the product of the matrix with some vector in its null space. What do you observe? Why does this make sense?
  • Formulate a conjecture about the relationship between the rows of a matrix and the elements of its null space.
  • Prove your conjecture.

Bibliography

Matrices used in Problems prb:5.1-prb:5.34 come from the end of Chapter 4 of Ken Kuttler’s A First Course in Linear Algebra. (CC-BY)

Ken Kuttler, A First Course in Linear Algebra, Lyryx 2017, Open Edition, pp. 227–232.

2024-09-28 16:02:52