Hacker News new | ask | show | jobs
by JWKennington 2594 days ago
Slight nit-pick, but matrix multiplication is not exclusively a contraction, but rather a contraction on the tensor product of the two matrices. See the next paragraph for why this is concerning.

I find this notation great for simple applications, but potentially unwieldy for dim > 2. For instance, how would I represent the tensor (or outer) product of two matrices? the inputs would be two circles with two lines attached to each, the result would need to be a single circle with four lines attached. The natural attempt would be something like:

  a    - o -
      /    /
     |    /
     \   |
  ab  ---o---
         |   \
        /    |
       /    /
  b    - o -
But I suspect the above diagram isn't correct because there are no "open" indices at the end of this. Rather, this diagram seems to represent the contraction of a 4D tensor with 2, 2D tensors.

It seems we we would need a way of connecting circles without implying a contraction of a particular index.

Anyone know how to annotate the outer product of two matrices in this diagrammatic convention?

1 comments

A tensor product of two matrices is just this, with 4 loose ends:

    ---A---
    ---B---
A_ab B_cd = (A⊗B)_acbd. If a,c=1...N then you can think of (ac) as being an index with N^2 possible values, which is what the double line now means... if you like, you may compact it a bit:

    ===(A⊗B)===
But how am I supposed to know that AB is one mathematical object here instead of the 2 separate objects A, B? My point is that there should be a graphical way other than "put them arbitrarily close" to link them together

I prefer your second notation, with the tensor product happening in parenthesis, but it kind of defeats the point of the graphical nature of the notation if we need to explictly write the tensor product I think..

Speaking as someone who uses this tensor notation quite a lot: putting multiple objects into the same diagram is what a tensor product is, and a great thing about the notation is that it reveals that a tensor product of two matrices is not an essential object in itself.

If you wish, you can draw a circle around A and B to "factor out" that part of the diagram as a sub tensor product. Here might be a way to show that matrix multiplication is both "tensor product then contract" and "function composition": https://imgur.com/tcCycYj.png (though I didn't give this gray-circle notation much thought).

Think about this: how is it in a product abcd of plain old numbers am I supposed to see the mathematical object ad without putting them arbitrarily close together? (Well, in standard notation, you do put them close together and write (ad)bc or something.)

The equations satisfied by tensor products are exactly those of drawing things next to each other. Look up Bob Coeckes Kindergarten Quantum Mechanics which was linked elsewhere here.

What you need is two parallel walls where lines can start and end. The rest is all fine.