In data science, a matrix is a table of numbers, while in physics and graphics it is an operator that transforms space. How can the same box of numbers be both at once?
Data Tables and Operators
Text solution
Put each recipe into a columnWriting each drink's ingredients as a column builds a table A whose columns are complete recipes and whose rows track a single ingredient across the menu.
A=[4113],x=[32]
Combine the columns by the order weightsMultiplying A by the customer order x scales the Smoothie column by 3 and the Shake column by 2, then adds the two recipes together.
Ax=3[41]+2[13]=[123]+[26]=[149]
Or dot each ingredient row with the orderTaking each row of A and multiplying matching entries with x totals one ingredient at a time across both drinks.
Ax=[(4×3)+(1×2)(1×3)+(3×2)]=[12+23+6]=[149]
So the order x=[32] requires 14 berries and 9 scoops of protein powder.
1
Size, Entries, and Input-Output Shapes
Our first table had 2 rows and 2 columns, so the input and output had the same length. When a table has a different number of rows and columns, we need a way to name its size, point to individual numbers inside it, and tell what size vector it can take in and send out.
Size, Entries, and Input-Output Shapes
We always count down the rows first and across the columns second, both for the size of the whole matrix and for the position of a single entry:
Watch out: on an (x,y) graph you go across first and up second, but in a matrix A3,1 means down to row 3, then across to column 1.
Text solution
Match the input length to the columnsBecause our 3×2 recipe matrix A has 2 columns, the input order x must have 2 entries to weight them. A 3-entry vector like 325 leaves the 5 with no third column to scale, so Ax is not defined.
A=412132,x=[32]
Add the scaled columns to get the outputScaling and adding the two 3-entry columns produces a 3-entry output vector, one entry for each ingredient row.
Ax=3412+2132=1236+264=14910
So the 2-item drink order comes out as a 3-item ingredient list: 14 berries, 9 scoops of powder, and 10 bananas.
2
Scaling and Adding Matrices
Now that we know how one matrix acts on a vector, what happens when we update a whole table at once, like doubling every recipe or adding a table of seasonal extras?
Scaling and Adding Matrices
Text solution
Scale every entry by cDoubling the menu multiplies every entry in the 3×2 matrix A by 2.
2A=2412132=824264
Add matching entries of same-size matricesBecause the base table A and the Summer Boost table B are both 3×2, we add the entries sitting in the exact same row and column. If their sizes did not match, A+B would not be defined.
Combine the outputs directlyMultiplying a scaled or added matrix by x gives the exact same result as scaling or adding the separate outputs Ax and Bx.
(cA)x(A+B)x=c(Ax),=Ax+Bx
3
How Matrices Move Space
Up to now, our vectors have been lists of drinks and ingredients. What happens when the input vector x=[32] is a point on a 2D grid?
How Matrices Move Space
Text solution
Break the point into standard grid stepsOn a standard grid, the point [32] is 3 steps of [10] (right) plus 2 steps of [01] (up), which are the columns of the identity matrix I=[1001].
I[32]=3[10]+2[01]=[32]
Put the new landing spots into the columnsStretching the right step [10] to [20] and tilting the up step [01] to [11] gives the columns of A.
A=[2011]
Use the point's coordinates to weight the new columnsMultiplying A by [32] takes 3 of Column 1 plus 2 of Column 2 on the new grid.
A[32]=3[20]+2[11]=[60]+[22]=[82]
So A moves the point [32] to [82], and moves the entire 2D grid along with its two columns.
Every point [x1x2] stays attached to the grid as x1 times Column 1 plus x2 times Column 2. So once you know where [10] and [01] land, you can stretch, tilt, rotate, reflect, or flatten the whole plane.
The two columns of a matrix are simply where the right step and the up step land, and those two arrows carry every point on the grid to its new spot.
Key concepts
Whenever you read or build an m×n matrix A, you are looking at both a table of numbers and a machine that transforms vectors:
Rows by columns (m×n and Ai,j)
Count down to the row i first and across to the column j second. In the 3×2 matrix A=412132,A3,1=2.
When Ax is defined and its shape
The input x weights the columns of A, so Ax is only defined when x has n entries (matching the n columns), and the output Ax always has m entries (matching the m rows).
Scaling and adding matrices
You can scale any matrix entry by entry (cA), and you can add two matrices entry by entry (A+B) only when they have the exact same m×n size. If you already have the outputs Ax and Bx, skip building the full matrix and combine the outputs directly:
(cA)x(A+B)x=c(Ax),=Ax+Bx
Columns are where the grid steps land
In geometry, the columns of A are the landing spots of the standard axis steps, like [10] and [01] in 2D, or 100,010, and 001 in 3D. Rotating the plane by 90∘ moves [10] to [01] and [01] to [−10], giving [01−10]; flattening onto the X-axis moves [01] to [00], giving [1000].
4
Practice
1
A bakery tracks 3 ingredients (rows: flour, butter, sugar) across 4 pastries (columns) in the matrix
A=210121302231
What is the size of A, what are the entries A2,3 and A3,2, and what does Column 3 represent?
Count the 3 horizontal rows first and the 4 vertical columns second: don't read across first like (x,y) coordinates, which swaps them to A2,3=1 and A3,2=0 and writes the size backwards as 4×3.
For both matrix size and entry subscripts, do we count down the rows first or across the columns first?
Count the 3 horizontal rows first and the 4 vertical columns second:
Size of A=3×4
For A2,3, go down to row 2 and across to column 3; for A3,2, go down to row 3 and across to column 2 (don't read across first like (x,y) coordinates, which swaps them to A2,3=1 and A3,2=0 and writes the size backwards as 4×3):
A2,3=0,A3,2=1
Column 3 is 302, which represents the complete recipe for the third pastry: 3 units of flour, 0 butter, and 2 sugar.
2
Using the same 3×4 matrix
A=210121302231
explain why Ax is not defined for x=213, and compute Ay for the order y=2013.
Watch out for the 0 in the second entry: adding Column 2 unscaled instead of multiplying it by 0 gives 14136.
Does each entry of the input vector weight a row of A or a column of A?
Because A has 4 columns, its input vector must have 4 entries, one weight for each column, so Ax is not defined for the 3-entry vector x=213 (don't match the input length to the 3 rows).
For the 4-entry order y=2013, scale each of the 4 columns by its matching entry in y (watch out for the 0 in the second entry: adding Column 2 unscaled instead of multiplying it by 0 gives 14136):
Let A and B be 3×2 matrices and C be a 2×3 matrix. For x=[32], suppose Ax=14910 and Bx=503, where the top row of A is [41] and the top row of B is [11]. Find the top row of 2A+B, compute (2A+B)x, and explain why (A+C)x is not defined.
You only know the top rows of A and B. How can you find (2A+B)x directly from the outputs Ax and Bx?
To find the top row of 2A+B, double both entries in the top row of A and add the top row of B:
2[41]+[11]=[82]+[11]=[93]
To find (2A+B)x, scale Ax by 2 and add Bx directly (be careful to double only Ax, not Bx: doubling both gives 2(Ax+Bx)=381826):
Finally, (A+C)x is not defined because A (3×2) and C (2×3) do not have the exact same size, so A+C cannot be added.
4
A 2×2 matrix A moves the standard right step [10] to [3−1] and the standard up step [01] to [12]. Write the matrix A and find where it moves the point x=[23].
Do the landing spots of [10] and [01] form the rows of A or the columns of A?
Write the landing spots [3−1] and [12] as the columns of A (don't write them as rows, which gives [31−12] and sends [23] to [38]):
A=[3−112]
Now weight the two columns by the coordinates of x=[23]:
Ax=2[3−1]+3[12]=[6−2]+[36]=[94]
5
Write the 2×2 matrix R that reflects the 2D plane across the Y-axis and the matrix P that flattens the plane onto the Y-axis. How does the combined matrix I+R transform any point [x1x2], where I is the 2×2 identity matrix?
Don't flip the vertical step to [0−1], which reflects across the X-axis instead and makes I+R flatten onto the X-axis at [2x10].
When you reflect across the Y-axis or flatten onto the Y-axis, where does the horizontal step [10] land, and where does the vertical step [01] land?
Reflecting across the Y-axis flips the horizontal step [10] to [−10] and leaves the vertical step [01] on the Y-axis at [01] (don't flip the vertical step to [0−1], which reflects across the X-axis instead and makes I+R flatten onto the X-axis at [2x10]). Flattening onto the Y-axis sends [10] to [00] and keeps [01] at [01]:
R=[−1001],P=[0001]
Adding I and R entry by entry gives 2P:
I+R=[1001]+[−1001]=[0002]=2P
This flattens every point [x1x2] onto the Y-axis and doubles its vertical coordinate to [02x2].
6
A video game projects 3D points xyz onto a 2D screen using a matrix M. If the 3D axis steps 100,010, and 001 land at [2−1],[30], and [04] on the screen, what is the size of M, what is M, and where on the 2D screen does the 3D point 2−13 land?
Don't write the size as 3×2 by putting input size before output size.
The input has 3 coordinates and the output has 2 coordinates. How many columns and how many rows must M have?
Each 2D landing spot is a 2-entry column and there are 3 of them (one for each 3D axis step), so M has 2 rows and 3 columns (don't write the size as 3×2 by putting input size before output size):
Size of M=2×3,M=[2−13004]
Now weight the 3 columns by the coordinates of 2−13 (watch the negative sign on y=−1: adding the second column instead of subtracting it gives [710]):