RangeSpace[a]
gives a minimal list of vectors that form a basis for the range space of the matrix a.
RangeSpace
RangeSpace[a]
gives a minimal list of vectors that form a basis for the range space of the matrix a.
Details and Options
- RangeSpace is also known as the range, image, im or column space of a linear transformation.
- The range space of an
matrix a is the linear space of values, i.e.
, where
is the field of constants, typically the reals
or complexes
. - The returned list of vectors is a basis for the range space
. - The dimension of the range space is the length of the returned list of vectors.
- For an
matrix, Length[RangeSpace[a]]+Length[NullSpace[a]]==n, also known as the rank–nullity theorem. » - RangeSpace works on both numerical and symbolic rectangular matrices.
- The row space
can be computed through RangeSpace[a]. - 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 - For approximate numeric matrices, SingularValueDecomposition is used, and Tolerance controls the singular values that are taken to be zero.
- For exact numeric and symbolic matrices, RowReduce is used, and Method, Modulus and ZeroTest only apply to this case.
- For symbolic matrices, RangeSpace will treat all unknowns as having generic values. The result can be incorrect for special cases. »
- RangeSpace[m,Modulus->n] finds the range space of rational matrices modulo the integer n. If n is zero, ordinary arithmetic is used. If n is not prime, the computation may fail. »
- RangeSpace[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".
Examples
open all close allBasic Examples (3)
Find the range space of a square matrix:
RangeSpace[(| | | |
| - | - | - |
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |)]Find the range space of a rectangular matrix:
RangeSpace[(| | | | | | |
| - | - | - | - | - | - |
| 1 | 2 | 3 | 1 | 0 | 0 |
| 4 | 5 | 6 | 0 | 1 | 0 |
| 7 | 8 | 9 | 0 | 0 | 1 |)]Find the range space of a matrix with symbolic entries:
RangeSpace[(| | | |
| - | - | - |
| 3 | 1 | a |
| 2 | 1 | b |)]Scope (13)
Basic Uses (8)
Range space of a matrix of rationals:
RangeSpace[{{3 / 2, 19 / 4, -16 / 5}, {-17 / 10, 67 / 10, -93 / 10}, {49 / 10, -865 / 100, 154 / 10}}]Range space of a machine-precision matrix:
RangeSpace[{{1.5, 4.75, -3.2}, {-1.7, 6.7, -9.3}, {4.9, -8.65, 15.4}}]Range space of a complex matrix:
RangeSpace[{{1. + I, 2, 3 - 2 I}, {0, 4, 5I}, {1 + I, 6, 3 + 3I}}]Range space of an arbitrary-precision matrix:
N[{{π, Sqrt[2], E}, {(1/Sqrt[2]), 1 + Sqrt[2], 2 π}, {-(1/Sqrt[2]) + 2 π, -1 + Sqrt[2], 2 E - 2 π}}, 20]RangeSpace[%]Range space of an exact matrix:
RangeSpace[{{0, 0, 0, π}, {2, 2, 2, 2}, {3 + ISqrt[2], 0, 0, 0}, {0, 4, 4, 0}}]Find the range space symbolically:
RangeSpace[{{a, b, c}, {c, b, a}, {0, 0, 0}}]The above result is generic; special values of the symbols may give different results:
Block[{a = 0, c = 0}, RangeSpace[{{a, b, c}, {c, b, a}, {0, 0, 0}}]]Range space of a tall rectangular matrix:
RangeSpace[(| | |
| ----- | ----- |
| 1.2 | 3.4 |
| 5.6 | 7.8 |
| 9.10 | 11.12 |
| 13.14 | 15.16 |)]Range space of a wide rectangular matrix:
RangeSpace[(| | | | | | |
| ---- | ---- | ---- | ---- | ---- | ---- |
| 0.52 | 0.03 | 0.08 | 0.75 | 0.52 | 0.24 |
| 0.97 | 0.34 | 0.13 | 0.24 | 0.44 | 0.60 |
| 0.50 | 0.68 | 0.36 | 0.31 | 0.06 | 0.05 |)]The range space of a large numerical matrix is computed efficiently:
mat = RandomReal[{2, 10}, {200, 180}];RangeSpace[mat]//Dimensions//TimingSpecial Matrices (5)
Range space of a sparse matrix:
SparseArray[{{2, 1} -> 12, {1, 1} -> 4, {2, 3} -> 13, {3, 1} -> 7, {4, 4} -> 2}, {4, 4}]RangeSpace[%]Range space of a structured matrix:
SymmetrizedArray[{{1, 2} -> 3, {2, 2} -> 5, {2, 3} -> 7, {3, 2} -> 13}, {3, 3}, Symmetric[All]]RangeSpace[%]Compute the range space for HilbertMatrix:
RangeSpace[HilbertMatrix[{3, 4}]]Range space of a matrix with finite field elements:
ℱ = FiniteField[29, 4];
RangeSpace[{{ℱ[12], ℱ[23], ℱ[34]}, {ℱ[45], ℱ[56], ℱ[67]}, {ℱ[101], ℱ[98], ℱ[240]}}]Compute the range space of a 10×12 matrix of univariate polynomials of degree 100:
rpoly[n_] := RandomInteger[{-2 ^ 10, 2 ^ 10}, {n + 1}].x ^ Range[0, n]
SeedRandom[1234];
m = Table[rpoly[100], {10}, {12}];RangeSpace[m]//Short[#, 3]&//AbsoluteTimingOptions (3)
Modulus (1)
m is a 3×3 random matrix of integers between 0 and 4:
m = {{1, 0, 4}, {2, 0, 3}, {2, 1, 2}};The range space is full dimensional in ordinary arithmetic:
RangeSpace[m]Use arithmetic modulo 5 to compute the range space:
RangeSpace[m, Modulus -> 5]Tolerance (1)
Create a matrix with a linear dependency and noise added:
v1 = {1, 2, 1, 2};
v2 = {2, 3, -1, 1};
v3 = 2v1 - 3v2 + RandomReal[{-.01, .01}, 4];
m = {v1, v2, v3}RangeSpace[m]A tolerance setting commensurate with the noise eliminates a vector of noise-level values:
RangeSpace[m, Tolerance -> 10 ^ (-2)]This is consistent with row reduction:
RowReduce[m, Tolerance -> 10 ^ -2]ZeroTest (1)
By default, symbolic expressions are considered nonzero:
m = (| | | | |
| - | -- | - | --- |
| 1 | -2 | 3 | 2 |
| 1 | 1 | 1 | k |
| 2 | -1 | 4 | k^2 |);
RangeSpace[m]In this case, RangeSpace is missing the special case
that produces a singular matrix:
RangeSpace[m /. k -> 2]Write a function that tests if an expression might be zero:
test[k_][e_] := Reduce[e == 0, k, ℝ] =!= False
{test[k][k^2 + 1], test[k][k^2]}Pass test[k] as the value of ZeroTest to get a more symbolic reduction:
gen = RangeSpace[{{1, -2, 3, 2}, {1, 1, 1, k}, {2, -1, 4, k ^ 2}}, ZeroTest -> test[k]]//FullSimplifyThis gives a valid, if nonstandard, basis for generic values of
:
gen /. k -> 1For
, a two-dimensional range space is shown, even if the output includes an extraneous zero vector:
gen /. k -> 2The extraneous vector can be removed, for example, with DeleteCases:
DeleteCases[%, {0, 0, 0}]Applications (17)
The Geometry of RangeSpace (6)
The following matrix has a one-dimensional range space:
m = (| | |
| - | - |
| 1 | 2 |
| 2 | 4 |
| 3 | 6 |);
{Subscript[v, 1]} = RangeSpace[m]Any vector of the form
will lie along the line parallel to
:
With[{y = m.{a, b}}, Projection[y, Subscript[v, 1]] == y//Simplify]Generate 50 random points in the range space:
pts = Table[m.RandomReal[{-1, 1}, 2], {50}];Visualize how the points lie along the line generated by
:
Graphics3D[{{Thick, StandardBlue, InfiniteLine[Subscript[v, 1]]}, PointSize[Medium], Point[pts]}, PlotRange -> 10, Axes -> True]The following matrix has a two-dimensional range space:
m = (| | | |
| - | - | - |
| 1 | 2 | 0 |
| 2 | 4 | 9 |
| 3 | 6 | 0 |);
{Subscript[v, 1], Subscript[v, 2]} = RangeSpace[m]Any vector of the form
will lie in the plane generated by
and
:
With[{y = m.{a, b, c}}, Projection[y, {Subscript[v, 1], Subscript[v, 2]}] == y//Simplify]Generate 2500 random points in the range space:
pts = Table[m.RandomReal[{-5, 5}, 3], {2500}];Visualize how the points lie on the plane generated by
and
:
Graphics3D[{{Thick, StandardBlue, InfinitePlane[{Subscript[v, 1], Subscript[v, 2]}]}, PointSize[Medium], Point[pts]}, Axes -> True, PlotRange -> 50]The following matrix has a three-dimensional range space:
m = (| | | |
| -- | -- | -- |
| 19 | -1 | 0 |
| -1 | 19 | 0 |
| -1 | -3 | 22 |);
RangeSpace[m]Since
is
, the range space is all of
, and
has a solution for any value of
:
Solve[{Subscript[y, 1], Subscript[y, 2], Subscript[y, 3]} == m.{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}]Generate 2500 random points in the range space:
pts = Table[m.RandomReal[{-5, 5}, 3], {10000}];Visualize how the points fill a solid region:
Graphics3D[{Point[pts]}, Axes -> True, PlotRange -> 100]The following system of equations has no solution:
system = {3 == x + 2 y + 3 z, -2 == 2 x + 4 y + 3 z, 7 == 3 x + 6 y + 3 z};
Solve[system, {x, y, z}]Rewrite the system in matrix form:
a = (| | | |
| - | - | - |
| 1 | 2 | 3 |
| 2 | 4 | 3 |
| 3 | 6 | 3 |);b = {3, -2, 7};
system == Thread[a.{x, y, z} == b]//SimplifyThe range space of the coefficient matrix
is a plane:
rs = RangeSpace[a]The vector
does not lie in this plane, so the system has no solutions:
Graphics3D[{InfinitePlane[rs], StandardBlue, PointSize[.05], Point[b]}, PlotRange -> 10, Axes -> True, ViewPoint -> {-3, -2, 0}]The following overdetermined system of equations has a solution:
system = {1 == x + 2 y, 1 == 3 x + 4 y, 1 == 5 x + 6 y};
Solve[system, {x, y}]Rewrite the system in matrix form:
a = (| | |
| - | - |
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |);
b = {1, 1, 1};
system == Thread[a.{x, y} == b]//SimplifyThe range space of the coefficient matrix
is a plane:
rs = RangeSpace[a]The vector
lies in this plane, so the system has a solution:
Graphics3D[{{Opacity[0.5], InfinitePlane[rs]}, StandardRed, PointSize[.05], Point[b]}, PlotRange -> 10, Axes -> True, ViewPoint -> {-3, -2, 0}]Create a visualization of the fact that
. Compute a basis for
with RangeSpace:
m = (| | |
| - | - |
| 1 | 2 |
| 2 | 4 |
| 3 | 6 |);
{Subscript[v, 1]} = RangeSpace[m]Compute a basis for
with NullSpace and Transpose:
{Subscript[v, 2], Subscript[v, 3]} = NullSpace[Transpose[m]]Use InfiniteLine and InfinitePlane to visualize the two perpendicular subspaces:
Graphics3D[{StandardBlue, Thick, InfiniteLine[Subscript[v, 1]], StandardRed, InfinitePlane[{Subscript[v, 2], Subscript[v, 3]}]}]Equation Solving and Invertibility (6)
Determine if the following system of equations has a unique solution:
system = {2x + 3y + 5z == -2, -3x + 4y - z == 7, 4x + y - 6z == 3};Rewrite the system in matrix form:
a = {{2, 3, 5}, {-3, 4, -1}, {4, 1, -6}};
b = {-2, 7, 3};
system == Thread[ a.{x, y, z} == b]The range space is full dimensional, so the system has a unique solution:
Length[RangeSpace[a]] == Last[Dimensions[a]]Verify the result using Solve:
Solve[system, {x, y, z}]Find all values of the
for which the following overdetermined linear system has a solution:
system = {5 x + 2 y + z == Subscript[v, 1], x + 6 y + 7 z == Subscript[v, 2], 4 y + 6 z == Subscript[v, 3], x + 10 y + 9 z == Subscript[v, 4], 2 x + 2 y + 10 z == Subscript[v, 5]}Rewrite the system in matrix form:
a = {{5, 2, 1}, {1, 6, 7}, {0, 4, 6}, {1, 10, 9}, {2, 2, 10}};
b = {Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4], Subscript[v, 5]};
system === Thread[a.{x, y, z} == b]Find the range space of the coefficient matrix
:
rs = RangeSpace[a]Assign the
to be the components of a general linear combination of basis vectors for the range space:
{Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4], Subscript[v, 5]} = Sum[c[i] rs[[i]], {i, Length[rs]}]Use Solve to confirm that it is possible to solve for
,
and
for every value of the
:
Solve[a.{x, y, z} == b, {x, y, z}]Find all values of the vector
for which the equation
has a solution, and the general solution
:
m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
is a 3×3 singular matrix whose range space is not full dimensional:
rs = RangeSpace[m]
for which there is a solution must be a linear combination of range space basis vectors:
b = Sum[c[i] rs[[i]], {i, Length[rs]}]Confirm that there is a solution for each such
by finding one using LinearSolve:
Subscript[x, 1] = LinearSolve[m, b]All solutions are given by
, where
is any vector in the null space:
ns = NullSpace[m]Construct the general solution:
x = Subscript[x, 1] + Sum[d[i] ns[[i]], {i, Length[ns]}]Simplify[m.x == b]Determine if the following matrix has an inverse:
a = (| | | | |
| --- | --- | ---- | --- |
| 108 | 90 | 252 | 186 |
| 240 | 260 | 520 | 420 |
| 264 | 340 | 536 | 468 |
| 522 | 705 | 1038 | 929 |);The range space is not full dimensional, so the matrix is not invertible:
Length[RangeSpace[a]] == Length[a]Verify the result using Inverse:
Inverse[a]Determine if the following matrix has a nonzero determinant:
a = (| | | | |
| - | -- | --- | -- |
| 1 | 4 | 2 | -9 |
| 4 | 12 | 2 | 5 |
| 6 | 7 | -11 | 9 |
| 5 | 15 | 10 | 12 |);Since the range space is full dimensional, the matrix must have nonzero determinant:
Length[RangeSpace[a]] == Length[a]Confirm the result using Det:
Det[a]Estimate the fraction of random 10×10 0–1 matrices that are invertible:
Block[{n = 10000}, N[Sum[If[Length[RangeSpace[RandomInteger[1, {10, 10}]]] == 10, 1, 0], {n}] / n]]Spans and Linear Independence (5)
Find the dimension of the column space of the following matrix:
a = (| | | | |
| - | -- | --- | -- |
| 1 | 4 | 2 | -9 |
| 4 | 12 | 2 | 5 |
| 6 | 7 | -11 | 9 |
| 5 | 15 | 10 | 12 |);Column space is just another name for range space, so the answer can be computed directly:
Length[RangeSpace[a]]Find the dimension of the subspace spanned by the following vectors:
Subscript[v, 1] = {8, 8, 0, -4, 6};Subscript[v, 2] = {2, -2, -11, 1, 0};Subscript[v, 3] = {-4, -8, -12, 4, -4};Subscript[v, 4] = {8, 12, 14, -6, 6};Subscript[v, 5] = {4, 4, 6, -2, 0};By definition, this is the dimension of the range space of the matrix whose columns are the vectors:
Length[RangeSpace[Transpose[{Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4], Subscript[v, 5]}]]]The following three vectors are not linearly independent:
v1 = {1, 2, 3};v2 = {4, 5, 6};v3 = {7, 8, 9};
Solve[a v1 + b v2 == v3, {a, b}]Find the range space of the matrix whose columns are the vectors:
RangeSpace[Transpose[{v1, v2, v3}]]The dimension of the range space is less than the number of vectors because of the linear dependence:
Length[%] < 3The following three vectors are linearly independent:
v1 = {1, 2, 3};v2 = {4, 5, 6};v3 = {7, 8, 10};
Solve[a v1 + b v2 == v3, {a, b}]Find the range space of the matrix whose columns are the vectors:
RangeSpace[Transpose[{v1, v2, v3}]]The dimension of the range space equals the number of vectors because of the linear independence:
Length[%] == 3Determine if the following vectors are linearly independent or not:
Subscript[v, 1] = {108, 90, 252, 186};
Subscript[v, 2] = {240, 260, 520, 420};
Subscript[v, 3] = {264, 340, 536, 468};
Subscript[v, 4] = {522, 705, 1038, 929};The range space of
is less than four dimensional, so they are not linearly independent:
Length[RangeSpace[Transpose[{Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4]}]]] < Length[{Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4]}]Properties & Relations (13)
RangeSpace[m] is spanned by nonzero vectors of the echelon form of Transpose[m]:
m = {{a, b, 2, 3}, {2, 3, a, -b}, {a + 4, b + 6, 2 + 2a, 3 - 2b}};
RangeSpace[m]RowReduce gives the echelon form, including zero vectors:
RowReduce[Transpose[m]]The dimension of the range space is the rank of the matrix:
m = {{a, b, 2, 3}, {2, 3, a, -b}, {a - 4, b - 6, 2 - 2a, 3 + 2b}};
Length[RangeSpace[m]] == MatrixRank[m]The sum of the dimensions of RangeSpace[m] and NullSpace[m] equals the number of columns of m (the rank-nullity theorem):
m = N[RandomInteger[1, {4, 4}]];
{r, c} = Dimensions[m];
ns = NullSpace[m];
rs = RangeSpace[m];
Length[rs] + Length[ns] == cIf m is exact, each element of RangeSpace[m] will have a 1 as its first nonzero entry:
m = (| | | |
| - | - | - |
| 1 | 2 | 1 |
| 6 | 2 | 6 |
| 7 | 0 | 5 |
| 8 | 6 | 4 |
| 7 | 9 | 3 |);
RangeSpace[m]If m is inexact, there are no constraints on the form of the elements:
RangeSpace[N[m]]For any two compatible matrices a and b, RangeSpace[a.b] is contained in RangeSpace[a]:
a = (| | | |
| ---- | ---- | ---- |
| 0.45 | 0.66 | 0.19 |
| 0.29 | 0.98 | 0.31 |
| 0.61 | 0.97 | 0.93 |
| 0.14 | 0.48 | 0.05 |
| 0.78 | 0.41 | 0.79 |);b = (| | | | | |
| ---- | ---- | ---- | ---- | ---- |
| 0.82 | 0.03 | 0.37 | 0.89 | 0.5 |
| 1.26 | 0.86 | 0.55 | 1.82 | 0.53 |
| 0.44 | 0.83 | 0.18 | 0.93 | 0.03 |);
rsa = RangeSpace[a];rsab = RangeSpace[a.b];
MatrixRank[rsa] == MatrixRank[Join[rsa, rsab]]For these particular matrices, RangeSpace[a.b] is a lower-dimensional subspace:
{Length[rsa], Length[rsab]}However, for any real-valued matrix, the range spaces of a and a.Transpose[a] are the same:
rsaat = RangeSpace[a.a];
Length[rsa] == Length[rsaat] == MatrixRank[Join[rsa, rsaat]]rsb = RangeSpace[b];rsbbt = RangeSpace[b.b];
Length[rsb] == Length[rsbbt] == MatrixRank[Join[rsb, rsbbt]]For any matrix, the range spaces of a and a.ConjugateTranspose[a] are the same:
a = RandomComplex[1, {5, 3}];
rsa = RangeSpace[a];rsaact = RangeSpace[a.a];
Length[rsa] == Length[rsaact] == MatrixRank[Join[rsa, rsaact]]RangeSpace[a] is orthogonal NullSpace[ConjugateTranspose[a]]:
a = RandomComplex[1, {5, 3}];
Projection[#, RangeSpace[a]]& /@ NullSpace[a]//ChopFor real-valued matrices, the latter space can be taken to be NullSpace[Transpose[a]]:
a = RandomReal[1, {5, 3}];
Projection[#, RangeSpace[a]]& /@ NullSpace[a]//ChopFor a square matrix, m has a full-dimensional range space if and only if Det[m]!=0:
m = RandomReal[{-1, 1}, {3, 3}];Length[RangeSpace[m]] == Length[m]Det[m] != 0For a square matrix, m has a full-dimensional range space if and only if m has full rank:
m = RandomReal[{-1, 1}, {3, 3}];Length[RangeSpace[m]] == Length[m]MatrixRank[m] == Length[m]For a square matrix, m has a full-dimensional range space if and only if m has an inverse:
m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};Length[RangeSpace[m]] == Length[m]Inverse[m]For a square matrix, m has a trivial null space iff LinearSolve[m,b] has a solution for a generic b:
m = RandomReal[{-1, 1}, {3, 3}];Length[RangeSpace[m]] == Length[m]LinearSolve[m, {Subscript[b, x], Subscript[b, y], Subscript[b, z]}]The range space of a square matrix m can be computed using SingularValueDecomposition:
m = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};Do row reduction on the transposed matrix:
{u, σ, v} = SingularValueDecomposition[m]//N;
MatrixForm /@ {u, σ, v}The nonzero columns of u.σ—here, the first two, due to the zeros in σ—are a basis for the range space:
{v1, v2} = Take[Transpose[u.σ], 2]Get the vectors using RangeSpace:
{n1, n2} = RangeSpace[m]Even though the vectors are not the same, they are a basis for the same vector subspace:
RowReduce[{v1, v2, n1, n2}]//MatrixFormRelated Guides
History
Text
Wolfram Research (2025), RangeSpace, Wolfram Language function, https://reference.wolfram.com/language/ref/RangeSpace.html.
CMS
Wolfram Language. 2025. "RangeSpace." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RangeSpace.html.
APA
Wolfram Language. (2025). RangeSpace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RangeSpace.html
BibTeX
@misc{reference.wolfram_2026_rangespace, author="Wolfram Research", title="{RangeSpace}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/RangeSpace.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rangespace, organization={Wolfram Research}, title={RangeSpace}, year={2025}, url={https://reference.wolfram.com/language/ref/RangeSpace.html}, note=[Accessed: 12-June-2026]}