Matrix Vector Subspaces

Synopsis. Operations with vectors have been formally defined by the vector space algebraic structure, and the idea of obtaining new vectors by linear combination has been concisely stated as matrix-vector multiplication. Matrices also describe mappings between vector spaces that preserve linear combinations. Can all vectors of interest be obtained by linear combination of some set of vectors? This is a natural question to ask, and is answered through the concept of vector subspaces associated with a matrix.

1.Vector subspaces

1.1.Vectors reachable by linear combination

A central interest in data science is to seek simple description of complex objects. A typical situation is that many instances of some object of interest are initially given as an m-tuple 𝒃m with large m. Assuming that addition and scaling of such objects can be cogently defined, a vector space is obtained, say over the field of reals with an Euclidean distance, Em. Examples include for instance recordings of medical data (electroencephalograms, electrocardiograms), sound recordings, or images, for which m can easily reach in to the millions. A natural question to ask is whether all the m real numbers are actually needed to describe the observed objects. Perhaps instead of specifying all the components of 𝒃m, it might be possible to state that 𝒗 is a linear combination of n<m vectors

𝒃=𝑨𝒙=[ 𝒂1 𝒂2 𝒂n ][ x1 x2 xn ]=x1𝒂1++xn𝒂n.

It is then natural to formally define the set of all vectors 𝒃 that could thus be expressed, meaning that they can be reached by linear combination of the columns of 𝑨.

Definition. In vector space 𝒱=(V,S,+,), the span of vectors 𝒂1,𝒂2,,𝒂nV,is the set of vectors reachable by linear combination

span{𝒂1,𝒂2,,𝒂n}={𝒃V|x1,,xnSsuchthat𝒃=x1𝒂1++xn𝒂n}.

What now is the relationship between this set of reachable vectors and the entire vector space? The mathematical transcription of this question leads to a consideration of another algebraic structure.

Definition. 𝒰=(U,S,+,), U, is a vector subspace of vector space 𝒱=(V,S,+,) over the same field of scalars S, denoted by 𝒰𝒱, if UV and a,bS, 𝒖,𝒗U, the linear combination a𝒖+b𝒗U.

The above states a vector subspace must be closed under linear combination, and have the same vector addition and scaling operations as the enclosing vector space. The simplest vector subspace of a vector space is the null subspace that only contains the null element, U={𝟎}. In fact, any subspace must contain the null element 𝟎, or otherwise closure would not be verified for the particular linear combination 𝒖+(-𝒖)=𝟎. One can think of 𝒵=({𝟎},S,+,) as the smallest subspace of a vector space. By the above definition, 𝒰 is also a subspace of itself, intuitively, the largest subspace. If UV, then 𝒰 is said to be a proper subspace of 𝒱, denoted by 𝒰<𝒱.

Setting n-m components equal to zero in the real space m defines a proper subspace whose elements can be placed into a one-to-one correspondence with the vectors within n. For example, setting component m of 𝒙m equal to zero gives 𝒙=[ x1 x2 xm-1 0 ]T that, while not a member of m-1, is in a one-to-one relation with 𝒙'=[ x1 x2 xm-1 ]Tm-1. Dropping the last component of 𝒚m, 𝒚=[ y1 y2 ym-1 ym ]T gives vector 𝒚'=[ y1 y2 ym-1 ]m-1, but this is no longer a one-to-one correspondence since for some given 𝒚', the last component ym could take any value.

m=3; x=[1; 2; 0]; xp=x[1:2]

[ 1 2 ] (1)

y=[1; 2; 3]; yp=y[1:2]

[ 1 2 ] (2)

[xp==yp x==y]

[ true false ] (3)

1.2.Vector space composition

Vector subspaces arise from the decomposition of a vector space, the idea of breaking up a complex object into component parts. The converse, composition of vector spaces 𝒰=(U,S,+,) 𝒱=(V,S,+,) is also defined in terms of linear combination. A vector 𝒙3 can be obtained as the linear combination

𝒙=[ x1 x2 x3 ]=[ x1 0 0 ]+[ 0 x2 x3 ],

