# Null Space Calculator

Welcome to Omni's **null space calculator**, where we'll study the topic of **how to find the null space of a matrix**. In essence, it means finding all the vectors that are **mapped to zero** by the given array $A$. This notion comes from treating $A$ as a linear map, and as such, the null space of a matrix is also often called **the kernel of that matrix**. In general, it will have infinitely many elements, so "*finding all the vectors*" basically means determining **the basis for the null space** (whose dimension we call the nullity of the matrix).

So sit back, bring along a cup of coffee, and **let's get to it**!

## What is a matrix?

**A long time ago in a galaxy far, far away...** No, wait! This doesn't seem right for us talking about what a matrix is. **Let's try again.**

**Several years ago, in the virtual world that we call reality**, we used to go to primary school. And it was then when we **first saw what a matrix is**. That's right; they had taught us about these high-school-algebra objects long before we learned the most memorable information from our teenage education - that **mitochondria are the powerhouses of cells**.

We begin our mathematical education with **learning numbers** by counting dogs and kitties. Soon enough, the thing gets more complicated, and they tell us to add and subtract those numbers. **But it's not that bad**; we have our fingers to help us with that.

However, to our wonder, it appears that **mathematics doesn't end there**. The next topic they introduce is **multiplication**, and that one is trickier. Don't get us wrong; **the operation makes sense**. After all, if there are five trees and each has seven apples, then it's useful to know that, in total, we have thirty-five apples. The problem is that **we don't have that many fingers**! How do we grasp this if our most reliable tool failed us?

**That's where matrices come in!** Well, in a sense, at least.

To help us with our multiplication (and division), we are shown what is called **a multiplication table** - some rows and columns with numbers in it. **Precisely like a matrix.**

·1 | ·2 | ·3 | ·4 | ·5 | ·6 | ·7 | ·8 | ·9 | ·10 | |
---|---|---|---|---|---|---|---|---|---|---|

1· | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

2· | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |

3· | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 |

4· | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 |

5· | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 |

6· | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 |

7· | 7 | 14 | 21 | 28 | 35 | 42 | 49 | 56 | 63 | 70 |

8· | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 |

9· | 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) **with a set number of rows and columns.** It is the main object of studies in linear algebra. An example of a matrix would be:

Moreover, we say that a matrix has **cells**, or **boxes**, into which we write the elements of our array. For example, the 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 the same thing as real numbers for all intents and purposes.

As you can see, matrices came to be when scientists 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:

- Systems of equations, especially with Cramer's rule (Chek our dedicated Cramer's rule calculator to see how it works in practice);
- Vectors and vector spaces;
- 3-dimensional geometry (e.g., the dot product and the cross product);
- Linear transformations (translation and rotation); and
- Graph theory and discrete mathematics.

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, and 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, which you can quickly evaluate using our matrix determinant calculator.

But it's just **the beginning of our journey**! We're here to learn how to find the null space of a matrix, and the word "*null*" hasn't even appeared yet. So let's not waste another minute and jump to the next section to learn **what it is that we're trying to calculate**.

## Null space/kernel of a matrix

