# NullSpace

NullSpace[m]

gives a list of vectors that forms a basis for the null space of the matrix m.

# Details and Options • NullSpace works on both numerical and symbolic matrices.
• The following options can be given:
•  Method Automatic method to use Modulus 0 integer modulus to use Tolerance Automatic numerical tolerance to use ZeroTest Automatic function to test whether matrix elements should be considered to be zero
• NullSpace[m,Modulus->n] finds null spaces for integer matrices modulo n.
• NullSpace[m,ZeroTest->test] evaluates test[m[[i,j]]] to determine whether matrix elements are zero.
• Possible settings for the Method option include "CofactorExpansion", "DivisionFreeRowReduction", and "OneStepRowReduction". The default setting of Automatic switches among these methods depending on the matrix given.

# Examples

open allclose all

## Basic Examples(3)

Find the null space of a 3×3 matrix:

The action of m on the vector is the zero vector:

The null space of a symbolic matrix:

Verify that multiplication by m gives the zero vector:

Compute the null space of a rectangular matrix:

Verify that both vectors returned are in the null space:

## Scope(11)

### Basic Uses(7)

Null space of a machine-precision matrix:

Null space of a complex matrix:

Null space of an exact matrix:

Null space of an arbitrary-precision matrix:

Find the null space symbolically:

Null space of non-square matrices:

The null space of a large numerical matrix is computed efficiently:

### Special Matrices(4)

Null space of a sparse matrix:

Null space of structured matrices:

always has an empty null space:

The null space of IdentityMatrix[{m,n}] is nonempty:

Compute the null space for HilbertMatrix:

## Options(1)

### Modulus(1)

m is a 3×3 random matrix of integers between 0 and 4:

Use arithmetic modulo 5 to compute the null space:

The vector is in the null space modulo 5:

## Applications(12)

### Spans and Linear Independence(5)

The following three vectors are not linearly independent:

Therefore the null space of the matrix whose rows are the vectors is nonempty:

The following three vectors are linearly independent:

Therefore the null space of the matrix whose rows are the vectors is empty:

Determine if the following vectors are linearly independent or not:

The matrix formed from the vectors has a nonempty null space, so they are not linearly independent:

Find the dimension of the column space of the following matrix:

Since the null space is empty, the dimension of the column space equals the number of columns:

Find the dimension of the subspace spanned by the following vectors:

Since the matrix rank of the matrix formed by the vectors is three, that is the dimension of the subspace:

### Equation Solving and Invertibility(7)

Determine if the following system of equations has a unique solution:

Rewrite the system in matrix form:

The coefficient matrix has an empty null space, so the system has a unique solution:

Verify the result using Solve: is a 3×3 singular matrix with a nonempty null space:

Find a solution for :

All solutions are given by , where is any vector in the null space:

Determine if the following matrix has an inverse:

The null space is less than the dimension of the matrix, so it is not invertible:

Verify the result using Inverse: Determine if the following matrix has a nonzero determinant:

Since the null space is empty, its determinant must be nonzero:

Confirm the result using Det: is an eigenvalue of if the null space of is nontrivial. A matrix is deficient if it has an eigenvalue whose multiplicity is greater than the dimension of the null space of . Show that is an eigenvalue for the following matrix :

Confirm the result using Eigenvalues:

The matrix is deficient because 2 appears twice, but eigenspace is one-dimensional:

Confirm the result with Eigensystem, which indicates deficiency by padding the eigenvector list with zeros:

Find a basis for the eigenvectors of the following matrix:

First, compute the eigenvalues:

For each unique eigenvalue, find the null space:

Combine the two one-dimensional spaces and one two-dimensional space using Join and Apply:

Confirm the result using Eigenvectors:

Estimate the fraction of random 10×10 01 matrix that are invertible:

## Properties & Relations(8)

For any linear combination of elements of the null space of , gives zero:

By the rank-nullity theorem, the dimension of the null space is the number of columns minus MatrixRank[m]:

For a square matrix, m has a trivial null space if and only if Det[m]!=0:

For a square matrix, m has a trivial null space if and only if m has full rank:

For a square matrix, m has a trivial null space if and only if m has an inverse: For a square matrix, m has a trivial null space iff LinearSolve[m,b] has a solution for a generic b:

The dimension of the null space of a matrix is known as its nullity :

The nullity of a product of two square matrices satisfies Silvester's law of nullity :

In this case, the product in the opposite order has a different nullity:

But it still satisfies the law:

The null space of a square matrix m can be computed using RowReduce:

Do row reduction on the matrix augmented with the identity matrix:

The augmented half of a row is in the null space if the row has a leading 1 in the augmented half:

Get null vectors using NullSpace:

Even though the vectors are not the same, they are a basis for the same space: