Definitions

# Kernel (matrix)

In linear algebra, the kernel or null space (also nullspace) of a matrix A is the set of all vectors x for which Ax = 0. The null space of a matrix with n columns is a linear subspace of n-dimensional Euclidean space.

The nullspace (or kernel) of the matrix A is exactly the same thing as the nullspace (or kernel) of the linear mapping defined by the matrix-vector multiplication $mathbf\left\{x\right\} mapsto mathbf\left\{Ax\right\}$, that is, the set of vectors that map to the zero vector.

## Finite dimensional linear operator

In linear algebra, the null space (also nullspace) of a matrix A is the set of all vectors x for which Ax = 0. The null space of a matrix with n columns is a linear subspace of n-dimensional Euclidean space.

If we regard the matrix as a linear transformation, then the null space is precisely the kernel of the mapping (i.e. the set of vectors that map to zero). For this reason, the kernel of a linear transformation between abstract vector spaces is sometimes referred to as the null space of the transformation.

## Definition

The null space of an m × n matrix A is the set
$text\left\{Null\right\}\left(mathbf\left\{A\right\}\right) = left\left\{ textbf\left\{x\right\}intextbf\left\{R\right\}^n : mathbf\left\{A\right\}textbf\left\{x\right\} = textbf\left\{0\right\} right\right\}text\left\{,\right\}$
where 0 denotes the zero vector with m components. The matrix equation Ax = 0 is equivalent to a homogeneous system of linear equations:
mathbf\left\{A\right\}textbf\left\{x\right\}=textbf\left\{0\right\} ;;Leftrightarrow;; begin\left\{alignat\right\}\left\{6\right\}
a_{11} x_1 &&; + ;&& a_{12} x_2 &&; + cdots + ;&& a_{1n} x_n &&; = 0& a_{21} x_1 &&; + ;&& a_{22} x_2 &&; + cdots + ;&& a_{2n} x_n &&; = 0& vdots;;; && && vdots;;; && && vdots;;; && vdots,& a_{m1} x_1 &&; + ;&& a_{m2} x_2 &&; + cdots + ;&& a_{mn} x_n &&; = 0. & end{alignat} From this viewpoint, the null space of A is the same as the solution set to the homogeneous system.

## Example

Consider the matrix
$mathbf\left\{A\right\} = begin\left\{bmatrix\right\},,,2 & 3 & 5 -4 & 2 & 3end\left\{bmatrix\right\}.$
The null space of this matrix consists of all vectors (xyz) ∈ R3 for which
$begin\left\{bmatrix\right\},,,2 & 3 & 5 -4 & 2 & 3end\left\{bmatrix\right\}begin\left\{bmatrix\right\} x y zend\left\{bmatrix\right\} = begin\left\{bmatrix\right\} 0 0 end\left\{bmatrix\right\}text\left\{.\right\}$
This can be written as a homogeneous system of linear equations involving x, y, and z:
begin\left\{alignat\right\}\left\{7\right\}
2x &&; + ;&& 3y &&; + ;&& 5z &&; = ;&& 0
-4x &&; + ;&& 2y &&; + ;&& 3z &&; = ;&& 0. end{alignat} This can be written in matrix form as:
$begin\left\{bmatrix\right\},,,2 & 3 & 5 & 0 -4 & 2 & 3 & 0end\left\{bmatrix\right\}.$
Using Gauss-Jordan reduction, this reduces to:
$begin\left\{bmatrix\right\},,,1 & 0 & .0625 & 0 0 & 1 & 1.625 & 0end\left\{bmatrix\right\}.$
Rewriting yields:
begin\left\{alignat\right\}\left\{7\right\}
x = ;&& -.0625z
y = ;&& -1.625z. end{alignat} Now we can write the null space (solution to Ax = 0) in terms of z (which is our free variable), where z is scalar:
$z begin\left\{bmatrix\right\},,,-.0625 -1.625 1end\left\{bmatrix\right\}.$

The null space of A is precisely the set of solutions to these equations (in this case, a line through the origin in R3).

## Subspace properties

The null space of an m × n matrix is a subspace of Rn. That is, the set Null(A) has the following three properties:

1. Null(A) always contains the zero vector.
2. If x ∈ Null(A) and y ∈ Null(A), then x + y ∈ Null(A).
3. If x ∈ Null(A) and c is a scalar, then c x ∈ Null(A).

Here are the proofs:

1. A0 = 0.
2. If Ax = 0 and Ay = 0, then A(x + y) = Ax + Ay0 + 0 = 0.
3. If Ax = 0 and c is a scalar, then A(cx) = cAxc0 = 0.

## Basis

The null space of a matrix is not affected by elementary row operations. This makes it possible to use row reduction to find a basis for the null space:

