1.1
Multiplication of
Ax
Using Columns of
A
[MIT 18.065] Matrix Methods in Data Analysis, Signal Processing, and Machine Learning by Gilbert Strang
Junseo Lee

Ax
and the Column Space of
A

In this notebook, I will be exploring matrix-vector multiplication, focusing on how it relates to the column space of a matrix and the rank.
A fundamental way of thinking about the matrix-vector multiplication
Ax
is to see it as a linear combination of the columns of
A
.
​

Example

Given a matrix
A
2
3
2
4
3
7
, multiply it by a vector
x
x
1
x
2

. There are two ways to perform this multiplication
Ax
, each of which yields the same result.
In[]:=
A = {{2,3},{2,4},{3,7}}
Out[]=
{{2,3},{2,4},{3,7}}
In[]:=
x={{x1},{x2}}
​
Inner Products
The matrix
A
and vector
x
can be multiplied as inner products of the rows of
A
with
x(
x
1
,
x
2
)
.
In[]:=
(*Inner Product of A and x *)​​Ax = A.x
Out[]=
{{2x1+3x2},{2x1+4x2},{3x1+7x2}}
In[]:=
% // MatrixForm
Out[]//MatrixForm=
2x1+3x2
2x1+4x2
3x1+7x2
The product results in a
31
column vector.
​
Outer Product
Alternatively, the matrix-vector multiplication can be performed by forming a linear combination of the columns
a
1
and
a
2
with scalars
x
1
and
x
2
.
In[]:=
(* First Column of Matrix A *)​​a1 = A[[All,{1}]];​​% // MatrixForm
Out[]//MatrixForm=
2
2
3
In[]:=
(* Second Column of Matrx A *)​​​​a2 = A[[All, {2}]];​​% // MatrixForm
Out[]//MatrixForm=
3
4
7
Forming a linear combination of the columns:
x
1
a
1
+
x
2
a
2
In[]:=
Ax = x1 a1 + x2 a2
Out[]=
{{2x1+3x2},{2x1+4x2},{3x1+7x2}}
In[]:=
% // MatrixForm
Out[]//MatrixForm=
2x1+3x2
2x1+4x2
3x1+7x2
We can observe that both approaches results in the same matrix.

All Possible Linear Combinations of the Columns of
A
and the Column Space

When all real numbers
x
1
and
x
2
are allowed in the linear combination
a
1
x
1
+
a
2
x
2
, we get infinitely many vectors
Ax
.
Thus, the combinations of the columns fills out the column space of
A
.
In the above example, each
Ax
is a vector in
3
R
and all linear combinations
Ax
a
1
x
2
+
a
2
x
2
produce a plane in
3
R
. This fills out an infinite plane containing the two lines.
ParametricPlot3D[Flatten[Ax],{x1, -100, 100},{x2,-100,100}, PlotStyle->Opacity[0.5]]
Out[]=
Generally speaking, the vector
b(
b
1
,
b
2
,
b
3
)
is in the column space of
A
exactly when
Axb
has a solution
(
x
1
,
x
2
)
. Then, the solution
x
specifies how we can express
b
as a linear combination
a
1
x
2
+
a
2
x
2
​

Example

For some
b
, this is impossible because they are not in the column space. For instance,
b
1
1
1
is not in
C(A)
because
Axb
is not solvable.
In[]:=
b={1,1,1}
Out[]=
{1,1,1}
In[]:=
(* Check if Ax= b is solvable *)​​LinearSolve[A, b]
LinearSolve
:Linear equation encountered that has no solution.
Out[]=
LinearSolve[{{1,3,8},{1,2,6},{0,1,2}},{1,1,1}]
The combinations of three independent columns in
3
R
give every vector
b
in
3
R
, thus filling the whole
3
R
, and the combinations of the columns of an
nn
invertible matrix fill its column space: all of
n
R
.

Independent Columns and the Rank of
A

Now that we have seen how the linear combinations of the columns of
A
fills its column space, let’s explore how we can find a basis for the column space of
A
and how we can factor
A
into a product of
C
times
R
.

Finding the Basis for the Column Space of
A

To begin with, what is a basis? A basis for a subspace is a full set of independent vectors, and all vectors in the space are linear combinations of the basis vectors.
Then, how do we find a basis? We can create a matrix
C
whose columns come directly from
n
columns of
A
, excluding any column that is a combination of previous columns, or simply linearly dependent columns.
The resulting matrix
C
will have
r
independent columns (
r≤n
) and they will be a basis for the column space of
A
.
​
We refer to the number of independent columns in
A
as the rank of
A
, and it is the dimension of its column space.
Although the basis for the column space is not unique, it always contains the same number of vectors.
​

Example 1

As an example, consider a matrix
A
1
3
8
1
2
6
0
1
2
In[]:=
A = {{1, 3, 8}, {1, 2, 6}, {0, 1, 2}};​​% // MatrixForm
Out[]//MatrixForm=
1
3
8
1
2
6
0
1
2
​

Example 2

The Rank Theorem

References
Strang, G. (2019). Linear Algebra and Learning from Data. Wellesley-Cambridge Press.