These problems practise reading diagrams (Problem 1.1), counting contraction costs (Problem 1.2) and working with isometries and gauges (Problem 1.3, Problem 1.4). The last two, Problem 1.5 and Problem 1.6, go with the hands-on gaps in the notebooks.
Problem 1.1 (Warm-up: indices and diagrams).
- A tensor
has shape and is stored in row-major order. At which position (counting from 1) of the flat list is the entry ? In column-major order? - Draw the diagram of
. How many open legs does it have, and what is its order? - Draw
and for three matrices and explain why the diagrams are the same.
Solution
- Row-major: the last index runs fastest, so the position is
. This is why detrand(2,3,4)[2,1,3]in both notebooks equals the 15th number of the hash sequence,. Column-major: the first index runs fastest, . has legs ; has legs ; has leg . Connect between and and between and . The open legs are and , so is a matrix (order 2). - Both are a ring: the column leg of
joins the row leg of , the column leg of joins the row leg of , and the column leg of joins the row leg of . A diagram only records which legs are connected, not where we start reading, so the cyclic property of the trace is built into the notation.
Problem 1.2 (Cost of an expectation-value step).In the MPS norm step of the notes, insert a one-site operator
( ) between and :
- Find an order with total cost
, and show that it never needs an intermediate with more than entries. - Show that every order that contracts
with before costs at least . - In Module 4 the operator is a matrix product operator tensor
with bond dimension , and gets a third leg . Generalize the good order and give its cost.
Solution
- First
: indices , cost . Then : indices , cost . Finally : indices , cost . The intermediates and have entries each. - If
(or ) meets before , the intermediate keeps the four open bond legs and the contraction involves a physical leg as well, so by the counting rule it costs at least , and its result has entries. costs . Then involves : . Finally involves : . The total is . For the TFIM ( , ) the terms dominate once .
Problem 1.3 (Properties of isometries).Let
be an matrix with and .
- Show that
for every , and that is an orthogonal projector of rank . When is ? - Let
and be left isometries across the cuts and . Show that their contraction is a left isometry across . Draw the diagram of the proof.
Solution
. For the projector, and ; its rank is . It is the identity only if its rank is , that is when and is unitary. - We need
. Write it out: using first that
is a left isometry (the bracket is ) and then that is. In the diagram, the - pair closes into a line (as in the isometry figure of the notes), and then the - pair does too. Repeating this argument site by site shows that a chain of left isometries is a left isometry for the whole left block, the key property of the canonical form in Module 2.
Problem 1.4 (Spectra survive isometries).Let
across a bond, where is a left isometry ( , ) and is .
- Show that
and have the same nonzero singular values. - Show that for any invertible
the singular values of are the same as those of , but that the singular values of are in general not those of . - Explain why this makes QR (rather than SVD) enough to bring a network into a form where the singular values across one bond can be read off from a single small tensor.
Solution
. The nonzero singular values are the square roots of the nonzero eigenvalues of these equal matrices, so they agree. (Equivalently, if then is an SVD of , because is again an isometry.) is the same matrix, so its singular values cannot change. But has singular values equal to those of (since ), which are all only if is unitary. Hands-on 1.5 shows the same effect on a generic (not isometric) : a random changes from to while the spectrum of stays . - Take the bond between sites
and . QR sweeps from the left make sites left isometries, so by Problem 1.3 their block, together with the identity on the physical leg , is one big isometry . Part 1 alone would only say that the singular values are those of everything else, a large matrix. So also make sites right isometries by LQ sweeps from the other end; their block satisfies . The matrix across the bond is then , where is the site- tensor reshaped as a matrix (left bond and physical leg as rows, right bond as columns). Part 1 removes , and its mirror image, , removes . So the singular values across the bond are those of the single small tensor , and one SVD of a matrix gives them. QR and LQ sweeps make the SVD of the large matrix unnecessary; this is the mixed canonical form of Module 2.
Problem 1.5 (Hands-on 1.2 and 1.3: contractions by hand).In Hands-on 1.2 you implemented
contract_by_matmulforwith shapes and , and in Hands-on 1.3 the function pair_cost.
- What does
pair_costreturn for this contraction, and what are the shapes of the two matrices that get multiplied?- Suppose you fused
on but on . Would the code fail? What would the result be? - Hands-on 1.3 prints cost ratios
at for . What are the ratios for , and why does the bad order become relatively less bad as grows at fixed ?
Solution
- All indices
are involved, so the cost is multiply-adds. The matrices are ( ) and ( ); their product is , and . - Both fused indices have length 20, so the shapes match and the code runs without an error. But row
of one matrix now pairs with for different pairs of values, so the result is over mismatched index pairs: a wrong matrix of the right shape. The check against einsum(or TensorKit’s@tensor) in the notebook exists to catch exactly this.- The ratio is
, so for it is : . Both costs grow linearly in , but the bad order has the extra step that does not involve (contracting into ). That step is a fixed fraction of the bad cost, so its relative weight shrinks as grows: the prefactor falls from at to at and towards for large . The ratio is still controlled by , not by : the bad order is always at least times slower.
Problem 1.6 (Hands-on 1.5 and 1.6: gauge and dense Hamiltonian).
- In Hands-on 1.5,
gauge_fix_leftreturnswith for a bond of dimension 4. Show that for every left isometry. - In Hands-on 1.6, how many terms does
ising_hamiltonianadd forsites, and how much memory does the dense take for and in Float64? - The notebooks check
against with the bidiagonal matrix with on the diagonal and above it. For , verify this formula by hand.
Solution
. For this gives . The value does not depend on at all, which shows that norms of individual tensors carry no gauge-invariant information. - There are
bond terms and field terms, in total, each a Kronecker product. The dense has entries: entries or 512 KiB for , and entries or 2 GiB for . Building it also creates temporaries of the same size, so is at the edge of a laptop. - For
there is no bond term, with ground energy . The matrix has one singular value , so . The general formula comes from the Jordan-Wigner mapping to free fermions (1). The singular values are the quasiparticle energies , so and the ground state, with no quasiparticles, has . For the single quasiparticle energy is exactly the gap between the eigenvalues and of .