Input An m × n matrix A.
Output A basis for the null space of A
# Use elementary row operations to put A in reduced row echelon form.
# Interpreting the reduced row echelon form as a homogeneous linear system, determine which of the variables x1x2, ..., xn are free. Write equations for the dependent variables in terms of the free variables.
# For each free variable xi, choose the vector in the null space for which xi = 1 and the remaining free variables are zero. The resulting collection of vectors is a basis for the null space of A.
For example, suppose that the reduced row echelon form of A is
left\left[begin\left\{alignat\right\}\left\{6\right\}
1 && 0 && -3 && 0 && 2 && -8 0 && 1 && 5 && 0 && -1 && 4 0 && 0 && 0 && 1 && 7 && -9 0 && ;;;;;0 && ;;;;;0 && ;;;;;0 && ;;;;;0 && ;;;;;0 end{alignat} ,right]text{.} Then x3, x5, and x6 are free, with
begin\left\{alignat\right\}\left\{7\right\}
x_1 &&; = ;&& 3x_3 &&; - ;&& 2x_5 &&; + ;&& 8x_6 & x_2 &&; = ;&& -5x_3 &&; + ;&& x_5 &&; - ;&& 4x_6 & x_4 &&; = ;&& &&; - ;&& 7x_5 &&; + ;&& 9x_6 &. end{alignat} Therefore, the three vectors
$begin\left\{array\right\}\left\{r\right\} x_3 rightarrow x_5 rightarrow x_6 rightarrow end\left\{array\right\}$

left[!! begin{array}{r} 3 -5 mathbf{1} 0 mathbf{0} mathbf{0} end{array} right],; left[!! begin{array}{r} -2 1 mathbf{0} -7 mathbf{1} mathbf{0} end{array} right],; left[!! begin{array}{r} 8 -4 mathbf{0} 9 mathbf{0} mathbf{1} end{array} right] are a basis for the null space of A.

## Relation to the row space

Let A be an m by n matrix (i.e., A has m rows and n columns). The product of A and the n-dimensional vector x can be written in terms of the dot product of vectors as follows:
$mathbf\left\{A\right\}textbf\left\{x\right\} = begin\left\{bmatrix\right\} textbf\left\{a\right\}_1 cdot textbf\left\{x\right\} textbf\left\{a\right\}_2 cdot textbf\left\{x\right\} vdots textbf\left\{a\right\}_m cdot textbf\left\{x\right\} end\left\{bmatrix\right\}text\left\{.\right\}$
Here a1, ..., am denote the rows of the matrix A. It follows that x is in the null space of A if and only if x is orthogonal (or perpendicular) to each of the row vectors of A.

The row space of a matrix A is the span of the row vectors of A. By the above reasoning, the null space of A is the orthogonal complement to the row space. That is, a vector x lies in the null space of A if and only if it is perpendicular to every vector in the row space of A.

The dimension of the row space of A is called the rank of A, and the dimension of null space of A is called the nullity of A. These quantities are related by the equation

$text\left\{rank\right\}\left(mathbf\left\{A\right\}\right) + text\left\{nullity\right\}\left(mathbf\left\{A\right\}\right) = ntext\left\{.\right\},$
The equation above is known as the rank-nullity theorem.

## Nonhomogeneous equations

The null space also plays a role in the solution to a nonhomogeneous system of linear equations:
mathbf\left\{A\right\}textbf\left\{x\right\}=textbf\left\{b\right\};;;;;;text\left\{or\right\};;;;;;begin\left\{alignat\right\}\left\{7\right\}
a_{11} x_1 &&; + ;&& a_{12} x_2 &&; + cdots + ;&& a_{1n} x_n &&; = ;&&& b_1 a_{21} x_1 &&; + ;&& a_{22} x_2 &&; + cdots + ;&& a_{2n} x_n &&; = ;&&& b_2 vdots;;; && && vdots;;; && && vdots;;; && &&& ;vdots a_{m1} x_1 &&; + ;&& a_{m2} x_2 &&; + cdots + ;&& a_{mn} x_n &&; = ;&&& b_m end{alignat} If u and v are two possible solutions to the above equation, then
$mathbf\left\{A\right\}\left(textbf\left\{u\right\}-textbf\left\{v\right\}\right) = mathbf\left\{A\right\}textbf\left\{u\right\} - mathbf\left\{A\right\}textbf\left\{v\right\} = textbf\left\{b\right\} - textbf\left\{b\right\} = textbf\left\{0\right\},$
Thus, the difference of any two solutions to the equation Ax = b lies in the null space of A.

It follows that any solution to the equation Ax = b can be expressed as the sum of a fixed solution v and an arbitrary element of the null space. That is, the solution set to the equation Ax = b is

$left\left\{ textbf\left\{v\right\}+textbf\left\{x\right\} ,:, textbf\left\{x\right\}intext\left\{Null\right\}\left(mathbf\left\{A\right\}\right), right\right\}text\left\{,\right\}$
where v is any fixed vector satisfying Av = b. Geometrically, this says that the solution set to Ax = b is the translation of the null space of A by the vector v. See also Fredholm alternative.

## Left null space

The left null space of a matrix A consists of all vectors x such that xTA = 0T, where T denotes the transpose of a column vector. The left null space of A is the same as the null space of AT. The left null space of A is the orthogonal complement to the column space of A, and is the cokernel of the associated linear transformation. The null space, the row space, the column space, and the left null space of A are the four fundamental subspaces associated to the matrix A.

## Null space of a transformation

If V and W are vector spaces, the null space (or kernel) of a linear transformation TV → W is the set of all vectors in V that map to zero:
$ker\left(T\right) = left\left\{textbf\left\{v\right\}in V : T\left(textbf\left\{v\right\}\right) = textbf\left\{0\right\} right\right\}text\left\{.\right\}$
If we represent the linear transformation by a matrix, then the kernel of the transformation is precisely the null space of the matrix.

## Numerical computation of null space

Algorithms based on row or column reduction, that is, Gaussian elimination, presented in introductory linear algebra textbooks and in the preceding sections of this article, are not suitable for a practical computation of the null space because of numerical accuracy problems in the presence of rounding errors. Namely, the computation may greatly amplify the rounding errors, which are inevitable in all but textbook examples on integers, and so give completely wrong results. For this reason, methods based on introductory linear algebra texts are generally not suitable for implementation in software; rather, one should consult contemporary numerical analysis sources for an algorithm like the one below, which does not amplify rounding errors unnecessarily.

A state-of-the-art approach is based on singular value decomposition (SVD). This approach can be also easily programmed using standard libraries, such as LAPACK. SVD of matrix A computes unitary matrices U and V and a rectangular diagonal matrix S of the same size as A with nonnegative diagonal entries, such that

$mathbf\left\{USV\right\} = mathbf\left\{A\right\}.$

Denote the columns of V by

$v_1,dots,v_n,$

the diagonal entries of S by

$s_1,dots,s_\left\{min\left\{m,n\right\}\right\},$

and put

$s_\left\{min\left\{m,n\right\}+1\right\}=cdots=s_n=0.$

(The numbers $s_i$ are called the singular values of A.) Then the columns $v_i$ of V such that the corresponding $s_i,=,0$ form an orthonormal basis of the nullspace of A. In a numerical computation, the singular values $s_i$ are taken to be zero when they are less than some small tolerance. In the Matlab function null, the tolerance is taken to be

$max\left\{m,n\right\} max \left\{s_i\right\} varepsilon,$

where $varepsilon$ is the machine epsilon of the computer, that is, the smallest number such that in the floating point arithmetics of the computer, $1,+,varepsilon>1$. For the IEEE 64 bit floating point format, $varepsilon,approx, 2.2cdot 10^\left\{-16\right\}$.

Computation of the SVD of a matrix generally costs about the same as several matrix-matrix multiplications with matrices of the same size, when state-of-the art implementation (accurate up to rounding precision) is used, such as in LAPACK. This is true even if, in theory, the SVD cannot be computed by a finite number of operations, so an iterative method with stopping tolerances based on rounding precision must be employed. The cost of the SVD approach is several times higher than computing the null space by reduction, but it should be acceptable whenever reliability is important. It is also possible to compute the null space by the QR decomposition, with the numerical stability and the cost both being between those of the SVD and the reduction approaches. The computation of a null space basis using the QR decomposition is explained in more detail below.

Let A be a mxn matrix with m < n. Using the QR factorization of $mathbf\left\{A\right\}^T$, we can find a matrix such that

$mathbf\left\{A\right\}^T , mathbf\left\{P\right\} = mathbf\left\{Q\right\} , mathbf\left\{R\right\} = \left[mathbf\left\{Q\right\}_1 ; mathbf\left\{Q\right\}_2\right] , mathbf\left\{R\right\}$,
where P is a permutation matrix, Q is nxn and R is nxm. Matrix $mathbf\left\{Q\right\}_1$ is nxm and consists of the first m columns of Q. Matrix $mathbf\left\{Q\right\}_2$ is nx(n-m) and is made up of Q 's last n-m columns. Since $mathbf\left\{A\right\} , mathbf\left\{Q\right\}_2 = 0$, the columns of $mathbf\left\{Q\right\}_2$ span the null space of A.