Matrices and Matrix Multiplication

We dive into linear algebra by unpacking functions as set mappings, then zoom in on linear mappings and how they all secretly boil down to matrices.

Now we’re properly diving into linear algebra. First up โ€” let’s take a look at “functions (mappings).”

When we say “function,” us middle-and-high-school grads picture something like this

Hand-drawn graph of the curve y = f(x) on a coordinate plane

or this, right~~

Hand-drawn picture of a function f sending the set X to the set Y, with x going to f(x)

Yep, not wrong. But instead of the coordinate-plane interpretation on the left, thinking of a “function” as something that sends one set to another set โ€” like the picture on the right โ€” is, apparently, juuust a tiny bit more fundamental. So from here on out, almost everything we say about functions is going to be interpreted set-style.

Oh, by the way โ€” I wrote “mapping” in parentheses next to “function” up there.

What’s that about?

Mapping is basically the idea of “copying a shape” from one place to another. Let me try mapping my ID photo.

The author’s passport photo, used as the ID picture to be mapped

MA!!PPING!!!

Hand-drawn smiley face with spiky hair, the mapped ID photo

Ta-daa~ Does it resonate?? T_T sob sob

This is how I think about it. Subjective, sure, but โ€” some vector

Hand-drawn arrow pointing up and to the right, a vector

gets passed through function f,

Smaller hand-drawn arrow pointing up and to the right, the vector after passing through f

and becomes this…… Is “mapping” really the right word for that…?? Hmm, I dunno lol.

Anyway โ€” “function” and “mapping” get used pretty much interchangeably, and you can basically think of “mapping” as roughly the same thing as “function.”

Linear function and linear mapping

Now, among the absurdly many functions/mappings out there, we’re going to zoom in on the “linear” ones. Because this is linear algebra!!!!

Notation usually looks like this:

The notation L : V โ†’ W for a linear mapping from V to W

That alien-language thing means: a linear function L (or linear mapping L) that sends some vector space V to another vector space W.

OK so now let’s look at the conditions for L to actually count as a linear function (mapping). I talked about this waaaay back in the very first post. Conditions for being a linear mapping:

The two conditions for a linear mapping: L(v1 + v2) = L(v1) + L(v2) and L(av) = aL(v)

Easy, right.

Now let me throw a few examples of linear mappings at you.

(Let’s pin it down to R^2 โ€” 2-dimensional space โ€” and also pin down the basis ฮฒ.)

Enlarging (shrinking) mapping: a small red square is sent by L to a bigger red square, and the point (x, y) goes to the point (x’, y’)

What this says is: passing the point (x, y) through the linear mapping gives you the point (x’, y’). The red outline is the collection of all those points, drawn as lines.

But there’s an enlargement happening โ€” so what’s the relationship between x, y and x’, y’?!?!

The equations x’ = ax and y’ = by

I’m guessing it goes like that.

Rotation mapping: a red rectangle is turned by the angle theta, with formulas for x’ and y’

Stretching: a small red square is stretched into a long rectangle, with x’ = ax and y’ = y

Wiping out: a red square is sent to nothing, with x’ = 0 and y’ = 0

If we kept listing types like this, we’d literally never finish. So we’ll cut it off there. Even from just those few, we can spot something all linear mappings have in common.

The system x’ = ax + by and y’ = cx + dy

(Side note) When we usually represent a vector on a coordinate plane, we write it like (x y) a lot, but you can also write it as (x, y) written as a column.

We’re more used to the first one. But is there a difference between the two?!? For now โ€” nope. None. Whether you write a point on the coordinate plane one way or the other, no difference.

OK, so we now know what a linear mapping is. Then when we run into some specific linear mapping, we might be curious โ€” what kind of linear mapping is it, out of all the linear mappings out there?

So when we run into one, what info do we need to extract before we can say “yep, I’ve conquered this linear mapping”???

Same vibe as: when we run into a first-degree linear equation, knowing one point it passes through plus the slope is enough to say conquered!!!! Turns out there’s a similar “got it, conquered!!” condition for linear mappings too.

In general, fully knowing a function means knowing its “domain” and “codomain” and the rule that sends each input to its output (the “range,” the outputs that actually get hit, then follows) โ€” and then we get to say we know the function inside out, right?!?!

To be able to say we’ve conquered a linear mapping in its enti~~~rety, it’s enough to just know where the “basis” archers shoot their arrows. From that we can figure out where all the other archers shoot theirs.

From here on, for the sake of the discussion, let’s call the domain “the archers” and the codomain “the targets.” And let’s call the range “the targets the arrows actually hit”!!!!

Each of the two basis vectors is sent by L to a column of letters: the first to (a, c), the second to (b, d)

(That’s our setup.)

Out of the insanely many archers, we just need to know where these two shoot.

Why!!!!

Because of the two principles of linear mapping:

