Number of rows
Number of columns
First row
Second row
Third row

Welcome to Omni's column space calculator, where we'll study how to determine the column space of a matrix. The whole process is quite similar to how we calculate the rank of a matrix, but, if you're new to the topic, don't worry! We'll slowly go through all the theory and provide you with some examples. And we will not only find the column space, we'll give you the basis for the column space as well!

So sit back, pour yourself a nice cup of tea, and let's get to it!

What is a matrix?

The first time we learned about matrices was way back in primary school. Yes, that's right! You've known them all this time without even realizing it.

At first, we counted apples and bananas using our fingers. Then they taught us to add and subtract the numbers, and still fingers proved the superior tool for the task. If nothing else, they're very handy *wink wink*.

But then multiplication barged its way into the picture, and everything got a little more complicated. Even if we took off our shoes and started using our toes as well, it was often not enough. Those big-headed scientists... why did they invent so many numbers?

Still, there is this simple tool that came to the rescue - the multiplication table. And that was the first matrix of our lives! (Unless you'd already seen the movie by that time, which we don't recommend at that age.)

1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10· 10 20 30 40 50 60 70 80 90 100

A matrix is an array of elements (usually numbers) that has a set number of rows and columns. An example of a matrix would be:

A =
3 -1
| 0 2
1 -1

Moreover, we say that a matrix has cells, or boxes, into which we write the elements of our array. For example, matrix A above has the value 2 in the cell that is in the second row and the second column. The starting point here are 1-cell matrices, which are, for all intents and purposes, the same thing as real numbers.

As you can see, matrices came to be when a scientist decided that they needed to write a few numbers concisely and operate with the whole lot as a single object. As such, they naturally appear when dealing with:

We can look at matrices as an extension of the numbers as we know them. After all, the multiplication table above is just a simple example, but, in general, we can have any numbers we like in the cells: positive, negative, fractions, decimals. If you're feeling especially brainy, you can even have some complex numbers in there too.

The usefulness of matrices comes from the fact that they contain more information than a single value (i.e., they contain many of them). Arguably, it makes them fairly complicated objects, but it's still possible to define some basic operations on them, like, for example, addition and subtraction.

However, the possibilities don't end there! Matrices have an extremely rich structure. To illustrate this with an example, let us mention that to each such matrix, we can associate several important values, such as the determinant.

But let's not dilly-dally too much. After all, we're here for the column space of a matrix, and the column space we will see! We have the basic object well-defined and understood, so it's no use wasting another minute - we're ready to go further!

Column space of a matrix

Believe it or not, the column space has little to do with the distance between columns supporting a building. Rather than that, we will look at the columns of a matrix and understand them as vectors. As such, they will be elements of Euclidean space, and the column space of a matrix will be the subspace spanned by these vectors.

To have something to hold on to, recall the matrix from the above section:

3 -1
| 0 2
1 -1

It has two columns:

| 0


| 2

In a more concise notation, we can write them as [3, 0, 1] and [-1, 2, -1]. Note how a single column is also a matrix (as are all vectors, in fact). In this case, the array has three rows, which translates to the columns having three elements. As such, they are elements of three-dimensional Euclidean space.

The column space of a matrix A is, as we already mentioned, the span of the column vectors v₁, v₂, v₃,..., vₙ (where n is the number of columns in A), i.e., it is the space of all linear combinations of v₁, v₂, v₃,..., vₙ, which is the set of all vectors w of the form:

w = 𝛼₁*v₁ + 𝛼₂*v₂ + 𝛼₃*v₃ + ... + 𝛼ₙ*vₙ

where 𝛼₁, 𝛼₂, 𝛼₃,..., 𝛼ₙ are any numbers. In our case, this means the space of all vectors:

w = 𝛼*[3, 0, 1] + β*[-1, 2, -1]

with 𝛼 and β set arbitrarily.

In fact, we can also define the row space of a matrix: we simply repeat all of the above, but exchange column for row everywhere. However, we'll not do that, and it's not because we're lazy. No, really, it's not that. Seriously.

In mathematics, the column space of a matrix is more useful than the row space. This is because when we look at an array as a linear transformation in a multidimensional space (a combination of a translation and rotation), then its column space is the image (or range) of that transformation, i.e., the space of all vectors that we can get by multiplying by the array.

If the above paragraph made no sense whatsoever, don't fret. We can leave it at "It's useful to know the column space of a matrix." The rest is in the details.

So why do we need the column space calculator? After all, the space is defined by its columns. Why use some fancy tool for that?

It may happen that, although the column space of a matrix with 4 columns is defined by 4 column vectors, some of them are redundant. Here's where the definition of the basis for the column space comes into play.

Basis for the column space

As we've mentioned at the end of the previous section, it may happen that we don't need all of the matrix' columns to find the column space. What we mean by this is that we can obtain all the linear combinations of the vectors by using only a few of the columns.

We call this notion linear dependence. We say that v₁, v₂, v₃,..., vₙ are linearly independent vectors if the equation:


(here 0 is the vector with zeros in all coordinates) holds if and only if 𝛼₁ = 𝛼₂ = 𝛼₃ = ... = 𝛼ₙ = 0. Otherwise, we say that the vectors are linearly dependent.

In essence, linear dependence means that you can construct (at least) one of the vectors from the others. If that's the case, then it's redundant in defining the span, so why bother with it at all? We can just forget about it.