As mentioned in the above section, we can view a matrix as **a linear map** (a translation or rotation) in a Euclidean space, i.e., the one-dimensional line, the two-dimensional plane, the three-dimensional space, or the four-dimensional hyperspace (the list goes on, but **we're focusing here on arrays of size up to** $4\times4$). In other words, the elements of that space are **vectors with one, two, three, or four coordinates**, respectively.

**The null space** or **the kernel of a matrix** is the subspace consisting of all the vectors mapped to the zero vector of that space. In mathematical notation, for an array $A$ with $n$ columns, this means all the vectors $\boldsymbol{v} = (v_1, v_2,\ldots, v_n)$ for which

$A\cdot\boldsymbol{v} = \boldsymbol{0}$,

where $\cdot$ here denotes matrix multiplication, and $\boldsymbol{0}$ is the zero vector, i.e., $\boldsymbol{0} = (0,0,...,0)$ with $n$ coordinates.

Observe that:

**The zero vector is always in the null space.**After all, whatever matrix we have, we'll get zero if we multiply it by zero.- In general,
**the kernel of a matrix can have infinitely many elements**. In fact, if $(v_1, v_2,\ldots, v_n)$ is in the null space, then so is $(av_1, av_2,\ldots, av_n)$ for any real number $a$. - You can extend Point 2. above further: if $\boldsymbol{x_1}$, $\boldsymbol{x_2}$,…, $\boldsymbol{x_k}$ all belong to the null space, then
**so does every linear combination of these vectors**. - The above points boil down to the fact that
**the null space of a matrix is a vector subspace**of the big Euclidean space. Therefore, if we want to study it in-depth, it'd be best to be able to describe what its elements look like in general. That's where the notion of**a basis**for the null space comes into play - more on that in the next section.

Alright, so the null space of a matrix is just **a subspace of elements that satisfy some formula**. Fair enough. **But how is it useful?** What does it tell us about the matrix itself? Well, **how fortunate of you to ask**, we were just getting to that!

## Nullity of a matrix

**The nullity of a matrix** is the dimension of its null space. Simple as that, no strings attached. But although the nullity definition takes one line, let's try to go one step further and actually **try to understand it**.

Generally, **the dimension of a space is equal to the size of its basis**. Yup, yet another definition that uses words and notions that are not too easy themselves. Well, it looks like **we'll have to go deeper** than that.

Let $\boldsymbol{x_1}$, $\boldsymbol{x_2}$,…, $\boldsymbol{x_k}$ be a collection of vectors from the same space. Then any vector $\boldsymbol{w}$ of the form:

$\boldsymbol{w} = \alpha_1\!\cdot\!\boldsymbol{x_1} + \alpha_2\!\cdot\!\boldsymbol{x_2} + \alpha_3\!\cdot\!\boldsymbol{x_3} + \ldots + \alpha_k\!\cdot\!\boldsymbol{x_k}$,

where $\alpha_1, \alpha_2, \alpha_3, \ldots, \alpha_k$ are arbitrary real numbers is called **a linear combination** of the vectors $\boldsymbol{x_1}$, $\boldsymbol{x_2}$, $\boldsymbol{x_3}$,…, $\boldsymbol{x_k}$. The space of all such vectors $\boldsymbol{w}$ is called **the span** of $\boldsymbol{x_1}$, $\boldsymbol{x_2}$, $\boldsymbol{x_3}$,…, $\boldsymbol{x_k}$.

At times, it may happen that among $\boldsymbol{x_1}$, $\boldsymbol{x_2}$,…, $\boldsymbol{x_k}$, **some of the vectors are redundant**. This means that you can construct all elements of the space from only a part of the $k$ vectors given. In that case, we say that $\boldsymbol{x_1}$, $\boldsymbol{x_2}$,…, $\boldsymbol{x_k}$ are **linearly dependent**. Otherwise, we call them **linearly independent**. (Please note that here, we mention all these notions briefly. For a more in-depth study, be sure to check out linear independence calculator).

Any linearly independent vector set that generates a space is called its **basis**. In particular, **the basis for the null space of a matrix is a collection of vectors that generate that matrix's kernel**. Therefore, coming back to the nullity definition at the beginning of this section, we can reformulate it as follows:

💡 The nullity of a matrix is the number of linearly independent vectors that generate the null space of that matrix.

All in all, given a matrix (i.e., a linear map) $A$ that has $n$ columns (i.e., acts on elements of an $n$-dimensional space), **it is beneficial to know which elements are vanishing** (that is, are mapped to zero) **under** $A$. In other words, to know the null space of $A$. For instance, if $A$ has, say, $4$ columns and the nullity of that matrix is $3$, then we know that $A$ "*kills*" three dimensions along the way, and **the fewer dimensions there are, the easier the calculations**.

A matrix's nullity is connected to its rank by the following theorem, called simply **the rank-nullity theorem**.

💡 For a matrix $A$, the sum of its rank and its nullity is equal to the number of columns in $A$.

In other words, **if you know a matrix' nullity, then you know its rank** and vice versa. For more information on that topic, be sure to check out matrix rank calculator.

Phew, **it's been quite a few definitions**, don't you think? Fortunately, the nullity definition was the last one for today, and it made us more than ready to finally **learn how to find the null space of a matrix**. Let's waste not a second longer and see what we came here for!

## How to find the null space of a matrix?

When we're trying to determine the kernel and nullity of a matrix, the primary tool to use is **the Gauss-Jordan elimination**. It is a handy algorithm that transforms a given matrix into its reduced row echelon form, which is **so much easier to work with**.

The idea is to "*kill*" (i.e., make zero) as many entries of the matrix as possible using the so-called **elementary row operations**. These are:

- Exchanging two rows of the matrix;
- Multiplying a row by a non-zero constant; and
- Adding to a row a non-zero multiple of a different row.

The crucial property here is that **the initial matrix and its reduced row echelon form have the same rank and null space**. Note that **our null space calculator can show you how the input array looks after the Gauss-Jordan elimination** due to its usefulness. It's enough to go into the advanced mode and choose the right option under "*Show the reduced matrix?*".

For example, suppose we have a matrix with three rows and four columns.

Then, the first step in the Gauss-Jordan elimination is to **take the first cell in the first row**, i.e., $a_1$ (provided that it is non-zero), and use the elementary row operations to *kill* the entries below it. This means that we add a suitable multiple of the top row to the other two so that we obtain a matrix of the form:

Next, **we do something similar with the middle row**. We take $s_2$ (as long as it is non-zero) and use it to *kill* the entries below it. As a result, we get an array of the form:

Now comes the distinction between the Gauss-Jordan elimination and its simplified form, the Gaussian elimination: **we divide each row by the first non-zero entry in that row**. This gives:

And that's where we often end the algorithm, like, for instance, when we're looking for the column space of a matrix. In fact, for our purposes, **we can already read off some useful information** from the array we have.

🔎 Don't know what a column space is? No worries - head to Omni's column space calculator for a brief introduction to the topic!

The ones that appear as the first non-zero elements in each row are called **the leading ones**. In our example, we have them in the first, second, and third columns out of four. **The number of columns that do not contain a leading one is equal to the nullity of that matrix.** As a bonus, if we recall the above section and the nullity definition, we get that **the number of columns with a leading one is the rank of our matrix**.

However, to find the basis for the null space, **we'll modify the array some more**. Again, we use elementary row operations, but this time **we go from the bottom upwards**. Firstly, we use the $1$ in the third row to *kill* the entries above it.

Next, we do the same with the $1$ in the middle row to *kill* the cell above it.

**This, finally, is the matrix that will give us the basis for the null space.** To determine it in detail, we follow a few simple rules.

- If the matrix has no columns without a leading one,
**the null space is trivial**, i.e., it is of dimension $0$ and contains only the zero vector. - If the array contains a column with nothing but zeros, say, the $k$-th one, then
**the elementary vector**$\boldsymbol{e_k}$ is an element of the basis, i.e., the vector with $1$ in the $k$-th coordinate and zeros otherwise. - If a column, say, the $k$-th one, doesn't have a leading one and has at least one non-zero entry, then
**we construct a vector**$\boldsymbol{v}$ of the basis by taking all the non-zero cells of that column and putting their opposites (i.e., the value times $-1$) in the corresponding coordinates of $\boldsymbol{v}$. Moreover, we put $1$ in its $k$-th coordinate and zeros in the remaining ones. Observe that**this is what happens in the example above**: from the matrix that we've obtained, we know that the vector $(u_4, m_4, r_4, 1)$ is in the basis for the null space. **No other vectors belong to the basis.**

Alright, we admit that although informative, this section was no walk in the park. But no worries - **we hereby declare the end of theory**! (Of course, for the rest of this article, not forever.) We've spent so much time on it that **we deserve an excellent example** with numbers rather than letters, don't you think?

## Example: using the null space calculator

Say that **you're sitting through the very last class before the winter break**, and it just so happens that it's **the linear algebra class**. You can already see yourself running home to start packing for **the mountain trip you have organized for the weekend**. Oh, you just can't wait to go skiing, but first, you have to endure this last half an hour of mathematics.

You can see the teacher at the edge of dozing off. Apparently, **not only could you use the break from school**. However, they can't just end the class there and then, so they decide to **give you one last task**, and whoever finishes it is free to leave. So the only thing separating you from the winter break is **finding the null space of the following matrix**:

Oh, **how lucky we are that Omni is here** with the null space calculator! Let's see how fast it will give us the answer to our problem.

The array we have at hand has **two rows and four columns**, so we begin by choosing the correct options under "*Number of rows*" and "*Number of columns*". **This will trigger a symbolic matrix to appear** with its cells denoted with symbols used under it. We see that the first row has entries $a_1$, $a_2$, $a_3$, and $a_4$, so looking back at the array $A$, we input

$a_1 = 2$, $a_2 = -4$, $a_3 = 8$, and $a_4 = 2$.

Similarly, the second row has $b$-s in it, so we get

$b_1 = 6$, $b_2 = -12$, $b_3 = 3$, and $b_4 = 13$.

Once we input the last number, **the null space calculator will spit out the answer**. However, let's not get ahead of ourselves and take the time to grab a piece of paper and **calculate the whole thing ourselves**.

We begin by **applying the Gauss-Jordan elimination** to $A$. It has only two rows, so it shouldn't be too difficult.

We want to use the first element in the first row, i.e., the $2$ to *kill* the entry below it. Since $6 + (-3)\cdot2 = 0$, we add a multiple of $-3$ of the top row to the bottom one. This gives:

Next, just as Gauss-Jordan elimination states, **we divide each row by the first non-zero entry**. In our case, this translates to dividing the first row by $2$ and the second by $-21$.