The two conditions for a linear mapping: L(v1 + v2) = L(v1) + L(v2) and L(av) = aL(v)

Let me lay out the reasoning.

Derivation: L(x, y) = L(x, 0) + L(0, y) = xL(1, 0) + yL(0, 1) = x(a, c) + y(b, d) = (ax + by, cx + dy) = (x’, y’), all written as columns

So if we can pin down a, b, c, d here, we can call this linear mapping L analyzed! We know everything about it!! That is โ€”

The mapping L written as the 2 x 2 matrix with rows (a, b) and (c, d) multiplying the column (x, y)

Almost there. The true identity of this thing we thought we knew called a “matrix” is about to be revealed!!!!

Definition of a matrix

2 x 2 matrix

The 2 x 2 matrix with rows (a, b) and (c, d)

The meaning of a matrix like this is:

it’s a certain function.

And it’s written using only the subscripts of L with the matrix (a b; c d) as its subscript. The rule for transforming the vector (x, y) into the vector (x’, y’) under that mapping is x’ = ax + by, y’ = cx + dy โ€” meaning it follows a rule like that.

There’s another notation for matrices too. The thing you learned back in 11th grade! That’s how you write it: a_ij, and it represents the elements of the matrix.

The 2 x 2 matrix with entries a11, a12, a21 and a22

The position-value for each spot in the matrix is indicated like this โ€” i is the “row” and j is the “column.”

(For anyone who gets confused~~ we usually say “horizontal then vertical,” not “vertical then horizontal,” right? In a matrix, “row” is horizontal and “column” is vertical!!!)

Also, the matrix A can be written as (a_ij) or alternatively as A_ij.

Notation isn’t that important โ€” it’s the kind of thing you just gradually get used to.

OK!!! Let’s keep going. The 2 x 2 matrix was โ€” L : R^2 โ†’ R^2 โ€” found among functions that move from 2-dimensional space to 2-dimensional space, like this!!

Extrapolating โ€” L : R^n โ†’ R^m โ€” what does the matrix form of a linear function from n-dimensional space to m-dimensional space look like???

Probably a shape like this:

The m x n matrix equation: the column (x’_1 … x’_m) equals the matrix with entries a11 up to amn, with n columns and m rows, times the column (x_1 … x_n)

And the equation that used to be x’ = ax + by becomes

The formula x’_i equals the sum over j from 1 to n of a_ij times x_j

so that’s how we’d write it.

Row vectors and column vectors

A matrix like the one above can also be torn apart by row, or torn apart by column. No wait โ€” tearing it by row is called a row vector, and tearing it by column is called a column vector.

Row vector A sub i and column vector A super j of the matrix A

What if linear mappings happen back-to-back?!?!?!

Two mappings in a row: L from R^n to R^m with the matrix A, and M from R^m to R^l with the matrix B

The product of the matrices B and A is the matrix C, which is the composite function Mโˆ˜L

This is just composite functions, a.k.a. matrix multiplication โ€” you all know this, right?!?!?! (I’m dying to just skip this part) Matrix multiplication is something everyone can do on autopilot!!!! Right!

The (i, j) entry of C = BA comes from row i of B and column j of A

The (i, j) element of matrix C โ€” where C is the product of matrices B and A โ€” is

The formula b_i1 a_1j + b_i2 a_2j + … + b_im a_mj equals the sum over k from 1 to m of b_ik a_kj

right?!

OK then!! Does the commutative law hold for matrix multiplication?

Of course no-no it’s no-no?!?? That’s no~no~ (AB โ‰  BA)

But since a matrix represents a function, and multiplying matrices means composing functions,

the fact that the commutative law doesn’t hold for composite functions is totally natural โ€” and so matrix multiplication not commuting is also totally natural.

I’m gonna move on to the next post fast!!!!

One more thing (side note)

About the identity matrix I โ€” back in high school we kind of grasped I as “roughly the number 1, but for matrices.” But now that we know a matrix is actually a “function” (more specifically a mapping), if we think about what kind of mapping the identity matrix is โ€”

it’s a “copy mapping”!!!! It just hands you back exactly what you gave it.

Also โ€” tip!!!! Have you learned the Kronecker delta?!?! Turns out the Kronecker delta shows up all over linear algebra. The identity matrix I can be expressed super cleanly using the Kronecker delta!!

The identity matrix I equals (ฮด_ij), the Kronecker delta


Heads-up. The figures here are the original notes, slips and all. A few things to watch for:

  • In the rotation example the second formula should read $y' = \sin\theta\,x + \cos\theta\,y$; the picture has a minus sign.
  • In the basis-archer picture the second line should read $L(0, 1) = (b, d)$; the picture writes $a$ where the 1 belongs.

Comments

Discussion happens via GitHub Discussions. You'll need a GitHub account to comment.