## 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;
```

## MPSs and MPOs

Returning to our example at the top of the page. One tensor in a matrix product state (purple or red block) has two or three indices. The vertical lines (superscripts) have a different meaning from the horizontal lines (sub-indices). In ITensor, they are defined as a rank two or three tensor: one Site (or physical) index and one or two link indices.

One tensor in a matrix product operator (gray boxes) has two physical indices and one or two link indices. So, it is a rank three or four tensor. The tensors on the edge of the network (sites 1 and 5) have a different form from those in the bulk (sites 2-4). One can see this by the different numbers of indices on the edges. That is why there is one less link index on each of the MPS and the MPO.

### IQMPS

To keep things simple, we've left off arrows in our diagrams. We'll discuss the role of these when we discuss the quantum block structure for IQTensors.

### @@\Lambda\Gamma@@ notation

We have used here the AB notation of left and right normalized tensors. There is also a notation with @@\Lambda@@ and @@\Gamma@@ matrices that is useful for discussing iDMRG|.

Back to Tutorials

Back to Main