but also as

𝒙=[ x1 x2 x3 ]=[ x1 x2-a 0 ]+[ 0 a x3 ],

for some arbitrary a. In the first case, 𝒙 is obtained as a unique linear combination of a vector from the set U={[ x1 0 0 ]T|x1.} with a vector from V={[ 0 x2 x3 ]T|x2,x3.}. In the second case, there is an infinity of linear combinations of a vector from V with another from W={[ x1 x2 0 ]T|x1,x2.} to the vector 𝒙. This is captured by a pair of definitions to describe the two types of vector space composition.

Definition. Given two vector subspaces 𝒰=(U,S,+,), 𝒱=(V,S,+,) of the space 𝒲=(W,S,+,), the direct sum is the vector space 𝒰𝒱=(UV,S,+,), where the direct sum of the two sets of vectors U,V is UV={𝒖+𝒗:!𝒖U,!𝒗V}. (unique decomposition)

Definition. Given two vector subspaces 𝒰=(U,S,+,), 𝒱=(V,S,+,) of the space 𝒲=(W,S,+,), the sum is the vector space 𝒰+𝒱=(U+V,S,+,), where the sum of the two sets of vectors U,V is U+V={𝒖+𝒗:𝒖U,𝒗V}.

Since the same scalar field, vector addition, and scaling is used, it is convenient to refer to vector space sums simply by the sum of the vector sets U+V, or UV, instead of specifying the full 4-tuplet for each space. This shall be adopted henceforth to simplify the notation.

u=[1; 0; 0]; v=[0; 2; 3]; vp=[0; 1; 3]; w=[1; 1; 0]; [u+v vp+w]

[ 1 1 2 2 3 3 ] (4)

In the above computational example, the essential difference between the two ways to express 𝒙3 is that UV={𝟎}, but VW={[ 0 a 0 ]T:a}{𝟎}, and in general if the zero vector is the only common element of two vector spaces then the sum of the vector spaces becomes a direct sum. In general, the common elements of two vector subspaces can also be defined.

Definition. Given two vector subspaces (U,S,+,), (V,S,+,) of the space (W,S,+,), the intersection is the set UV={𝒙|:𝒙U,𝒙V}.

In practice, the most important procedure to construct direct sums or to check when an intersection of two vector subspaces reduces to the zero vector is through an inner product.

Definition. Two vector subspaces U,V of the real vector space m are orthogonal, denoted as UV if 𝒖T𝒗=0 for any 𝒖U,𝒗V.

Definition. Two vector subspaces U,V of U+V are orthogonal complements, denoted U=V, V=U if they are orthogonal subspaces, UV, and UV={𝟎}, i.e., the null vector is the only common element of both subspaces.

Continuing the above computational example where the same vector was obtained through two different linear combinations, 𝒛=𝒖+𝒗=𝒗'+𝒘, the essential difference between the two is 𝒖 is orthogonal to 𝒗, whereas 𝒗' is not orthogonal to 𝒘.

[u'*v vp'*w]

[ 0 1 ] (5)

2.Vector subspaces of a linear mapping

2.1.Matrix column and left null spaces

The wide-ranging utility of linear algebra essentially results a complete characterization of the behavior of a linear mapping between vector spaces 𝒇:UV, 𝒇(a𝒖+b𝒗)=a𝒇(𝒖)+b𝒇(𝒗). For some given linear mapping the questions that arise are:

  1. Can any vector within V be obtained by evaluation of 𝒇?

  2. Is there a single way that a vector within V can be obtained by evaluation of 𝒇?

Linear mappings between real vector spaces 𝒇:nm, have been seen to be completely specified by a matrix 𝑨m×n. It is common to frame the above questions about the behavior of the linear mapping 𝒇(𝒙)=𝑨𝒙 through sets associated with the matrix 𝑨. To frame an answer to the first question, a set of reachable vectors is first defined.

Definition. The column space (or range) of matrix 𝑨m×n is the set of vectors reachable by linear combination of the matrix column vectors

