We're now gonna talk about composition of linear functions.
We'll see that that gives you yet another interpretation of matrix multiplication.
[NOISE] So let's suppose
a is an m by p matrix and b is p by n. So these are two matrices.
Um, of course I can multiply,
I can form the product C equals ab.
So let's define a function f and it's going to map, uh, Rp to Rm.
And that means that f takes in a p vector and,
and returns an m vector.
Um, g is going to be a function that takes in an n vector and then,
uh, spits out a p vector.
Um, and these are going to be defined by,
well, matrix multiplication by a and b respectively.
So, um, f takes an argument u,
which is a p vector.
And it, what it gives us a result is Au, the matrix A,
g takes in, um,
a vector v, which is an n vector.
And what it gives back is B times v,
the matrix vector product.
These are linear functions, right?
Because they're given by matrix vector multiplication.
[NOISE] Um, now, the composition of the two functions,
um, or some people call it chain is another one.
Uh, but composition is a standard mathematical term.
Um, that's a function that says basically take the output of
g and plug it into the input of f. So that's informally.
Now what that means is this.
Um, this says we're going to define h and so h, let's see,
g maps n vectors,
n vectors to p vectors,
then f maps p vectors to m vectors.
And so we can, we can do g first,
then F. And that would map something, an n vector to an m vector.
Okay. And so the way we write that is, is we say, h of x,
h here is the composition of f and g. Um,
and it says h of x is f of g of x.
Now, you really have to sit here and parse this very carefully to make,
to make absolutely certain that the syntax makes sense and everything like that.
So here, x is an n vector,
g of x is a- I'm going slow to make sure I get it right, is a p vector.
Then we look at f and so in computer science,
you'd say we check the signature of f,
but this is math not computer science.
So we check, we check what f takes as an input.
f takes as an input indeed a p vector. So we're cool.
And then f of g of x is indeed an m vector.
Okay? So by the way,
another notation for this is h equals f and a little circle g. So that's another,
that's a circle that's not the letter O. Um,
it's a, it's a little circle.
So f composed with g. Okay?
Now let's figure out what this composition function is.
Well, h of x is f of g of x,
and that's so f,
to take f of anything,
you simply multiply it by the matrix A.
So we put A there,
g of x is indeed Bx,
so it's a paren time Bx.
Um, but as you know, uh, these,
this is like a matrix triple product if we think of x as a matrix and it is associative,
and that means that I can multiply a and b together.
And so what we see is,
so what we've shown here is very cool.
It says that if you compose two linear functions, um,
the result is linear and not only that,
the associate matrix is
the product of the matrices associated with each of the functions.
So that's another interpretation,
um, oh, uh, one,
one thing I should note here is,
is very is a bit, I, I should note this.
and I'll, I'll, I'll say it. Um, so basically it says matrix multiplication is,
is composition of linear functions.
There is one, um, weird thing here and I,
I thought I'd mention it,
um, and that is that when you see the product AB,
um, like that, uh,
what, what you have to re-,
you know, bear in mind is that b is first, okay?
It looks like it's second when you write A,
B, looks like B, but B is first.
And the reason is that thing multiplies a vector and the first thing to touch the vector,
roughly speaking, is b.
So b comes first.
Uh, so it just means that it's a little bit
backwards and you get used to it and then everything is,
uh, is, is fine.
Okay. So let's look at an example.
And an example is, we're going to,
we're going to start from an example we saw a few, uh,
lectures ago, a few chapters ago,
which was on the difference matrix.
So now remember that dn, uh,
is this n minus 1 by n difference matrix. And here it is.
Uh, what it does is it produces when you multiply this matrix by a vector,
what you get is the vector of first differences.
So it's the second minus the first entry,
the third minus the second,
all the way up to the last minus the penultimate entry.
Okay? So that's the,
that's called the difference matrix.
And you may remember what it looks like.
It looks, you know, like this.
It's got each row has a minus 1 and a 1,
which by now you should kinda get makes sense, right?
So if you take this matrix here and multiply in your mind by an x,
you will see that the first entry the,
of the pro- of the matrix vector product is indeed x_2 minus x_1.
That's what this tells you the mu- the 1 and the minus 1, okay.
So, um, well, we also have d sub n minus 1.
And that is the difference matrix,
uh, but it's a different size.
It's n minus 2 by,
uh, n minus 1.
Uh and what it,
what it does is it takes, uh, it, it,
it simply takes the, uh,
it's also the differences, but it's 1- 1 dimension smaller.
Now, I can actually, uh,
multiply these two matrices because let's see.
Um, I can have dn minus 1 times dn and,
uh, that's an n minus 2 by n. That's a so-called second difference matrix, right?
And what it does is it simply take,
it forms the differences at the vector.
That's the, that's the Dn x.
It takes the differences and then it forms the differences of the differences.
And when you do that, you end up with something that looks like that and it,
this maybe looks familiar to you or maybe not.
The second difference is actually something like the first plus
the third entry minus twice the second entry, right?
So these are the entries of this.
If you take the so-called second difference, by the way,
it's also something like if you like,
you could think of this as a second derivative.
I mean, of course, these are sequences that are not continuous functions,
but they're, um, they're even,
they're finite sequences, they're lists of numbers.
But the point is you, if you want to,
you could think of it as, you know,
a, um, you, you could certainly think of this,
uh, as a second derivative.
Okay? So we'll call delta this matrix Dn minus 1 Dn.
And let's do this for n equals 5.
So, so here it is,
here is the 4 by 5 difference matrix.
Uh, and what it does,
it takes a 5-vector and it spits back the 4 differences.
The differences being the second minus the first, you know,
third minus the second,
fourth minus the third and fifth minus the fourth, right?
So that's what, that's what this one does.
Then you take those you started with,
we started with a, a 5-vector.
Now you've got four differences,
and now you difference those and you're going to end up with a 3-vector,
which is, you know, the, well,
it's the second difference minus the first difference and so on.
And what you do is you will simply multiply these two matrices.
One is there, the two different sized difference matrices.
And you get this matrix here.
And you see that sure enough, it's this thing.
It's exactly the same thing. So it's very cool.
It just shows you, uh,
that you can compose two things.
Um, and it all kind of makes sense.
I think, let's see. Yeah. I think it makes sense.
Uh, okay, actually I think it's wrong because I think these should all be pluses.
But any way, aside from being,
from having a typo on the slides,
it kinda makes sense.