The basis of the space is the minimal set of vectors that span the space. With what we've seen above, this means that out of all the vectors at our disposal, we throw away all which we don't need so that we end up with a linearly independent set. This will be the basis.

"Alright, I get the idea, but how do I find the basis for the column space?" Well, how nice of you to ask! We were just about to answer that!

To find the basis for the column space of a matrix, we use so-called Gaussian elimination (or rather its improvement: the Gauss-Jordan elimination). This algorithm tries to eliminate (i.e., make 0) as many entries of the matrix as possible using elementary row operations. They are:

  1. Exchange two rows of the matrix.
  2. Multiply a row by a non-zero constant.
  3. Add to a row a non-zero multiple of a different row.

For instance, say that you have a matrix of size 3×2:

a₁ a₂
| b₁ b₂
c₁ c₂

If the first cell in the first row (in our case, a₁) is non-zero, then we add a suitable multiple of the top row to the other two rows, so that we obtain a matrix of the form:

a₁ a₂
| 0 s₂
0 t₂

Next, provided that s₂ is non-zero, we do something similar using the second row to transform the bottom one:

a₁ a₂
| 0 s₂
0 0

Lastly (and this is the extra step that differentiates the Gauss-Jordan elimination from the Gaussian one), we divide each row by the first non-zero number in that row. This gives an array in its so-called reduced row echelon form:

1 k₂
| 0 1
0 0

Also, note how you don't have to do the Gauss-Jordan elimination yourself - the column space calculator can do that for you! Just open up the advanced mode and choose "Yes" under "Show the reduced matrix?".

We call the first 1's in each row the leading ones. The last thing to do here is read off the columns which contain the leading ones. These are the ones that form the basis for the column space.

Phew, that was a lot of time spent on theory, wouldn't you say? It's high time we leave the letters and see some example which actually have numbers in them.


Example: using the column space calculator

Your dream has finally come true - you've bought yourself a drone! You can't wait to turn it on and fly around for hours. However, apparently, before you start playing around, you have to input three vectors that will define the drone's movements.

It will only be able to fly along these vectors, so it's better to do it well. The worst-case scenario is that they will define a low-dimensional space, which won't allow us to move freely. After all, the world we live in is three-dimensional, so restricting ourselves to 2 is like only being able to turn left.

You close your eyes, flip a coin, and choose three vectors at random: (1, 3, -2), (4, 7, 1), and (3, -1, 12). Note that each has three coordinates because that is the dimension of the world around us. Now, we'd better check if our choice was a good one, i.e., if their span is of dimension 3. Oh, how fortunate that we have the column space calculator for just this task!

Let's take a look at our tool. At the top, we have to choose the size of the matrix we're dealing with. We have three vectors (so we need three columns) with three coordinates each (so we need three rows). We choose these values under "Number of columns" and "Number of rows". This will trigger a symbolic picture of our chosen matrix to appear, with the notation that the column space calculator uses.

We need to input our three vectors as columns of the matrix. We see that the first one has cells denoted by a₁, b₁, and c₁. Looking back at our values, we input

a₁ = 1, b₁ = 3, c₁ = -2.

Similarly, for the other two columns we have

a₂ = 4, b₂ = 7, c₂ = 1,

a₃ = 3, b₃ = -1, c₃ = 12.

Once we input the last number, the column space calculator will spit out the answer: it will give us the dimension and the basis for the column space. But we're too ambitious to just take this spoiler of an answer for granted, aren't we? Let's grab a piece of paper and calculate the whole thing ourselves!

Example: how to calculate column space of a matrix by hand?

Let's continue our example. First of all, let's see how our matrix looks:

A =
1 4 3
| 3 7 -1
-2 1 12

According to the instruction from the above section, we now need to apply the Gauss-Jordan elimination to A. Since the first cell of the top row is non-zero, we can safely use it to eliminate the 3 and the -2 from the other two. Since 3 + (-3)*1 = 0 and -2 + 2*1 = 0, we add a multiple of (-3) and of 2 of the first row to the second and the third, respectively. This gives:

1 4 3
| 3+(-3)*1 7+(-3)*4 -1+(-3)*3
-2+2*1 1+2*4 12+2*3

which is:

1 4 3
| 0 -5 -10
0 9 18

Next, we'd like to use the -5 from the middle row to eliminate the 9 from the bottom one. Since 9 + (9/5) * (-5) = 0, we add a multiple of 9/5 of the second row to the third one:

1 4 3
| 0 -5 -10
0 9+(9/5)*(-5) 18+(9/5)*(-10)

which is:

1 4 3
| 0 -5 -10
0 0 0

Lastly, we divide each non-zero row of the matrix by its left-most number. In our case, this means that we divide the top row by 1 (which doesn't change a thing) and the middle one by -5:

1 4 3
| 0 -5 / (-5) -10 / (-5)
0 0 0
1 4 3
| 0 1 2
0 0 0

Our end matrix has leading ones in the first and the second column. This means that the column space is two-dimensional and that the two left-most columns of A generate this space. In our case, this means that the basis for the column space is: (1, 3, -2) and (4, 7, 1).

Well, that is precisely what we feared - the space is of lower dimension than the number of vectors. We can't have our drone flying only in two directions... It'd be best if we change one of the vectors slightly and check the whole thing again. Oh, how lucky we are that we have the column space calculator to save us time!

Maciej Kowalski, PhD candidate