
Matrix Multiplication - kasbah
http://matrixmultiplication.xyz/
======
daniel-levin
This is a cool example of what Bret Victor calls an "Explorable Explanation"
[0]. That said, I feel that it's more important to understand how and why
matrix multiplication corresponds to a composition of linear transformations
than learning the actual mechanics of doing the computation. You can get good
at matrix multiplication without knowing what is going on. I view that as a
less valuable activity than learning about linear transformations (vector-
space structure preserving mappings) between finite dimensional vector spaces.

[0]
[http://worrydream.com/ExplorableExplanations/](http://worrydream.com/ExplorableExplanations/)

~~~
samuell
For understanding the mechanics of matrix multiplication, I found it useful to
think in an analogy consisting of a grid of two layers of pipes; One -- the
input-pipes -- coming in one direction, and the other -- the output pipes --
laid in an orthogonal direction. Then there would be "taps" in the cross-
sections between the input and output pipes, representing the numbers
(multiplication factors, really) in the matrix. I illustrated this in this
little drawing:
[http://imgur.com/gallery/gBs64](http://imgur.com/gallery/gBs64)

The point then is that the taps (again, representing the matrix values)
determine _how much of each item in the input vector, that should be mixed
into each item in the output vector_.

This analogy has the limitation that the taps are allowed to _enhance_ the
flow, not just limit it, like physical taps would. That is, outputting more
than 100% of the input :P Also, while this way of illustrating it may make
some sense for matrix * vector multiplication, matrix * matrix would probably
become a prohibitively cluttered image.

~~~
snovv_crash
I really like that. And matrix * matrix would just have to be 3D, with a whole
cube of taps. Sure, not easy to illustrate, but the concept extends well. It
also makes it more obvious what the complexity of the operation is.

~~~
im3w1l
Actually the complexity of matrix multiplication is not known. Current best is
n^2.37

~~~
dangom
There is a proven lower bound [1], though.

[1]
[http://epubs.siam.org/doi/abs/10.1137/0218052](http://epubs.siam.org/doi/abs/10.1137/0218052)

------
tskaiser
This is cool, but I have a few criticisms:

\- Flipping something over like that looks cool, but confuses the brain. At
least it confused mine.

\- Inconsistently calculating 1 or 2 elements at a time is confusing. Having 2
results calculated at a time simply put requires the recipient to untangle
what is going on. This only gets worse when the recipient tries to do it
themselves for examples with more columns in the right matrix.

Disclaimer: I am biased as I already know how to do matrix operations, and I
visualize it differently. When multiplying by hand I translate the right
matrix up, like in the animation, but do not flip it over. Then I calculate
each element one at a time by taking the sum of products of the row and column
that intersects over that element. Like so:
[http://i.imgur.com/D572zOI.png](http://i.imgur.com/D572zOI.png)

As you can see I'm not much of a graphics artist.

Edit: actually, I think this would be really good if you "filter down" one
column at a time, instead of moving the whole matrix down, so that it only
calculates one element at a time, one column at a time. Means the animation
will contain more steps, but I think that is actually to its benefit. Does
this make sense?

~~~
qb45
> Flipping something over like that looks cool, but confuses the brain. At
> least it confused mine.

I think it would be helpful to have a shadow of the right matrix after it's
moved to the top. This way it would be easier to see where particular numbers
are coming from in the original input.

Disclaimer: I'm similarly biased and actually the reason I came up with this
shadow thing is because I also imagine the right matrix moving like here but
somehow this never causes it to disappear from its original place on paper, go
figure, so this animation looked really alien to me.

------
j1vms
Not sure if anyone here has mentioned this yet, but it's useful to think of
matrix multiplication as the most natural extension of one-dimensional algebra
into multiple dimensions. First, remember that people first wrestled with and
found solutions to "1-D" equations like "ax^2 + bx + c = 0". When others came
along asking about how to extend these results into multiple dimensions so
that previous results might still be useful, the most natural answer was found
to be how we now define matrix multiplication. To see further evidence of
this, take your favorite linear algebraic equation using matrices and then
look at the edge case where you have only 1x1 matrices in your equation.
Usually you'll end up with something that looks analogous to a result in basic
algebra in real number (or complex) variables, not matrices.

If all this still seems counter-intuitive, then realize this is essentially
why math is so important to our logic. It helps us to reason about things that
are not obvious, yet logically must fall through from the basic tautologies we
"chose" (like 0 != 1, addition on integer numbers, etc.). Or, more aptly in
this case, it helps retain an analogous symbolic representation (the overall
logic of the equation at the high level) despite a change in the underlying
nuts and bolts of computing solutions to it (matrix multiplication vs. our
regular "1D" multiplication).

~~~
gunnihinn
I'm sorry, but that's not how that works.

Your example is of a second-degree equation, which can't be solved by linear
algebra. Linear algebra was invented to solve systems of linear equations, and
matrices first arose as a convenient notation for expressing those. Matrix
multiplication came later and is now understood to correspond to the
composition of linear morphisms on vector spaces.

If you try to extend the (very few) methods we have for obtaining exact
solutions to polynomial equations in one variable to higher dimension, you (a)
fail and (b) invent algebraic geometry.

------
zubspace
I like the idea, but my brain is wired differently.

Usually, when I do matrix multiplications, the rows on the left side
transition to the columns on the right side. In the example, the 1 goes to 2,
2 to 6, 1 to 1.

The animation completely confused me, because it looks like being reversed,
but the result is the same.

Maybe, make this a visualization option?

~~~
kutkloon7
I do this too and this is way more intuitive in my opinion, as you can easily
see which entries of the resulting matrix are linear in which rows and
columns. Also, you don't need to transform the matrices in a way that is
impossible to do on paper.

------
ryanmonroe
For me personally, a simple animated version of this image[0] looping through
rows of A and columns of B seems easier to understand.

[0]
[https://upload.wikimedia.org/wikipedia/commons/e/eb/Matrix_m...](https://upload.wikimedia.org/wikipedia/commons/e/eb/Matrix_multiplication_diagram_2.svg)

------
user1713952
The idea is good but I am afraid it misses the point entirely. Multiplying
both columns of the right hand side matrix to the left hand side matrix is
really not helping the target audience understand what is going on. 2
operations are going on as the same time. I believe
[https://www.youtube.com/watch?v=XkY2DOUCWMU](https://www.youtube.com/watch?v=XkY2DOUCWMU)
is a much better way to illustrate the matrix multiplication (and provide a
clear explanation of the why) .

~~~
staltz
Comments like these (aside from providing a nice link) just make authors of
content sad. Why say such thing? You can say "here is another helpful link",
but "misses the point entirely"? The point is to provide a self-evident
mnemonic, as explained here:
[https://github.com/staltz/matrixmultiplication.xyz](https://github.com/staltz/matrixmultiplication.xyz)

Not nice.

~~~
user1713952
Mr Staltz, please allow me to elaborate. I did not mean to be mean at all, nor
to reduce the value of your work, excuse me if I made you feel like that. I am
actually grateful that you made this animation as it allows one to reflect on
the concept.

If your kid proudly brings home a drawing, you are most probably going to
greet him with warm encouragements no matter the quality of the art. The kid
is in a process of developing his creative sense, learning, and forming
his/her sense of reality. Comparing the drawing to what mature artists produce
would certainly have a negative effect on the kid. The point is to provide a
feedback relevant to the recipient of the critic.

The same goes here with this animation. I respect your work but obviously
disagree with the usefulness of it. You made an animation to explain the
matrix product, which is a really good idea. Alas, I think the realization of
it gives a confused picture of what it is. I doubt that a student with no
prior understanding of matrix products will get much enlightment. Too many
operations are going on at the same time. This means that it misses its
intended audience: students in need of building an intuitive understanding of
the matrix product. That's what all those javascript (among others) animations
(ex: [http://jackschaedler.github.io/circles-sines-
signals/dft_int...](http://jackschaedler.github.io/circles-sines-
signals/dft_introduction.html)) are all about: make it simpler to grasp a
concept. Unfortunately, though beautiful, the animation is not clear. At best
it provides a visual mnemonic for multiplying matrices which maybe useful for
some but not for the younger version of me in need of understanding :)

I realize that instead of providing such a harsh critic, I would have been
better inspired to suggest improvements. Mea culpa :)

~~~
staltz
I think your elaboration just made it worse, as you compared my work to a
kid's drawing, and assumed that the target audience will not benefit from
that. I actually have proof against that. In Twitter, over 2000 people have
retweeted, and countless people have commented along the lines of "I wish this
was around when I was studying in school", or "now I finally understand it",
and even school teachers saying thanks and how they'll use it in class next
week. And, even this hackernews thread, for that matter.

~~~
romwell
To back up the parent, unfortunately, the audience is not always qualified to
judge the quality of your work - for the simple reason that they have no idea
what they are missing!

What they are missing from your explanation is "why". Your animation shows how
to multiply two matrices, and anyone confused about the mechanics of doing
that might find it helpful.

But the actual mechanics are not of much use if you don't know why they are
this way. Everything in mathematics is made up by humans, so why would someone
at some point write down this particular set of rules to apply to rectangular
arrays of numbers?

To that end, I reaffirm the parent's opinion that your visualization only
helps to confuse people, giving them a false sense of understanding. There is
already too much emphasis in education on "how", and too little on "why"; the
comments from the teachers you mentioned are downright scary to me.

Perhaps you will take this comment as yet another critique that is too harsh -
but it must be done, so that others don't mistake your animation for an
explanation of concepts behind the operation. When one understands the
concepts, visual mnemonics - like the one you created - are not needed.

To start a productive discussion, however, (which, hopefully, might lead to
you using your skills to come up with a version 2 of your work), I am very
curious to hear your answers to these questions - which people confused about
matrices might have:

1\. What information is actually stored in a matrix? Why write down a bunch of
numbers in a rectangle instead of, say, a list or a triangle (like Pascal's
triangle)?

2\. Why would one want to "multiply" two matrices? That is, why would one want
to combine two matrices, and what information would the "product" matrix
store?

3\. Why do the rules for "multiplication" actually yield the result desired in
(2)? Wouldn't some simpler rule do the same? For instance, if we have two 2x2
matrices, why not just multiply the numbers there elementwise (top left by top
left, top right by top right, etc.)?

My claim is that anyone who can answer these questions wouldn't need your
visualization - and, conversely, your visualization doesn't help answer these
questions at all.

I'd be glad to be proven wrong, so I'm looking forward to your explanations of
the three questions above.

~~~
staltz
I totally acknowledge that it is missing the "why", I knew that from the
beginning. The widget I built simply answers the "how". It's a very focused
tool, and this kind of tool may be very useful in itself. It's a tool to be
used in the context of other tools, like books and courses. Your ordinary
calculator never answers the why question. And if the audience, who includes
both students and teachers, isn't qualified to judge the quality of the work,
who exactly is?

On a side note, it's disgusting (I find that an appropriate word) how
hackernews threads are so harsh and negative. You can do a fun exploration:
search for historical threads announcing tools and services that were
revolutionary (Angular.js or React.js, to name a few), and you'll find a
plethora of negative comments. If hackernews discussions are good judges of
quality, absolutely everything in this world sucks.

~~~
romwell
> And if the audience, who includes both students and teachers, isn't
> qualified to judge the quality of the work, who exactly is?

Again, it is very unfortunate, but on the average, high school teachers
wouldn't be.

For starters, linear algebra (where multiplication belongs) simply isn't
taught at high-school level. It is not in the standard math curriculum in any
state. Bits and pieces of linear algebra, like teaching matrix multiplication
alone, simply don't belong in the high school curriculum.

For that matter, too many high school instructors either don't have deep
enough knowledge of linear algebra themselves, or if they do, they don't have
enough experience or expertise in teaching this subject - simply because it is
not a part of the curriculum.

To compound the problem, too often we don't teach math educators well enough.
The math requirements for math teachers are often significantly lower than for
math majors, and many don't get to see too many facets of mathematics.

To answer your question: matrix multiplication belongs in a university-level
linear algebra course. Our system is so perverse that the version taught to
non-math majors is missing most of the explanations, and even the math majors
don't really learn the linear algebra until their second (or even third) year.

So here's my opinion:

The instructors qualified to judge linear algebra instructional materials
would be people involved in teaching linear algebra courses at a college level
- the professors, TA's, and people running help sessions in universities.

The students would be qualified to judge in retrospect, once they have
themselves learned the material beyond the definition.

>On a side note, it's disgusting [...] how hackernews threads are so harsh and
negative. [...] If hackernews discussions are good judges of quality [...]
this world sucks.

Don't take HN threads as judges of quality - you have seen yourself that they
are not. Yes, they are endless sources of critique, and some of the critique
is valid and useful. Things people here talk about may succeed in spite of the
flaws, but it doesn't mean they are flawless.

And it's great! This thread alone can give you many ideas on where to go from
here if you like making educational props like this one - and how to improve
what you have done. Treat this thread as a feature request, as a todo-list, as
a bug report. You have just got yourself a small army of through beta-testers,
who were kind enough to submit detailed reports (with links and examples!).
Leverage that.

If you need praise: you are a talented programmer, who can create great
visualizations that can help many people get a deeper understanding of things
that you have mastered. And the critique is here because of this potential -
because you really, really, really can do better.

>I totally acknowledge that it is missing the "why", I knew that from the
beginning. The widget I built simply answers the "how".

"How" what?

How humans multiply matrices? Certainly not, I don't cut out one matrix and
put it on top of the other. And, to be frank, if I need to multiply two
matrices, I either use a computer algebra system (or code it up).

How computers multiply matrices? Software like MATLAB or BLAS would use more
complicated algorithms which perform faster (Karatsuba, Strassen, whatever).

In the end, your tool is just a visual mnemonic for a definition. It's a
SOHCAHTOA for matrices. And really do think we don't need more of that in
education.

> Your ordinary calculator never answers the why question.

That's why there should be way more caution in using calculators in classrooms
than is currently exercised. The current way of things is horrendous, but
doesn't have to be. I have designed Calculus labs with MATLAB in which, I
hope, the computer is not doing anything that the students could do by hand
(given a lot of time). Done this way, calculators and computers become tools
which aid understanding.

Anyway, regardless of what the motivation of others here was, here is where
I'm coming from:

I've taught linear algebra help sessions where by the middle of the semester
the students could multiply, row-reduce, invert matrices without having a clue
what they are doing. They could put a bunch of vectors in a matrix and do -
what to them was - some number magic to check for linear dependence.

I would draw them two arrows on the board pointing in different directions,
and ask them a simple question - are these vectors linearly independent or
not? They would be thoroughly lost.

That's the state of linear algebra education in the US. We are teaching people
mechanical operations that computers do better.

There are better approaches! Linear Algebra Done Right (S. Axler), for
example, is one of the few books that justifies the definition of matrix
multiplication. Practical Linear Algebra does everything visually, and is
suitable for beginners. But the first text is only taught to math majors, and
the second one is not widely used.

In any case, I am highly opposed to teaching the mechanics an operation,
because with a good understanding, people will come up with the mechanics
themselves.

You are an example of this. Having an understanding of the operation allowed
you to come up with a visualization. But the visualization, in my opinion,
doesn't set one on a path to develop a similar understanding. And this is
where your work can be improved.

For instance, take this: [https://betterexplained.com/articles/matrix-
multiplication/](https://betterexplained.com/articles/matrix-multiplication/)
[https://betterexplained.com/articles/linear-algebra-
guide/](https://betterexplained.com/articles/linear-algebra-guide/)

Is this a perfect explanation? Maybe not, and it's not animated. But the
author tries to pass on the way to get a better understanding, a new angle on
how to understand the operations being done.

Would doing things like that with an animation be challenging? Certainly. But
don't blame the audience for having a high expectation of what you can do.

------
inglor
Question for staltz - are you happy with the cycle code at
[https://github.com/staltz/matrixmultiplication.xyz/](https://github.com/staltz/matrixmultiplication.xyz/)
? It feels like a lot of work for this sort of task which I feel could have
been achieved by using an existing (mutable) matrix lib and drawing ad-hoc. It
feels like an awful lot of code written - especially with all the `.something
=== "SOME_STRING_CONSTANT"` (couldn't those be typed directly in TS btw?).

Still, you're a smart guy - I'm trying to see why it's worth it. Do you really
feel model-view-intent shines here?

(Nice visualization by the way)

~~~
staltz
Yes, I'm very happy with that code, apart from one thing: how animations are
done sometimes with tweens in JS, and sometimes with CSS.

I'm sure it could have been built with less code. In general, the more
shortcuts you take and the less abstraction you use, the less amount of code
you will have. But also, it's likely that you would mix concerns more easily.
So in general, when separating concerns, you end up getting more LOCs. That's
what I've perceived in my experience, not a fact that I can prove.

So I do feel like model-view-intent shines here. Model only has state
concerns. I was careful in moving away DOM-related code from the model. So
theoretically you could reuse this model for React Native or any other UI
target. View only displays state in a visual representation, and intent only
captures user events and represents them in a form suitable for the model.

About some TypeScript code, I think you referred to
[https://github.com/staltz/matrixmultiplication.xyz/blob/mast...](https://github.com/staltz/matrixmultiplication.xyz/blob/master/src/Calculator/model/actions.ts#L58-L80).
These could have been avoided. The only purpose they serve is to make
inference work out for lines like these:
[https://github.com/staltz/matrixmultiplication.xyz/blob/mast...](https://github.com/staltz/matrixmultiplication.xyz/blob/master/src/Calculator/model/reducers/controlPanel.ts#L16-L17)
TypeScript knows that `action` is of type StartMultiplyAction. If we had only
done `.filter(ac => ac.type === 'START_MULTIPLY')`, TypeScript couldn't infer
anymore. So I understand those isFoo functions are very boilerplatey, but they
serve the purpose to provide accurate typings. It's optional and depending how
you write TypeScript code, you can use more type casting and more `any`, or
you can go down the route of providing accurate types everywhere, which is
what I did. This is not at all related to Cycle.js nor MVI.

Feel free to ask more architecture-related questions. I like these. What else
feels like "too much code"?

------
cousin_it
I think a cool way to visualize matrix multiplication would be to put three
matrices MxN, NxK, MxK on the sides of a three-dimensional box MxNxK. Each
cell of the matrix MxK would cast a "shadow" onto some row in the MxN matrix
and some column in the NxK matrix, whose dot product would give the value of
that cell.

~~~
kakarot
Would you mind elaborating or providing a link for the uninitiated? I use
matrix multiplication in almost everything I do and that sounds like a neat
way to visualize what is happening.

------
jayajay
It's easier to think of matrix multiplication by computing the matrix
elements, which means reducing the problem to NM vector dot products.

To get the element of the result matrix at position (n,m), compute the inner
product < r_n | c_m >, where r_n is the nth row vector of the left matrix and
c_m is the mth column vector of the right matrix. Once you try it, you'll see
that it's also much easier to visualize than this strange, unintuitive
approach.

With great power comes great responsibility. That domain name belongs to that
person. I hope they do society a favor and put more content regarding MM that
that, because they chose one of the least intuitive ways of thinking about it.
Put more ways up, or ditch the domain.

If the goal is to get people to understand what matrices are, the best way is
to teach them about operators, transformations, vector spaces and linear
algebra in general, because this is really the only way to fully understand
what's going on without relying on some heuristic.

If the goal is to get people to remember how to do matrix multiplication, at
least put up more ways of doing it.

~~~
staltz
Nope, won't ditch the domain. I'd recommend you ditch that type of speech.

~~~
jayajay
I'm sorry if my words upset you. That said, it would be a shame to tell
someone off if they bring up a good point (however brash). I used to teach
this stuff, and I can tell you many of my students would end up being more
confused with your visualization. I hope you can see that you've assumed some
responsibility. That's all I can hope.

------
shultays
Change to color of rows to red & blue (while multiplying) so it is easier to
which result is which product.

~~~
kejaed
This is a great idea

------
JabavuAdams
Neat visualization. I feel it's important and eye-opening to note that there's
not just one way to multiply matrices, there're five (according to Strang):

5 ways to multiply A B = C

1) Each element of C is a dot-product of corresponding rows of A with columns
of B

2) Each column of C is a combination of the columns A. Each column of B has
the coefficients.

3) Each row of C is a combination of the rows of B. Each row of A has the
coefficients.

4) Accumulate outer-product. Accumulate sums of of outer-products of each col
of A with each row of B.

5) Block multiplication

They all produce the same answer, but different ones provide different insight
for particular situations.

See Video Lecture #3 of Strang's Linear Algebra course for more info:
[https://ocw.mit.edu/courses/mathematics/18-06-linear-
algebra...](https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-
spring-2010/video-lectures/lecture-3-multiplication-and-inverse-matrices/)

~~~
jasonx1e
His lectures are awesome, wish some of them could be remastered though

------
hdivider
Awesome.

Some concepts in math are so much easier to grasp with an interactive visual.
I once made an entire game around matrix multiplication -- such that players
didn't even know they learned how to do this.

And sometimes, visualizations can help cause discoveries. A lot of progress in
theoretical physics came about because physicists 'guessed' what nature's
equations should look like...and then got shocked when they discovered they
were right.

Take James Clerk Maxwell, for instance:

"He had achieved his greatest success by relying on just one empirical fact
known to every school boy. Yet now he tried to do without any empirical facts,
by pure thinking. He believed in the power of reason to guess the laws
according to which God has built the world."

[http://www.mathpages.com/home/kmath103/kmath103.htm](http://www.mathpages.com/home/kmath103/kmath103.htm)

~~~
abecedarius
I'm curious about this game. Is it online?

~~~
hdivider
I built it for the Windows 8 Store (of all places), years ago, in base C++/Cx.
All de-published now though. Could dig up a gameplay video if you wish...

~~~
abecedarius
Thanks, but I'm just curious and don't like videos. The world needs more
things like that, though -- it was nice to hear of it.

------
wodenokoto
As others have mentioned, many introductions to linear algebra / matrix
multiplication only gives the student a formula, but not why the formula looks
like it does.

Why is matrix multiplication not pointwise, was something I had a hard time
understanding.

Better explained has a good article on this, that really made it click for me

[https://betterexplained.com/articles/linear-algebra-
guide/](https://betterexplained.com/articles/linear-algebra-guide/)

------
IshKebab
This is nearly how I think of it, but for me I do one column of the second
matrix at a time. I think it is clearer that way. This way makes it look like
there is some kind of staircase thing going on which there isn't really.

~~~
nickcw
That was my thought too - I was taught to do one row of the first matrix with
one column of the second matrix at a time.

I found the whole staircase thing quite confusing.

------
ivan_ah
Nice illustration of the "row picture" of matrix multiplication. The "column
picture" is equally important. This intro lecture by Prof. Strang is a really
good lesson on that: [https://ocw.mit.edu/courses/mathematics/18-06-linear-
algebra...](https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-
spring-2010/video-lectures/lecture-1-the-geometry-of-linear-equations/)

Also, this short tutorial on linear algebra covers the row + column pictures
on the first page:
[https://minireference.com/static/tutorials/linear_algebra_in...](https://minireference.com/static/tutorials/linear_algebra_in_4_pages.pdf)
(disclaimer: I'm the author)

------
mfirmin
This reminds me of Nicky Case's Explorable Explanation of a 2D transformation
matrix: [http://ncase.me/matrix/](http://ncase.me/matrix/)

------
hacker_9
As a gamedev who uses matrices all the time, I don't find this animation
useful at all for practical work. Instead I think of matrix multiplication as
creating a list of ordered operations (scale x translate x rotate etc) which
is just encoded efficiently in a table, to then be sent to other parts of the
program for use. You can even remove items from the list by multiplying by
their inverse.

~~~
scraft
But of course when you have encoded the scale, rotate and translate into the
matrix, it isn't possible to decode it back out to your original values. This
is obvious if you consider the fact the following produce identical matrices
(just consider 2D for now):

1\. Scale in X and Y of -1

2\. Z rotation of 180

~~~
hacker_9
Yes, I know, what is your point exactly? When I say 'list of ordered
operations' I mean that if I were to apply the matrix to any object, you can
imagine each transform in the list being applied one after another to the
object visually, resulting in the final position.

------
FeepingCreature
This is sounding increasingly like the Monad situation, where everybody has
their own incompatible approach for explaining it, and none of them make any
sense.

I feel like I understand Matrices _less_ now than when I started reading
around here.

~~~
maxiepoo
If by "Monad situation" you mean trying to learn a concept by just reading a
single blog post then sure. Trying to learn something by scattered blog posts
without engaging in material is a bad idea no matter what the problem is. For
some reason nobody expects to read a blog post and understand the fundamental
theorem of calculus without first learning intuition and doing calculations
with derivatives _and_ integrals. On the other hand, if you have been working
through a concept and you read a blog post that gives a different perspective
than you're used to, it might help.

If you want to actually learn something, then get something like a book or
series of posts and work through examples and explore the ideas yourself. But
having more than one intuition is _useful_ and complaining about the fact that
there is more than one way to understand something is _lazy_.

------
tvural
Matrices are linear maps, and matrix multiplication composes the linear maps.
Now statements like the determinant of the product is the product of the
determinants, the trace is preserved under similarity transforms (since
similarity transforms just rewrite the linear map in a different basis), etc.
are intuitive.

I've always felt that these explicit calculations don't really get to the
point. You can memorize them and still not really understand what's going on.

~~~
gunnihinn
Maybe you know something I don't, but I don't find these statements about the
determinant and trace intuitive just from knowing that matrix multiplication
corresponds to composition of linear maps. They can be made intuitive by
appealing to geometry, but I don't see how to do that just by staring at the
algebraic picture.

Actually, proving them without picking a basis and then showing that what you
get is invariant under base change is quite nontrivial and involves throwing a
lot of heavy machinery around; see for example Coffman's non-coordinate proof
of the statement about the trace in
[http://users.ipfw.edu/CoffmanA/pdf/book.pdf](http://users.ipfw.edu/CoffmanA/pdf/book.pdf)

For the determinant, if you want to do everything without picking a basis,
you're basically proving that the exterior power operation defines a functor
on the category of finite-dimensional vector spaces, which isn't that bad to
do, but you somehow have to explain what all those words mean along the way.

------
Jaruzel
I have never understood Matrix Multiplication - which has always prevented me
from doing cool 3D stuff.

Now I do! THANK YOU! :)

~~~
clarry
You totally don't need matrices to do cool 3D stuff though.

------
amelius
How I would explain it:

\- First, show how to multiply a row vector by a column vector.

\- Then, show how to "simultaneously" multiply several row vectors by a single
column vector by placing the row vectors in a matrix.

\- Now, similarly, do the same with the column vector. And voila, matrix by
matrix multiplication.

~~~
appleflaxen
im trying to understand this, and what you said appeals to me but i can't
quite visualize what you mean. do you have an illustration?

------
ww2
I think this is overdone and does not help the intuition. two things: (1). the
first step of transposing the second matrix 90 degree is unnecessary and
confusing. A row vector and a column vector are different. This step confuses
the two. (2). All the final elements are independent and should be calculated
in parallel, the stepped anime is not necessary and does not reveal this basic
fact.

------
greggman
This is very cool. For me I needed to know why it works not what it does.

I worked it out here for 2d transformations
[http://webglfundamentals.org/webgl/lessons/webgl-2d-matrices...](http://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html)
and then expanded it to 3d, perspective, and cameras.

------
vladsotirov
The UI confuses me to the point of frustration.

1\. A "Previous" button would help since otherwise you have to go loop through
the whole thing to see what actually happened (e.g. how exactly the first step
lifts and rotates the matrix, what's getting added to what).

2\. The final animation step is a transition from the patently false equation
"[matrix1]=[result_matrix]" to the finally correct equation "[matrix1] x
[matrix2] = [result_matrix]". This could be avoided if instead of transforming
"[matrix1] x [matrix2]" into "[matrix1 plus overlay]=[result_matrix to be
filled]" and then doing the 'waterfall', the equation "[matrix1] x [matrix2] =
[result_matrix to be filled]" was maintained throughout, perhaps with the
moving overlay slightly grayer after lifting [matrix2].

------
rsp1984
Very nice, but the mental model I prefer is to think of a Matrix-Vector
multiplication as the weighted sum of Matrix columns, and a Matrix-Matrix
multiplication as just several Matrix-Vector multiplications (results being
the columns of a new matrix).

------
gregn610
Nice. I needed something like that when I was getting started with ML courses.

------
jakehoon
This would have been so awesome to have in college. I stumbled upon RegExr the
other day ([http://regexr.com](http://regexr.com)) which I absolutely love. It
kind of shares this spirit of showing people how to do things that appear
complex at first glance, but have a sort of addicting nuance to them. Thanks
for sharing.

------
jordigh
I find this image a lot easier to work with. The animation above just seems a
tad confusing:

[https://staff.fnwi.uva.nl/r.vandenboomgaard/IPCV/_images/Mat...](https://staff.fnwi.uva.nl/r.vandenboomgaard/IPCV/_images/Matrix_multiplication_diagram_2.png)

------
adamnemecek
I have found the Stanford EE263 class to be possibly the best class on linear
algebra. This might be due to the fact that it's technically a class about
linear dynamic systems not linear algebra per se

[http://ee263.stanford.edu/](http://ee263.stanford.edu/)

------
kafkaesq
I my head I see the matrices remaining in place, while the vectors from the
left slowly float to the right, produce dot products, which in turn float into
their destination cells in the new output matrix just to the right of the
equals sign.

But that's just me.

------
thanatropism
See the very first video in Strang's MIT Linear Algebra course on YouTube.

There's two ways of seeing matrix multiplication (from a matrix POV, rather
than as linear transformations).

------
daw___
Awesome. What about making it more clear that the "End" button will animate
remaining steps? Before clicking it I thought it would have jumped to the last
step.

------
scalablenotions
Thank you! This is marvelous and really made me understand this process at a
much simpler level. Please consider making more for other mathematical
concepts :)

------
cocktailpeanuts
I have no idea what's going on there.

But it's a cool piece of art, I'm guessing that was the intention.

------
lima
Appropriate use of the .xyz TLD :-)

------
NumberCruncher
I wish we had visualizations like this back in the 90's when I studied
statistics.

------
kasbah
I wonder if this visualization could be turned into a fun game.

------
matteuan
Nice, now let's do it with the Strassen's algorithm

------
hodder
Cool visualization.

------
jasonx1e
Now make one that can find inverses ( ͡° ͜ʖ ͡°)

------
esalman
Another one for matrix inversion would be nice.

------
rockdoe
Misrenders on Firefox for Android.

~~~
staltz
Yeah, I'm aware. It annoys me too.
[https://github.com/staltz/matrixmultiplication.xyz/issues/1](https://github.com/staltz/matrixmultiplication.xyz/issues/1)

------
mrcactu5
this is more than just visualization. i can touch the computation. each step
is tangible

------
joshaidan
Interesting, I wonder why Facebook has this website blocked, preventing me
from posting it on my wall.

~~~
staltz
Good sign that it's time to leave Facebook. Really

------
Vinkekatten
Meh, the site is blocked at my workplace. Websense is really crummy.

------
coin
Uggg, why is zoom disable on mobile devices?

------
known
Cool

------
HeavyStorm
I read the title and thought, oh God, not another one, the second was bad
enough and I like to pretend that the third never happened...

