## Learn to Use ITensor

How to Read Tensor Diagrams

Thomas E. Baker—August 20, 2015

In classical physics, free body diagrams represent the sum of forces in Newton's equations. In quantum field theories, Feyman diagrams represent integrals found in perturbative calculations. Both examples express a mathematical equation as a picture; tensor network diagrams do the same for summations.

For example, the expectation value of a Hamiltonian as a tensor diagram looks like:

and the summation we are representing here is

which shows why we wanted to draw these diagrams instead of writing out this summation. The diagram is clearer—once you understood how to read them.

In this discussion, we will see what the diagrams represent, how to understsand each shape and line in a diagram, and understand other things you might see in a diagram. We will also connect this with the MPS| and MPO| tensor networks used for DMRG and other tensor network methods in another discussion. Better yet, we'll make sure to connect this entire discussion with ITensor code you can use for your own projects!

## Diagrams 101

Each diagram will consist of blobs connected by lines. Each blob represents a tensor (an object with indices) and each line is the index of that tensor.

For example, one tensor with one line is a vector:

To make a vector in ITensor, one may use the code

```
Index mu("mu",m);//Index mu ranges from 1 to m
ITensor A(mu);
```

Since a matrix is a rank two object (there are two indices), the diagrammatic representation looks like

```
Index mu("mu",m),nu("nu",n);//for an (m x n) matrix
ITensor A(mu,nu);
```

A trace over matrices would look like

```
Index a("a",z),b("b",y),c("c",x),d("d",w),e("e",v);
ITensor A(a,b),B(b,c),C(d,e),D(e,a);
ITensor Tr = A*B*C*D;
```

Note that when two ITensors are multiplied with the `*`

operator, any matching Index is automatically summed over!

Diagrams can be simple, like those above, or they can be complicated like this one:

```
Index a("a",z),b("b",y),c("c",x),d("d",w),e("e",v),
f("f",u),g("g",t),h("h",s);
ITensor A(a,b,c,d,e,f),B(c,d,e,f,g,h);
ITensor C = A*B;
```

Back to Tutorials

Back to Main