C(𝑨)=range(𝑨)={𝒃m:𝒙nsuchthat𝒃=𝑨𝒙}.

By definition, the column space is included in the co-domain of the function 𝒇(𝒙)=𝑨𝒙, C(𝑨)m, and is readily seen to be a vector subspace of m. Having defined the set of vectors reachable by linear combination, two questions arise:

  1. Is the column space the entire co-domain, C(𝑨)=m ? This would signify that any vector can be reached by linear combination of columns of 𝑨.

  2. What co-domain vectors are not reachable by linear combination of columns of 𝑨 ?

Consider the orthogonal complement of C(𝑨) defined as the set vectors 𝒚 orthogonal to all of the column vectors of 𝑨=[ 𝒂1 𝒂2 𝒂n ], expressed through inner products as

𝒂1T𝒚=0,𝒂2T𝒚=0,,𝒂nT𝒚=0.

This can be expressed more concisely through the transpose operation

𝑨=[ 𝒂1 𝒂2 𝒂n ],𝑨T𝒚=[ 𝒂1T 𝒂2T 𝒂nT ]𝒚=[ 𝒂1T𝒚 𝒂2T𝒚 𝒂nT𝒚 ],

and leads to the definition of a set of vectors for which 𝑨T𝒚=𝟎

Definition. The left null space (or cokernel) of a matrix 𝑨m×n is the set

N(𝑨T)=null(𝑨T)={𝒚m:𝑨T𝒚=𝟎}.

Note that the left null space is also a vector subspace of the co-domain of 𝒇(𝒙)=𝑨𝒙, N(𝑨T)m. The above definitions suggest that both the matrix and its transpose play a role in characterizing the behavior of the linear mapping 𝒇=𝑨𝒙, so analagous sets are define for the transpose 𝑨T.

Definition. The row space (or corange) of a matrix 𝑨m×n is the set

R(𝑨)=C(𝑨T)=range(𝑨T)={𝒄n:𝒚m𝒄=𝑨T𝒚}n

Definition. The null space of a matrix 𝑨m×n is the set

N(𝑨)=null(𝑨)={𝒙n:𝑨𝒙=𝟎}n

2.2.Geometric description of subspaces

The concepts of Euclidean geometry are widely used to characterize subspaces of a vector space. Consider the familiar example of 2=(2,,+,) the Euclidean 2-space or plane,

2={[ x1 x2 ]:x1,x2}.

As is common the vector space representing the plane is referred to either by its full name 2 or in shorthand form as 2. The trivial subspaces of 2 are the zero vector space 𝒵=({𝟎},,+,), and 2 itself. Any line passing through the origin is a non-trivial subspace =(L,,+,) with

Lp,q={[ ap aq ]:a}.

In particular the x1,x2 axes are

L1,0={[ a 0 ]:a},L0,1={[ 0 a ]:a},

respectively. In 3, the non-trivial subspaces are lines passing through the origin

Lp,q,r={[ ap aq ar ]:a},

and planes passing through the origin

P𝒏={[ x1 x2 x3 ]:𝒏T𝒙=n1x1+n2x2+n3x3=0,x1,x2,x3},

where 𝒏 is the normal vector of the plane. An intuitive understanding of subspace geometry is essential and built up from instructive computational examples.

Examples. Consider a linear mapping between real spaces 𝒇:nm, defined by 𝒚=𝒇(𝒙)=𝑨𝒙=[ y1 yn ]T, with 𝑨m×n. Julia provides the nullspace function to return a set of vectors that span a null space. A function colspace to provide a set of vectors to span the column space is not yet in the general libraries, but can be readily defined, together with a function to display numerical results to a default precision of p=6 digits.

function colspace(A,p=6)
  return round.(Matrix(qr(A).Q)[:,1:rank(A)],digits=p)
end;
short(x) = round(x,digits=6);
short(pi)

3.141593

