Before you readA function sends ^=(1,0) to (2,1) and ^=(0,1) to (1,3), and keeps grid lines straight and evenly spaced. Where does it send (1,2)?
Watch: Linear transformations and matrices · 3Blue1Brown · Essence of Linear Algebra, ch. 3
A linear transformation moves every vector while keeping grid lines straight, parallel and evenly spaced, with the origin fixed. So it is decided entirely by where the basis vectors land.
A matrix records exactly that: its columns are where ^ and ^ go.
A=[2113],A[xy]=x[21]+y[13]
So A(1,2)T=1⋅(2,1)+2⋅(1,3)=(4,7). Matrix times vector is a linear combination of the columns.
A = [[2, 1], [1, 3]]
The columns of A are where î and ĵ land. Drag either arrow or a slider; slide "from I to A" to watch the grid move.
Watch: Matrix multiplication as composition · 3Blue1Brown · Essence of Linear Algebra, ch. 4
Multiplying matrices means doing one transformation after another: AB applies B first, then A. To get entry (i,j) of AB (row i, column j), multiply row i of A by column j of B entry by entry and add: for [12] and [34] that is 1⋅3+2⋅4=11. Order matters: in general AB=BA.
Shapes must match: (m×n)(n×p) gives m×p. A 2×2 times a 3×2 is undefined.
The transposeAT swaps rows and columns. A dataset is a matrix X with one row per example, and a linear model’s parameters form a vector θ. Then Xθ is one matrix–vector product giving every example’s prediction at once.
Recall
What do the columns of a matrix tell you?
Recall
In the product AB, which transformation happens first?
Recall
When is the product of an m×n and a p×q matrix defined, and what shape is it?
Exercise
Compute AB for A=[1021] and B=[1301]. Enter the four entries row by row: top-left, top-right, bottom-left, bottom-right.