## Learn to Use ITensor

main / tutorials / 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:

$$=\langle\psi|\hat H|\psi\rangle$$

and the summation we are representing here is

$$=\sum_{\begin{matrix} \sigma_1\ldots\sigma_5\\\\ \sigma_1'\ldots\sigma_5'\\\\ \end{matrix}} \sum_{ \begin{matrix} b_1'\ldots b_4'\\\\ a_1\ldots a_4\\\\ b_1\ldots b_4\\\\ \end{matrix}} A_{b_1'b_2'}^{\sigma_2'\dagger}A_{b_1'}^{\sigma_1'\dagger}A_{b_2'b_3'}^{\sigma_3'\dagger}A_{b_3'b_4'}^{\sigma_4'\dagger}A_{b_4'}^{\sigma_5'\dagger}H_{a_1}^{\sigma_1'\sigma_1}H_{a_1a_2}^{\sigma_2'\sigma_2}H_{a_2a_3}^{\sigma_3'\sigma_3}H_{a_3a_4}^{\sigma_4'\sigma_4}H_{a_4}^{\sigma_5'\sigma_5}A_{b_1}^{\sigma_1}A_{b_1b_2}^{\sigma_2}A_{b_2b_3}^{\sigma_3}A_{b_3b_4}^{\sigma_4}A_{b_4}^{\sigma_5}$$

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:

$$=A^\mu$$

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

$$=A^{\mu\nu}$$
Index mu("mu",m),nu("nu",n);//for an (m x n) matrix
ITensor A(mu,nu);


A trace over matrices would look like

$$=\sum_{\alpha\beta\gamma\eta} A^{\alpha\beta}B^{\beta\gamma}C^{\gamma\eta}D^{\eta\alpha}$$
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:

$$=\sum_{\gamma\delta\eta\mu} A^{\alpha\beta\gamma\delta\eta\mu}B^{\gamma\delta\eta\mu\nu\zeta}$$
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