With these functions defined, the following examples provide great insight into the significance of column and null spaces and their associated spanning sets. For these small-dimensional, simple examples geometric insight is sufficient to understand what column and null spaces represent. Computational procedures can be devised for much higher number of components, and the geometric insights gained here carry over.

  1. For m=3,n=1,

    𝑨=[ 1 0 0 ],𝑨T=[ 1 0 0 ],

    the column space C(𝑨) is the y1-axis, and the left null space N(𝑨T) is the y2y3-plane since the condition 𝑨T𝒚=0 reduces to y1=0. Spanning vector sets for C(𝑨) and N(𝑨T) can be computed as follows, confirming the previous geometric descriptions. Note that combining the two leads to the identity matrix, an observation whose significance will soon become apparent.

    A=[1; 0; 0]; colspace(A)

    [ 1.0 0.0 0.0 ] (6)

    nullspace(A')

    [ 0.0 0.0 1.0 0.0 0.0 1.0 ] (7)

    [colspace(A) nullspace(A')]

    [ 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 ] (8)

  2. For m=3,n=2,

    𝑨=[ 1 -1 0 0 0 0 ]=[ 𝒂1 𝒂2 ],𝑨T=[ 1 0 0 -1 0 0 ],

    the columns of 𝑨 are colinear, 𝒂2=-𝒂1, and the column space C(𝑨) is the y1-axis, and the left null space N(𝑨T) is the y2y3-plane, as before.

    A=[1 -1; 0 0; 0 0]; CA=colspace(A)

    [ 1.0 0.0 0.0 ] (9)

    NAt=short.(nullspace(A'))

    [ 0.0 0.0 1.0 0.0 0.0 1.0 ] (10)

    [CA NAt]

    [ 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 ] (11)

  3. For m=3,n=2,

    𝑨=[ 1 0 0 1 0 0 ],𝑨T=[ 1 0 0 0 1 0 ],

    the column space C(𝑨) is the y1y2-plane, and the left null space N(𝑨T) is the y3-axis.

    A=[1 0; 0 1; 0 0]; CA=colspace(A)

    [ 1.0 0.0 0.0 1.0 0.0 0.0 ] (12)

    NAt=short.(nullspace(A'))

    [ 0.0 0.0 1.0 ] (13)

    [CA NAt]

    [ 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 ] (14)

  4. For m=3,n=2,

    𝑨=[ 1 1 1 -1 0 0 ],𝑨T=[ 1 1 0 1 -1 0 ],

    the same C(𝑨), N(𝑨T) are obtained, albeit with a different set of spanning vectors returned by colspace.

    A=[1 1; 1 -1; 0 0]; CA=colspace(A)

    [ -0.707107 -0.707107 -0.707107 0.707107 0.0 0.0 ] (15)

    NAt=short.(nullspace(A'))

    [ 0.0 0.0 1.0 ] (16)

    [CA NAt]

    [ -0.707107 -0.707107 0.0 -0.707107 0.707107 0.0 0.0 0.0 1.0 ] (17)

  5. For m=3,n=3,

    𝑨=[ 1 1 3 1 -1 -1 1 1 3 ]=[ 𝒂1 𝒂2 𝒂3 ],
    𝑨T=[ 1 1 1 1 -1 1 3 -1 3 ]=[ 𝒂1T 𝒂2T 𝒂3T ],𝑨T𝒚=[ 𝒂1T𝒚 𝒂2T𝒚 𝒂3T𝒚 ].

    Since 𝒂3=𝒂1+2𝒂2, the orthogonality condition 𝑨T𝒚=𝟎 is satisfied by vectors of form 𝒚=[ a 0 -a ], a.

    A=[1 1 3; 1 -1 -1; 1 1 3]; CA=colspace(A)

    [ -0.5773502691896257 0.40824829046386313 -0.5773502691896257 -0.816496580927726 -0.5773502691896257 0.40824829046386313 ] (18)

    NAt=short.(nullspace(A'))

    [ -0.707107 0.0 0.707107 ] (19)

    [CA NAt]

    [ -0.5773502691896257 0.40824829046386313 -0.707107 -0.5773502691896257 -0.816496580927726 0.0 -0.5773502691896257 0.40824829046386313 0.707107 ] (20)