Ma · Mathematics

How to Find the Dimension of the Kernel of a Square Matrix

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify the size

    An n × n matrix represents a linear map from an n-dimensional space to itself.

  2. 2. Find the rank

    Row-reduce the matrix and count its pivot columns.

  3. 3. Apply rank-nullity

    Subtract the rank from n: kernel dimension equals n minus rank.

  4. 4. Check special cases

    An invertible matrix has kernel dimension zero; the zero matrix has kernel dimension n.

A square matrix does not have one fixed kernel dimension. If AA is an n×nn \times n matrix, its kernel can have any dimension from 00 through nn, depending on the entries of AA.

The key formula is the rank–nullity theorem:

dim⁡(ker⁡A)+rank⁡(A)=n.\dim(\ker A)+\operatorname{rank}(A)=n.

Therefore,

dim⁡(ker⁡A)=n−rank⁡(A).\boxed{\dim(\ker A)=n-\operatorname{rank}(A)}.

Here, ker⁡A\ker A means the set of vectors xx satisfying Ax=0Ax=0. The dimension of the kernel is also called the nullity of AA.

Why the formula applies

An n×nn \times n matrix defines a linear transformation

TA:Fn→Fn,TA(x)=Ax,T_A:\mathbb{F}^n\to\mathbb{F}^n,\qquad T_A(x)=Ax,

where F\mathbb{F} is usually R\mathbb{R} or C\mathbb{C}. The kernel consists of all input vectors sent to the zero vector:

ker⁡(A)={x∈Fn:Ax=0}.\ker(A)=\{x\in\mathbb{F}^n:Ax=0\}.

The rank is the dimension of the image, or column space, of AA. Rank–nullity says that the dimensions of the kernel and image add up to the dimension of the domain. Since the domain is Fn\mathbb{F}^n, its dimension is nn.

The fact that the matrix is square only tells you that the domain and codomain have the same dimension. It does not tell you the rank.

How to calculate the dimension

For an n×nn \times n matrix AA:

  1. Row-reduce AA to echelon form or reduced row-echelon form.
  2. Count the pivots. This number is rank⁡(A)\operatorname{rank}(A).
  3. Subtract the rank from nn.

Equivalently, the number of free variables in the homogeneous system Ax=0Ax=0 is the dimension of the kernel. Each free variable produces one parameter in the general solution, and the corresponding parameter vectors form a basis for the kernel.

Worked example

Consider

A=(123246111).A=\begin{pmatrix} 1&2&3\\ 2&4&6\\ 1&1&1 \end{pmatrix}.

The second row is twice the first, so it contributes no new pivot. Row-reducing gives

(123246111)⟶(1230000−1−2)⟶(10−1012000).\begin{aligned} \begin{pmatrix} 1&2&3\\ 2&4&6\\ 1&1&1 \end{pmatrix} &\longrightarrow \begin{pmatrix} 1&2&3\\ 0&0&0\\ 0&-1&-2 \end{pmatrix}\\ &\longrightarrow \begin{pmatrix} 1&0&-1\\ 0&1&2\\ 0&0&0 \end{pmatrix}. \end{aligned}

There are two pivots, so rank⁡(A)=2\operatorname{rank}(A)=2. Because AA is a 3×33\times3 matrix,

dim⁡(ker⁡A)=3−2=1.\dim(\ker A)=3-2=1.

To see the kernel directly, solve Ax=0Ax=0. The reduced equations are

x−z=0,y+2z=0. x-z=0,\qquad y+2z=0.

Let z=tz=t. Then x=tx=t and y=−2ty=-2t, so

(xyz)=t(1−21).\begin{pmatrix}x\\y\\z\end{pmatrix} =t\begin{pmatrix}1\\-2\\1\end{pmatrix}.

Thus

ker⁡(A)=span⁡{(1−21)},\ker(A)=\operatorname{span}\left\{\begin{pmatrix}1\\-2\\1\end{pmatrix}\right\},

which confirms that the kernel has dimension 11.

Important special cases

For an n×nn\times n matrix, the following cases are useful:

Matrix propertyRankKernel dimension
Invertiblenn00
Singular with rank rrrrn−rn-r
Zero matrix00nn

If AA is invertible, the only solution to Ax=0Ax=0 is x=0x=0. The kernel is then {0}\{0\}, whose dimension is 00. This is sometimes described as a trivial kernel.

At the other extreme, if AA is the zero matrix, then Ax=0Ax=0 for every vector x∈Fnx\in\mathbb{F}^n. Consequently, the kernel is all of Fn\mathbb{F}^n and has dimension nn.

For example, a 4×44\times4 matrix of rank 33 has a one-dimensional kernel, while a 4×44\times4 matrix of rank 11 has a three-dimensional kernel.

Using the determinant carefully

For a square matrix,

det⁡(A)≠0\det(A)\ne0

is equivalent to invertibility. Therefore, a nonzero determinant immediately gives

dim⁡(ker⁡A)=0.\dim(\ker A)=0.

However, det⁡(A)=0\det(A)=0 only tells you that the kernel has positive dimension. It does not tell you exactly what that dimension is. You still need the rank, or an equivalent calculation, to distinguish between nullity 11, 22, and so on.

For instance, both a rank-two 3×33\times3 matrix and the zero 3×33\times3 matrix have determinant zero, but their kernel dimensions are respectively 11 and 33.

Common mistakes

Assuming every square matrix has a zero-dimensional kernel

Only invertible square matrices have a zero-dimensional kernel. A singular square matrix has at least one nonzero vector in its kernel.

Confusing the number of rows with the rank

An n×nn\times n matrix has nn rows, but some rows may be linearly dependent. The rank is the number of independent rows or columns, not simply the number of rows.

Counting nonzero rows before reducing

The rank is found from an echelon form, where the nonzero rows are counted after row reduction. Counting nonzero rows in the original matrix can give the wrong answer.

Forgetting the field

The dimension is normally taken over R\mathbb{R} or C\mathbb{C}. In some problems the matrix is considered over a finite field, such as F2\mathbb{F}_2. The same rank–nullity formula holds, but rank and kernel are computed using that field’s arithmetic.

Thinking the determinant gives the exact nullity

A zero determinant proves only that the nullity is at least 11. Row reduction is needed to determine its exact value.

References

  1. Linear Algebra Done Right, Sheldon Axler
  2. Introduction to Linear Algebra, Gilbert Strang

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.