Example of the span of several vectors

Suppose we are given the following 4 vectors (Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4])∈(ℝ^3):

(Subscript[v, 1])={1,2,1};(Subscript[v, 2])={1,0,-1};(Subscript[v, 3])={1,-2,1};(Subscript[v, 4])={1,4,3};

and an arbitrary vector X=(([({{(Subscript[x, 1]), (Subscript[x, 2]), (Subscript[x, 3])}})])^T)∈(ℝ^3):

X={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3])};

To tell if {(Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4])} span (ℝ^3), we need to see if V A=X has a solution for all X, where the coefficient matrix V=[({{(Subscript[v, 1]), (Subscript[v, 2]), (Subscript[v, 3]), (Subscript[v, 4])]}}), and the unknown vector A=(([({{(Subscript[α, 1]), (Subscript[α, 2]), (Subscript[α, 3]), (Subscript[α, 4])}})])^T). Since the vectors (Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4]) are defined above as row vectors, the coefficient matrix V can be formed by first combining these vectors into a matrix, and then take its transpose:

V=Transpose[{(Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4])}];V//MatrixForm

A={(Subscript[α, 1]),(Subscript[α, 2]),(Subscript[α, 3]),(Subscript[α, 4])};

The augmented matrix M=[V|X] can be similarly formed:

M=Transpose[Join[Transpose[V],{X}]];M//MatrixForm

The linear system V A=X can be solved by reducing the augmented matrix M to RREF:

FullSimplify[RowReduce[M]]//MatrixForm

Alternatively, the linear system may be solved directly:

Solve[V.Transpose[{A}]==Transpose[{X}],A]

Since a solution for A exists for all X, we conclude that {(Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4])} span (ℝ^3). Note that Mathematica has taken (Subscript[α, 1]) as the free variable, whereas we would normally take (Subscript[α, 4]) as the free variable based on the RREF. Despite the different conventions, the set of solutions to the linear system is completely identical.

To tell if {(Subscript[v, 1]),(Subscript[v, 2]),(Subscript[v, 3]),(Subscript[v, 4])} are linearly independent, we need to see if V A=0 has a unique solution A=0. This homogeneous linear system can also be solved directly:

Solve[V.Transpose[{A}]==Transpose[{{0,0,0}}],A]

The set of solutions to V A=0 forms a vector space, called the null space of V:

NullSpace[V]