In progress - Rank and non-square matrix explanation

1. Spans and spaces

  • Span: The span of a set of vectors is all linear combinations of those vectors
  • Vector space is denoted as .
    • Every element in a vector space can be written as a linear combination of the elements in the basis (unit) vectors
      • Basis (unit) vectors (example): For a 2D vector space, the basis vectors are and
      • A matrix applies a linear transformation to a vector space (i.e. all vectors in the space)
      • The columns of represent the landing points for the basis (unit) vectors after the transformation
        • By extension, moves every input vector (more precisely, the point where every vector’s tip is) linearly to a new location.
      • We only need to know how transforms the bases and , since
        • any other vector is just a linear combination of and both before and after being transformed by
  • Subspace: a subset of a larger vector space
    • Geometric intuition: A subspace of a 3D vector space is a 2D plane that passes through the origin
    • Column space (aka range, or image): Span (i.e. set of all possible linear combinations) of the column vectors of
      • Geometrically: Essentially, the entire output space
    • Row space: Span of the row vectors of
    • Null space (or kernel): If , the span of all solutions constitutes the null space of
      • Geometrically: The space of all vectors that maps onto the zero vector (i.e. they are squished by onto the origin)
    • Left-Null space: If , the span of all solutions constitutes the left-null space of

2. More properties

  • Rank: The number of linearly independent columns (or rows) in is its rank
  • Orthonormal vectors: Two unit length vectors whose inner (i.e. dot) products are 0 (e.g. and )
  • Real value matrices:
    • Orthogonal matrices: If ‘s rows and cols are orthonormal vectors, is an orthogonal matrix. It satisfies:
    • Symmetric matrix: where (square matrices only)
  • Complex value matrices
    • Hermitian matrix: Complex matrices’ analog to orthogonal matrix
    • Unitary matrix: Complex matrices’ analog to symmetric matrix
  • Determinant: This can be computed for any square matrix
    • Matrices are only invertible if . Such matrices are non-singular; and satisfy
    • Matrices where are not invertible. They are singular matrices

3. Examples of the above (where relevant):

  • The span of vectors and is the whole - plane.
  • A vector, , with 3 elements is said to exist in vector space
  • The vector, is composed of (i.e. a linear combination of) the basis vectors , and .
  • The subspace of a 3D vector (in ) is the span of vectors , .
    • in this case the 2D - plane is a subspace (subset) of the 3D vector space
  • Vectors and are linearly dependent since one is a multiple of the other.
    • A matrix with those two vectors would be rank 1

TODO: Kroenecker product, Tensors, Tensor products,

https://en.wikipedia.org/wiki/Tensor https://en.wikipedia.org/wiki/Tensor_product https://en.wikipedia.org/wiki/Kronecker_product https://en.wikipedia.org/wiki/Block_matrix https://math.stackexchange.com/questions/973559/outer-product-of-two-matrices https://stackoverflow.com/questions/24839481/python-matrix-outer-product

4. Back to Non-Square matrices (A geometric perspective)

A non-square matrix has rows and columns. Geometrically, transforms a vector space into a vector space .

For example, the matrix transforms a 2D vector space into a 3D vector space.

  • Specifically, the two basis vectors (i.e. from 2D space) transform to 3D coordinates as follows:

Similarly, matrix transforms a 3D vector space into a 2D vector space.

  • Specifically, the three basis vectors (i.e. from 3D space) transform to 2D coordinates as follows:

4.1. Rank

  • Definition: The rank of is the number of linearly independent columns or rows in
    • Rank is the number of dimensions in the column-space (aka. span of the column vectors of in (or )).
    • Consequently, the number of linearly independent columns in a matrix the number of linearly independent rows in that matrix.

4.1.1. “Full Rank” Matrix

  • is full rank if (i.e. the rank is as high as it can be)
  • This is the same as:
    • if all columns of are linearly independent

4.1.2. Geometric intuition for Rank::

  • If matrix is a transformation, the rank is the number of dimensions in the output space. Examples:
    • If some matrix transformed some arbitrary vector space into a 1D line in , then
    • If transformed some vector space to a 2D plane in , then
  • In general, if transforms some vector space to , then

4.1.3. Geometric intuition, examples:

  • A matrix is full rank (i.e. rank 2) if the output is a 2D space (; same as the input space).
  • A matrix is full rank (i.e. rank 3) if the output is a 3D space (; same as the input space). . However,
    • If the matrix collapsed the input space to a 2D plane, then it is only rank 2 (NB: but it can collapse further)
    • If the matrix collapsed the input space to a 1D line, then it is only rank 1
  • A matrix is full rank (i.e. rank 2) if the output is a 2D plane in (same as the input space)

2.1.4. Augmented Matrix

  • If vector is concatenated to matrix , we say ” augmented with “. Denoted as .
    • if , then vector is “new” information
    • otherwise, if , it means can be created as a linear combination of the columns in
# Compute the condition number and rank for matrix A = [[1,1,0],[0,1,0],[1,0,1]]
# If y = [[1],[2],[1]], get the augmented matrix [A,y]
 
from numpy import array, trace, concatenate
from numpy.linalg import cond, matrix_rank
 
A = array([[1, 1, 0], [0, 1, 0], [1, 0, 1]])
y = array([[1], [2], [1]])
print("A matrix's shape:", A.shape, "\ny vector's shape", y.shape)
 
print("\nCondition number(A):", cond(A))
print("Rank(A):", matrix_rank(A))
print("Trace(A):", trace(A))
 
A_y = concatenate((A, y), axis=1)
print("\nOriginal A matrix:\n", A, "\ny vector:\n", y, "\n\nAugmented (A|y) matrix:\n", A_y)
print("Rank(A_y):", matrix_rank(A_y))
 
print("\nNote that the rank of A and A_y are both 3, so y is a linear combination of the columns of A.")
print("Therefore, there is no new information in y that is not already in A.")
 
A matrix's shape: (3, 3) 
y vector's shape (3, 1)
 
Condition number(A): 4.048917339522305
Rank(A): 3
Trace(A): 3
 
Original A matrix:
 [[1 1 0]
 [0 1 0]
 [1 0 1]] 
y vector:
 [[1]
 [2]
 [1]] 
 
Augmented (A|y) matrix:
 [[1 1 0 1]
 [0 1 0 2]
 [1 0 1 1]]
Rank(A_y): 3
 
Note that the rank of A and A_y are both 3, so y is a linear combination of the columns of A.
Therefore, there is no new information in y that is not already in A.