Identity, Diagonal, and Transpose
Some matrices appear so often that they deserve names.
This page introduces three:
- identity matrices
- diagonal matrices
- transposes
Each one is simple, but each one appears constantly in linear algebra and machine learning notation.
Identity
The identity matrix leaves a vector unchanged.
For any two-entry vector :
For example:
What is the first entry of ?
Compute it first, then check your number.
HintNo change
Multiplying by the identity does not change the vector.
SolutionIdentity leaves x alone
The first entry is 7. The identity matrix is the matrix version of "do
nothing" for a vector of the matching length.
Diagonal
A diagonal matrix has nonzero entries only on the main diagonal.
It scales coordinates separately:
The first coordinate was multiplied by 2. The second coordinate was
multiplied by 3.
If
what is the second entry of ?
Compute it first, then check your number.
HintUse the second scale
The second coordinate 5 is multiplied by 3.
SolutionSeparate coordinate scaling
The second entry is 15. A diagonal matrix scales coordinates separately,
so the second coordinate only sees the second diagonal entry.
Transpose
The transpose swaps rows and columns.
If:
then:
The shape changes from 2 x 3 to 3 x 2.
If has shape 5 x 2, what shape does have?
Compute it first, then check your number.
HintSwap rows and columns
The transpose swaps the two shape numbers.
SolutionSwap shape
A 5 x 2 matrix has 5 rows and 2 columns. Its transpose has 2 rows
and 5 columns.
Why These Patterns Matter
Identity matrices let equations say "leave this part unchanged." Diagonal matrices represent separate coordinate scaling. Transposes turn rows into columns and often make dot products and shape rules fit.
Enter 1 for identity, 2 for diagonal, or 3 for transpose:
This operation swaps
rows and columns.
Compute it first, then check your number.
HintRows become columns
Which named operation turns a 2 x 3 matrix into a 3 x 2 matrix?
SolutionTranspose
Enter 3. The transpose swaps rows and columns. That is why a 2 x 3
matrix becomes a 3 x 2 matrix after transposing.
Next, we use matrices to represent batches of many examples.