27
$\begingroup$

Penrose graphical notation seems to be a convenient way to do calculations involving tensors/ multilinear functions. However the wiki page does not actually tell us how to use the notation.

The several references, especially ones with Penrose as author, must be good places to start. But it is now the summer holiday and I am away from my school library. So I am wondering whether someone here has a nice introduction to "the use" of Penrose graphical notation.

Thanks!

$\endgroup$
5
  • 6
    $\begingroup$ His book Road to Reality explains and uses it in places. $\endgroup$
    – rschwieb
    Commented Jul 1, 2013 at 13:46
  • 3
    $\begingroup$ I think the notation you are talking about has been generalized somewhat to something called "String diagrams". See Qiaochu's blog post on them here and also this nLab article (or probably more importantly, the references therein). $\endgroup$ Commented Jul 1, 2013 at 14:00
  • 4
    $\begingroup$ I have used the Penrose notation for long tensor calculations, which I learned as birdtracks. I would not had attempted what I did with the index notation. $\endgroup$
    – Hbar
    Commented Sep 11, 2013 at 0:47
  • $\begingroup$ youtube.com/watch?v=QGccZUhf27c $\endgroup$
    – Babu
    Commented May 15, 2022 at 7:57
  • $\begingroup$ math.stackexchange.com/questions/2917/… $\endgroup$
    – Babu
    Commented May 22, 2022 at 13:37

3 Answers 3

7
$\begingroup$

TensorNetwork.org or tensors.net are great places to see introductory examples, and the math3ma blog has a wonderful little intuitive introduction, while Hand-waving and interpretive dance: an introductory course on tensor networks is a nice reference to understand this notation more systematically. Additionally, I have written my own introduction to the notation, heavily inspired by the other references. It's aimed for a machine learning / interpretability context, but should be mostly understandable to everyone.

Here are some excerpts:

In graphical notation, tensors are represented as shapes with "legs" sticking out of them. A vector can be represented as a shape with one leg, a matrix can be represented as a shape with two legs, and so on:

Penrose notation - basics

Each leg corresponds to an index of the tensor - specifying an integer value for each leg of the tensor addresses a number inside of it:

Penrose notation - indexing

where 0.157 happens to be the number in the (i=0,j=2,k=0) position of the tensor A. In python, this would be A[0,2,0]. The amount of memory required to store a tensor grows exponentially with the number of legs, so tensors with lots of legs are usually represented only implicitly: decomposed as operations between many smaller tensors.

Connecting the legs of two tensors indicates a tensor contraction (also known as an Einstein summation). Here are the most common kinds of contractions between vectors and matrices:

Penrose notation - familiar

In every case you can tell how many legs the resulting tensor will have by the number of uncontracted "free'' legs on the left.

But graphical notation is most useful for representing unfamiliar operations between many tensors. One example in this direction is $\sum_{\alpha \beta} A_{i \alpha \beta}v_{\beta}B_{\alpha \beta j}=M_{ij}$, which can be represented in graphical notation as

Penrose notation - more_complicated

The middle part of the graphical notation here shows that the number in each i, j position of the final matrix can be calculated with a sum over every possible indexing of the internal legs α and β, where each term in the sum consists of three numbers being multiplied (though in practice the contraction should be calculated in a much more efficient way).

Graphical notation really comes into its own when dealing with larger networks of tensors. For example, consider the contraction $\sum_{i\,j\,k\,l\,m\,n\,o\,p\,q\,r\,s\,t\,u} A_{ij} V_{ir} B_{jkl} W_{rks} C_{lmn} X_{smt} D_{nop} Y_{tou} E_{pq} Z_{uq},$ which is tedious to parse: indices must be matched up across tensors, and it is not immediately clear what kind of tensor (eg. number, vector, matrix ...) the result will be. But in graphical notation this is Penrose notation - ladder and we can immediately see which tensors are to be contracted, and that the result will be a single number. Contractions like this can be performed in any order. Some contraction orders are much more efficient than others, but they all get the same answer eventually.

$\endgroup$
1
  • $\begingroup$ I have since written my own introduction to Penrose graphical notation, here: lesswrong.com/posts/BQKKQiBmc63fwjDrj/… It is aimed for a machine learning context as it has einops / PyTorch code alongside the diagrams, but should be mostly understandable to everyone. $\endgroup$ Commented Dec 7, 2023 at 2:24
6
$\begingroup$

There are nice notes from a tutorial given at Siggraph in 2002 here : http://research.microsoft.com/apps/pubs/default.aspx?id=79791

$\endgroup$
3
$\begingroup$

There is succinct medium article covering it from the ground up. I am not aware of anything that goes into too much apart from what the previous answer points to

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .