G1: To understand matrix vector multiplication as transformation of the vector
Multiplying a matrix A with a vector x transforms x
G2: Understanding low rank matrices as applying transformation on a vector resulting in a subspace of the original vector space
Transforming a vector via a low rank matrix in the shown examples leads to a line
We first study Goal 1. The interpretation of matrix vector product is borrowed from the excellent videos from the 3Blue1Brown channel. I’ll first set up the environment by importing a few relevant libraries.
Basic imports
Code
import numpy as npimport seaborn as snsimport pandas as pdimport matplotlib.patches as mpatchesimport matplotlib.pyplot as pltfrom sympy import Matrix, MatrixSymbol, Eq, MatMulsns.reset_defaults()sns.set_context(context="talk", font_scale=0.75)%matplotlib inline%config InlineBackend.figure_format='retina'
In the above plots we can see that changing our x to any vector in the 2d space leads to us to transformed vector not covering the whole 2d space, but on line in the 2d space. One can easily take this learning to higher dimensional matrices A.