Chapter 3: Quantum Many-Body Physics Primer

Chapter 3: Quantum Many-Body Physics Primer#

We introduce the occupation-number description of interacting fermions, normal ordering and the matrix elements of one- and two-body Hamiltonians. The Lipkin, pairing, Hubbard and Heisenberg models supply reproducible benchmarks and illustrate the uses and limits of symmetry reduction. We derive configuration interaction and Hartree–Fock theory, including orbital stability, then contrast projected coupled cluster with variational unitary coupled cluster. The last two sections take the step to the quantum computer: the Jordan–Wigner transformation, the qubit encodings of the four models, Pauli rotations and Trotter steps as circuits, the measurement of a sum of Pauli strings with a finite number of shots, and a first unitary coupled-cluster circuit. These are the building blocks of the chapters that follow.

\[ \newcommand{\bm}[1]{\boldsymbol{#1}} \newcommand{\wick}[1]{\overline{#1}} \newcommand{\matr}[1]{\boldsymbol{#1}} \newcommand{\bfv}[1]{\boldsymbol{#1}} \renewcommand{\vec}[1]{\boldsymbol{#1}} \newcommand{\uvec}[1]{\boldsymbol{\hat{#1}}} \newcommand{\op}[1]{\widehat{#1}} \newcommand{\Op}[1]{\boldsymbol{\widehat{#1}}} \newcommand{\OP}[1]{\boldsymbol{\widehat{#1}}} \newcommand{\Det}[1]{|\boldsymbol{#1}|} \newcommand{\bigO}{\mathcal{O}} \newcommand{\var}{\mathrm{Var}} \newcommand{\cov}{\mathrm{Cov}} \newcommand{\real}[1]{\mathrm{Re}\left\{#1\right\}} \newcommand{\ud}[1]{d#1} \newcommand{\udd}[1]{d^2#1} \newcommand{\mean}[1]{\langle #1 \rangle} \newcommand{\overlap}[2]{\langle #1 | #2 \rangle} \newcommand{\bracket}[3]{\langle #1 | #2 | #3 \rangle} \newcommand{\projection}[2]{| #1 \rangle \langle #2 |} \newcommand{\brab}[1]{\big\langle #1 \big|} \newcommand{\ketb}[1]{\big| #1 \big\rangle} \newcommand{\bket}[1]{\vert #1\rangle} \newcommand{\bbra}[1]{\langle #1\vert} \newcommand{\ketbra}[2]{\vert #1\rangle\langle #2\vert} \newcommand{\braket}[2]{\langle #1\vert #2\rangle} \]
# Put every BookPrograms/chapter*/ and BookPrograms/common/ on sys.path
import sys, pathlib
root = pathlib.Path.cwd().resolve()
while not (root / 'BookPrograms').is_dir() and root.parent != root:
    root = root.parent
sys.path[:0] = sorted(str(p) for p in (root / 'BookPrograms').iterdir() if p.is_dir())
import numpy as np

Introduction#

The systems we want to study on a quantum computer are collections of interacting particles: electrons in atoms, molecules and solids, nucleons in nuclei, cold atoms in traps, spins on a lattice. What they have in common is that a fixed number of local degrees of freedom per site or particle leads, at fixed filling, to a Hilbert space whose dimension grows exponentially with system size. Storing a general state is therefore expensive classically. This does not make every many-body problem hard: symmetries, weak correlations and tensor structure can permit efficient classical treatments. A quantum register supplies a natural representation, but useful calculations also require feasible state preparation, evolution and measurement. This chapter collects the many-body physics that the rest of the book relies on. It is a primer rather than a treatise: every concept is introduced in the minimal form in which it is needed later, and every one of them is illustrated on the same four model Hamiltonians, so that the reader can follow the numbers from a formula to a program to a table.

Section Second quantization introduces second quantization, the language in which many-body Hamiltonians are written and in which the mapping to qubits of Section From fermions to qubits is formulated. The models themselves are presented in Section Four model Hamiltonians: the Lipkin model, the pairing model, the Hubbard model and the Heisenberg model. Each of them can be solved exactly for small sizes, each has a symmetry that reduces the problem, and each is used again and again in the later chapters as a test case for quantum algorithms. Section Full configuration interaction discusses exact diagonalization, or full configuration interaction, the method against which everything else is measured, and explains why it cannot scale. Section Hartree–Fock theory introduces the mean-field, or Hartree–Fock, approximation, together with two mathematical tools that reappear throughout the book: the Baker–Campbell–Hausdorff expansion and the Trotter–Suzuki splitting of exponentials of non-commuting operators. Section Coupled-cluster theory presents coupled-cluster theory, the most successful classical wave-function method for correlated fermions, and its unitary variant, whose general exact evaluation has no known efficient classical procedure but which supplies an important ansatz for the variational quantum algorithms of Chapter 6. Sections From fermions to qubits and From Pauli sums to circuits and measurements then take the step to the quantum computer: the Jordan–Wigner transformation, the qubit form of the four models, the circuits that exponentiate and measure a sum of Pauli strings, and a first variational circuit. The chapter closes with exercises and with the list of the programs that produce every number quoted in it.

Throughout the chapter we use the notation established in Chapter 2: \(\hbar=1\), \(\vert 0\rangle\) and \(\vert 1\rangle\) for the two states of a two-level system, and the Pauli matrices \(X\), \(Y\) and \(Z\). Single-particle states are labeled by \(p,q,r,s\) when they can be any state, by \(i,j,k,l\) when they are occupied in a reference state and by \(a,b,c,d\) when they are unoccupied. Matrices are written in bold when the distinction from an operator matters.

Second quantization#

Creation and annihilation operators#

Consider a set of \(M\) orthonormal single-particle states \(\vert\phi_p\rangle\), \(p=0,1,\ldots,M-1\), which could be the eigenstates of a one-body Hamiltonian, a set of lattice sites with spin, or any other convenient basis. The independent-particle state obtained by occupying \(N\) distinct orbitals is described, in first quantization, by a Slater determinant

\[\begin{equation*} \Phi(x_1,\ldots,x_N) = \frac{1}{\sqrt{N!}} \begin{vmatrix} \phi_{p_1}(x_1) & \phi_{p_1}(x_2) & \cdots & \phi_{p_1}(x_N) \\ \phi_{p_2}(x_1) & \phi_{p_2}(x_2) & \cdots & \phi_{p_2}(x_N) \\ \vdots & \vdots & & \vdots \\ \phi_{p_N}(x_1) & \phi_{p_N}(x_2) & \cdots & \phi_{p_N}(x_N) \end{vmatrix},\tag{3.1} \end{equation*}\]

which changes sign when two particles are exchanged and vanishes when two of the indices \(p_k\) coincide, so that the Pauli principle is built in. Working with determinants directly is clumsy: the number of particles is fixed, the antisymmetrization has to be carried along in every calculation, and matrix elements of operators between determinants require the bookkeeping of the Slater–Condon rules. Second quantization replaces all of this by an algebra of operators.

We introduce, for every single-particle state \(p\), a creation operator \(a^{\dagger}_p\) and its Hermitian conjugate, the annihilation operator \(a_p\), and define the Slater determinant of Eq. (3.1) as the state obtained by creating the particles one after the other on the vacuum \(\vert 0\rangle\), the state with no particles,

\[ \vert\Phi\rangle = \vert p_1 p_2\cdots p_N\rangle = a^{\dagger}_{p_1}a^{\dagger}_{p_2}\cdots a^{\dagger}_{p_N}\vert 0\rangle, \qquad a_p\vert 0\rangle = 0 \ \text{for all } p.\tag{3.2} \]

The antisymmetry of the determinant is then equivalent to the requirement that the creation operators anticommute among themselves, and the orthonormality of the single-particle basis to the requirement that creation and annihilation operators anticommute up to a Kronecker delta,

\[ \{a_p, a^{\dagger}_q\} = a_p a^{\dagger}_q + a^{\dagger}_q a_p = \delta_{pq}, \qquad \{a_p, a_q\} = \{a^{\dagger}_p, a^{\dagger}_q\} = 0 .\tag{3.3} \]

Everything else follows from Eq. (3.3). Setting \(p=q\) in the second relation gives \((a^{\dagger}_p)^2=0\): a state cannot be occupied twice, which is the Pauli principle. The operator

\[ \hat{n}_p = a^{\dagger}_p a_p\tag{3.4} \]

satisfies \(\hat{n}_p^2 = a^{\dagger}_p a_p a^{\dagger}_p a_p = a^{\dagger}_p(1-a^{\dagger}_p a_p)a_p = \hat{n}_p\), so its eigenvalues are \(0\) and \(1\): it counts whether state \(p\) is occupied, and \(\hat{N}=\sum_p\hat{n}_p\) counts the particles. The space spanned by all states of the form of Eq. (3.2), for all particle numbers from \(0\) to \(M\), is the Fock space. Its dimension is \(2^M\), and it is the direct sum of the \(N\)-particle spaces of dimension \(\binom{M}{N}\).

Because the eigenvalues of every \(\hat{n}_p\) are \(0\) or \(1\), a basis state of Fock space is completely specified by a string of \(M\) bits, one per single-particle state,

\[ \vert n_0 n_1 \cdots n_{M-1}\rangle, \qquad n_p\in\{0,1\},\tag{3.5} \]

the occupation-number representation. This is the representation in which second quantization and quantum computing meet: a register of \(M\) qubits has exactly the basis states of Eq. (3.5), and in Section From fermions to qubits the qubit \(\vert 1\rangle\) will mean “occupied”. In this chapter we already adopt the corresponding conventions: single-particle state \(p\) is the \(p\)-th bit from the left, and the ordered product of creation operators in Eq. (3.2) is taken with increasing indices, \(p_1<p_2<\cdots<p_N\), so that the state with bits \(n_p\) is

\[ \vert n_0 n_1\cdots n_{M-1}\rangle = \left(a^{\dagger}_0\right)^{n_0}\left(a^{\dagger}_1\right)^{n_1}\cdots \left(a^{\dagger}_{M-1}\right)^{n_{M-1}}\vert 0\rangle .\tag{3.6} \]

The action of \(a^{\dagger}_p\) on such a state is then fixed by anticommuting \(a^{\dagger}_p\) past the operators to its left,

\[\begin{align*} a^{\dagger}_p\vert n_0\cdots n_p\cdots n_{M-1}\rangle &= \delta_{n_p,0}\,(-1)^{\sum_{q<p}n_q}\, \vert n_0\cdots 1_p\cdots n_{M-1}\rangle,\\ a_p\vert n_0\cdots n_p\cdots n_{M-1}\rangle &= \delta_{n_p,1}\,(-1)^{\sum_{q<p}n_q}\, \vert n_0\cdots 0_p\cdots n_{M-1}\rangle .\tag{3.7} \end{align*}\]

The sign counts the occupied states with an index smaller than \(p\), that is the number of operators that \(a^{\dagger}_p\) has to jump over to reach its canonical position. This parity is the whole content of fermionic statistics in the occupation-number representation, and it is the origin of the strings of \(Z\) operators in the Jordan–Wigner transformation of Section The Jordan–Wigner transformation. As an example, with \(M=16\) and the state \(\vert 3\,6\,10\,13\rangle\), that is the bit string \(0001001000100100\), the program second_quantization.py gives

\[\begin{align*} a^{\dagger}_4\vert 3\,6\,10\,13\rangle &= -\vert 0001101000100100\rangle, \qquad a^{\dagger}_6\vert 3\,6\,10\,13\rangle = 0, \\ a^{\dagger}_{12}\vert 3\,6\,10\,13\rangle &= -\vert 0001001000101100\rangle , \end{align*}\]

where the first sign comes from the single occupied state \(3\) to the left of \(4\), and the last from the three states \(3,6,10\) to the left of \(12\). The rule is a few lines of code:

def apply_creation(bits, p):
    """Creation on a list of occupation bits (mode 0 leftmost)."""
    if bits[p] == 1:
        return 0, None
    sign = (-1) ** sum(bits[:p])
    new = list(bits)
    new[p] = 1
    return sign, new

bits = [int(b) for b in "0001001000100100"]
print(apply_creation(bits, 4))
(-1, [0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0])

Operators as matrices#

Since Fock space has dimension \(2^M\), every operator on it is a \(2^M\times2^M\) matrix, and for small \(M\) it is instructive, and for the programs of this book practical, to construct these matrices explicitly. For a single state, \(M=1\), the Fock space is spanned by \(\vert 0\rangle\) and \(\vert 1\rangle\) and

\[\begin{equation*} a = \begin{pmatrix} 0 & 1 \\ 0 & 0\end{pmatrix} = \vert 0\rangle\langle 1\vert, \qquad a^{\dagger} = \begin{pmatrix} 0 & 0 \\ 1 & 0\end{pmatrix} = \vert 1\rangle\langle 0\vert, \qquad \hat{n} = a^{\dagger}a = \begin{pmatrix} 0 & 0 \\ 0 & 1\end{pmatrix} .\tag{3.8} \end{equation*}\]

In the language of Chapter 2, \(a^{\dagger}=(X-iY)/2\) and \(a=(X+iY)/2\) are the raising and lowering operators of a qubit, and \(\hat{n}=(I-Z)/2\). For \(M\) states the basis is the tensor product of \(M\) such two-dimensional spaces, and the naive guess \(a_p = I\otimes\cdots\otimes a\otimes\cdots\otimes I\) fails: operators on different factors of a tensor product commute, whereas Eq. (3.3) demands that they anticommute. The sign rule of Eq. (3.7) shows what is missing. The factor \((-1)^{\sum_{q<p}n_q}\) is the eigenvalue of \(\prod_{q<p}(1-2\hat{n}_q) =\prod_{q<p}Z_q\) on the state, so that

\[ a_p = \underbrace{Z\otimes Z\otimes\cdots\otimes Z}_{p\ \text{factors}} \otimes\, a\,\otimes\underbrace{I\otimes\cdots\otimes I}_{M-p-1\ \text{factors}}, \qquad a^{\dagger}_p = Z^{\otimes p}\otimes a^{\dagger}\otimes I^{\otimes(M-p-1)} .\tag{3.9} \]

Because \(Z\) anticommutes with \(a\) and \(a^{\dagger}\) on the same factor and commutes with everything else, two operators \(a_p\) and \(a_q\) with \(p<q\) pick up exactly one relative sign, from the \(Z\) on factor \(p\) of \(a_q\) against the \(a\) on factor \(p\) of \(a_p\), and this is what turns the commutation of tensor factors into anticommutation. The program fockspace.py builds these matrices and checks all \(M^2\) anticommutators numerically; for \(M=4\) the largest violation is zero to machine precision. Equation (3.9) is the Jordan–Wigner transformation of Section The Jordan–Wigner transformation written as a matrix, and the string of \(Z\)’s is what will be called the parity string there. The parity sign is required by fermionic statistics. This particular string is the Jordan–Wigner realization for our chosen mode ordering; other encodings distribute that information differently.

One- and two-body operators#

We consider Hamiltonians with at most two-body interactions: a one-body part, the kinetic energy and an external potential, and a two-body interaction. In second quantization

\[ \hat{H} = \sum_{pq} h_{pq}\, a^{\dagger}_p a_q + \frac{1}{4}\sum_{pqrs}\langle pq\vert v\vert rs\rangle\, a^{\dagger}_p a^{\dagger}_q a_s a_r ,\tag{3.10} \]

with the one-body matrix elements \(h_{pq}=\langle p\vert\hat{h}\vert q\rangle\) and the antisymmetrized two-body matrix elements

\[ \langle pq\vert v\vert rs\rangle = \langle pq\vert\hat{v}\vert rs\rangle - \langle pq\vert\hat{v}\vert sr\rangle, \qquad \langle pq\vert v\vert rs\rangle = -\langle qp\vert v\vert rs\rangle = -\langle pq\vert v\vert sr\rangle = \langle qp\vert v\vert sr\rangle .\tag{3.11} \]

The factor \(1/4\) compensates for the fact that each physically distinct pair of states appears four times in the unrestricted sum. Note the order of the annihilation operators, \(a_s a_r\), opposite to the order of the ket indices; it is what makes the expectation value in a two-particle state come out with a positive sign. The proof that Eq. (3.10) reproduces the first-quantized Hamiltonian \(\sum_i \hat{h}(x_i)+\sum_{i<j}\hat{v}(x_i,x_j)\) on Slater determinants is standard and we do not repeat it; what matters for us is that once the matrix elements \(h_{pq}\) and \(\langle pq\vert v\vert rs\rangle\) are tabulated, Eq. (3.10) defines the Hamiltonian on all of Fock space at once, for every particle number, and that the three fermionic models below have this form with sparse matrix elements. The Heisenberg model is constructed directly in spin space. Three-body interactions, when needed, require additional terms.

The matrix elements of \(\hat{H}\) between two occupation-number states follow from the anticommutators. A one-body operator \(a^{\dagger}_p a_q\) moves one particle from \(q\) to \(p\), so it connects states that differ in at most one particle replacement (two changed occupation bits); a two-body operator connects states differing by at most two particle replacements. These are the Slater–Condon rules: for a state \(\vert\Phi\rangle\) with occupied set \(\{i\}\),

\[\begin{align*} \langle\Phi\vert\hat{H}\vert\Phi\rangle &= \sum_{i} h_{ii} + \frac12\sum_{ij}\langle ij\vert v\vert ij\rangle ,\tag{3.12}\\ \langle\Phi_i^a\vert\hat{H}\vert\Phi\rangle &= h_{ai} + \sum_{j}\langle aj\vert v\vert ij\rangle ,\tag{3.13}\\ \langle\Phi_{ij}^{ab}\vert\hat{H}\vert\Phi\rangle &= \langle ab\vert v\vert ij\rangle ,\tag{3.14} \end{align*}\]

and zero for states differing by three or more particle replacements, where \(\vert\Phi_i^a\rangle = a^{\dagger}_a a_i\vert\Phi\rangle\) and \(\vert\Phi_{ij}^{ab}\rangle = a^{\dagger}_a a^{\dagger}_b a_j a_i\vert\Phi\rangle\) are the singly and doubly excited states.

The companion program checks these rules against the explicit \(2^M\times2^M\) matrices for a random Hamiltonian on four states, for instance \(\langle 01\vert\hat{H}\vert 01\rangle = h_{00}+h_{11} +\langle 01\vert v\vert 01\rangle = 4.038893\). The rules imply that the Hamiltonian matrix in a basis of determinants is sparse, with at most \(1+N(M-N)+\binom{N}{2}\binom{M-N}{2}\) non-zero elements per row, and this sparsity is what makes exact diagonalization feasible at all (Section Full configuration interaction).

The particle-hole formalism and normal ordering#

For a system with many particles the vacuum \(\vert 0\rangle\) is a poor starting point; the natural reference is a chosen determinant \(\vert\Phi_0\rangle\), often obtained by filling the \(N\) lowest one-body orbitals (a Fermi sea). Occupied and virtual labels below refer to this chosen reference, whether or not it is the energy-minimizing one. Relative to \(\vert\Phi_0\rangle\) an excitation is described by moving a particle from an occupied state \(i\) to an unoccupied state \(a\), that is by creating a hole in \(i\) and a particle in \(a\). The operators that create excitations are therefore \(a^{\dagger}_a\) (a particle above the Fermi level) and \(a_i\) (a hole below it), and the operators that annihilate them are \(a_a\) and \(a^{\dagger}_i\). The reference state is annihilated by all of the latter,

\[ a_a\vert\Phi_0\rangle = 0 \quad (a>F), \qquad a^{\dagger}_i\vert\Phi_0\rangle = 0 \quad (i\le F),\tag{3.15} \]

which is the same structure as \(a_p\vert 0\rangle=0\) with the roles of some operators interchanged. One says that \(\vert\Phi_0\rangle\) is the Fermi vacuum.

A product of creation and annihilation operators is in normal order with respect to \(\vert\Phi_0\rangle\) when all operators that annihilate \(\vert\Phi_0\rangle\) stand to the right of all operators that do not. The normal-ordered form of a product \(ABC\cdots\), written \(N[ABC\cdots]\) or \(\{ABC\cdots\}\), is obtained by reordering the operators as if they anticommuted freely, with the sign of the permutation, and every nonempty normal-ordered string has vanishing expectation value in the reference state, \(\langle\Phi_0\vert N[\cdots]\vert\Phi_0\rangle=0\). The difference between a product and its normal-ordered form is a contraction,

\[ \wick{AB} = AB - N[AB] = \langle\Phi_0\vert AB\vert\Phi_0\rangle,\tag{3.16} \]

which is a number. With respect to the Fermi vacuum the only non-zero elementary contractions are

\[ \wick{a_a a^{\dagger}_b} = \delta_{ab} \ (a,b>F), \qquad \wick{a^{\dagger}_i a_j} = \delta_{ij} \ (i,j\le F),\tag{3.17} \]

while contractions of two creation or two annihilation operators, and those in the opposite order, vanish. Wick’s theorem states that any product of creation and annihilation operators equals its normal-ordered form plus the sum over all possible ways of contracting pairs of operators, each term being the normal-ordered product of the remaining operators times the contractions, with the sign of the fermionic permutation that brings each contracted pair together and leaves the remaining operators in their original order inside the normal-ordering symbol. Counting only crossings is sufficient for fully contracted strings; partial contractions also acquire signs from moving past uncontracted operators. For example, for three fermionic operators,

\[ ABC=N[ABC]+\wick{AB}C-\wick{AC}B+\wick{BC}A .\tag{3.18} \]

Taking the expectation value in \(\vert\Phi_0\rangle\) kills all terms that still contain a normal-ordered product, so that

\[ \langle\Phi_0\vert A_1A_2\cdots A_{2n}\vert\Phi_0\rangle = \sum_{\text{full pairings}} (-1)^{k} \wick{A_{i_1}A_{j_1}}\cdots\wick{A_{i_n}A_{j_n}} .\tag{3.19} \]

The number of full pairings of \(2n\) operators is \((2n-1)!!=1,3,15,105\) for \(n=1,2,3,4\), and most of them vanish by Eq. (3.17); what the theorem buys is that one never has to anticommute operators through each other by hand. The program second_quantization.py evaluates a few vacuum expectation values both ways, for instance \(\langle 0\vert a_1 a_0 a^{\dagger}_1 a^{\dagger}_0\vert 0\rangle=-1\) from the crossing of the two contraction lines, and confirms that the matrix products agree with the pairing count.

The normal-ordered Hamiltonian#

Applying Wick’s theorem to the Hamiltonian of Eq. (3.10) with respect to the reference determinant gives the central formula of this section,

\[ \hat{H} = E_{\mathrm{ref}} + \sum_{pq} f_{pq}\,N[a^{\dagger}_p a_q] + \frac14\sum_{pqrs}\langle pq\vert v\vert rs\rangle\, N[a^{\dagger}_p a^{\dagger}_q a_s a_r] = E_{\mathrm{ref}} + \hat{F}_N + \hat{V}_N ,\tag{3.20} \]

with the reference energy and the Fock matrix

\[ E_{\mathrm{ref}} = \sum_{i\le F} h_{ii} + \frac12\sum_{ij\le F}\langle ij\vert v\vert ij\rangle, \qquad f_{pq} = h_{pq} + \sum_{i\le F}\langle pi\vert v\vert qi\rangle .\tag{3.21} \]

The reference energy is the expectation value of \(\hat{H}\) in \(\vert\Phi_0\rangle\), Eq. (3.12); the Fock matrix contains the one-body part plus the mean field that the occupied states exert on a particle in state \(q\); and the normal-ordered two-body term \(\hat{V}_N\) contains what is left, the genuine two-particle correlations. Equation (3.20) is exact, it is the form of the Hamiltonian from which Hartree–Fock theory (Section Hartree–Fock theory), perturbation theory and coupled-cluster theory (Section Coupled-cluster theory) all start, and the Slater–Condon rules read off from it are particularly transparent: the matrix elements of \(\hat{H}\) between the reference and its single and double excitations are

\[ \langle\Phi_i^a\vert\hat{H}\vert\Phi_0\rangle = f_{ai}, \qquad \langle\Phi_{ij}^{ab}\vert\hat{H}\vert\Phi_0\rangle = \langle ab\vert v\vert ij\rangle .\tag{3.22} \]

The first of these will vanish at the Hartree–Fock solution (Brillouin’s theorem); the second is the driving term of perturbation theory and of the coupled-cluster equations. With the matrices \(h\) and \(v\) tabulated as numpy arrays, \(E_{\mathrm{ref}}\) and \(f\) are one line each,

import numpy as np
from models import PairingModel
model = PairingModel(4, g=1.0)
h, v, N = model.h, model.v, 4
occ = range(N)                                   # the reference: states 0 ... N-1
E_ref = sum(h[i, i] for i in occ) + 0.5 * sum(v[i, j, i, j] for i in occ for j in occ)
f = h + np.einsum("piqi->pq", v[:, :N, :, :N])   # f_pq = h_pq + sum_i <pi|v|qi>
print(E_ref, np.diag(f))                         # 1.0 and the Fock energies xi(p-1) - g/2, xi(p-1)
1.0 [-0.5 -0.5  0.5  0.5  2.   2.   3.   3. ]

and second_quantization.py verifies Eq. (3.22) against the explicit matrices.

A worked example: two modes#

The smallest Hamiltonian with all the ingredients of Eq. (3.10) has two single-particle states with energies \(\varepsilon_0\) and \(\varepsilon_1\), a hopping amplitude \(t\) between them, and an interaction \(U\) that acts when both are occupied,

\[ \hat{H} = \varepsilon_0\hat{n}_0 + \varepsilon_1\hat{n}_1 + t\left(a^{\dagger}_0a_1 + a^{\dagger}_1a_0\right) + U\hat{n}_0\hat{n}_1 ,\tag{3.23} \]

that is \(h_{00}=\varepsilon_0\), \(h_{11}=\varepsilon_1\), \(h_{01}=h_{10}=t\) and the single antisymmetrized element \(\langle 01\vert v\vert 01\rangle=U\). Its Fock space has four states, \(\vert 00\rangle\), \(\vert 01\rangle\), \(\vert 10\rangle\) and \(\vert 11\rangle\), and since \(\hat{H}\) conserves the particle number the \(4\times4\) matrix is block diagonal,

\[\begin{equation*} \hat{H} = \begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & \varepsilon_1 & t & 0 \\ 0 & t & \varepsilon_0 & 0 \\ 0 & 0 & 0 & \varepsilon_0+\varepsilon_1+U \end{pmatrix},\tag{3.24} \end{equation*}\]

with the vacuum, the one-particle block, and the doubly occupied state on the diagonal. The one-particle block is the two-level system of Chapter 2, with eigenvalues \(\frac{\varepsilon_0+\varepsilon_1}{2}\pm\sqrt{\left(\frac{\varepsilon_0-\varepsilon_1}{2}\right)^2+t^2}\); the interaction is felt only by the two-particle state, where there is nothing for it to mix with. For \(\varepsilon_0=1\), \(\varepsilon_1=2\), \(t=0.3\) and \(U=0.5\) the program second_quantization.py builds the matrix from Eq. (3.9) and finds the eigenvalues \(0\), \(0.9169\), \(2.0831\) and \(3.5\). Note the ordering of the basis: \(\vert 01\rangle\), with state \(0\) empty and state \(1\) occupied, has the energy \(\varepsilon_1\), in keeping with the convention that the leftmost bit is state \(0\). This Hamiltonian returns in Section A Hamiltonian on two qubits as the first example of a mapping to two qubits, where Eq. (3.24) is what the qubit Hamiltonian must reproduce.

Bosons and spins#

Bosonic creation and annihilation operators satisfy commutation rather than anticommutation relations, \([b_p,b^{\dagger}_q]=\delta_{pq}\), \([b_p,b_q]=0\), and a mode can hold any number of particles; a two-body bosonic Hamiltonian is \(\hat H=\sum_{pq}h_{pq}b_p^\dagger b_q+ \frac12\sum_{pqrs}v^{\mathrm{bare}}_{pqrs}b_p^\dagger b_q^\dagger b_s b_r\). Equivalently, one may use \(1/4\) with the explicitly symmetrized element \(v^{\mathrm{bare}}_{pqrs}+v^{\mathrm{bare}}_{pqsr}\). The prefactor must match the convention for the matrix elements. Bosons do not appear in the models of this chapter, but two hybrids do. A hard-core boson is a boson whose mode can hold at most one particle: on a single mode it is identical to a fermion, Eq. (3.8), while operators on different modes commute instead of anticommuting. A spin-\(1/2\) is the same object, with \(\hat{S}^+=\vert{\uparrow}\rangle\langle{\downarrow}\vert\) as the creation operator and \(\hat{S}^z+\frac12\) as the number operator, which is why the Heisenberg model of Section The Heisenberg model can be written in terms of Pauli matrices without any sign rule. And the pair operators of the pairing model, \(\hat{P}^+_p=a^{\dagger}_{p+}a^{\dagger}_{p-}\), act as hard-core bosons within the empty-or-paired local subspace: moving two fermionic operators past two others gives four interchanges, so \(\hat{P}^\pm_p\) commutes with \(\hat{P}^\pm_q\) for \(p\ne q\), while \((\hat{P}^+_p)^2=0\) and \([\hat P^-_p,\hat P^+_p]=1-\hat N_p\). Singly occupied levels are blocked and are not part of this two-state pair encoding. Whenever the physics is carried by such composite objects, the parity string of Eq. (3.9) is not needed, and the qubit encodings of Section The four models on a qubit register become correspondingly cheaper. A qubit, in this language, is a hard-core boson.

Four model Hamiltonians#

The four models provide complementary tests of the methods introduced here. Lipkin, pairing and Hubbard have fermionic one- and two-body tensors \(h\) and \(v\); Heisenberg acts directly on spins and is assembled from Pauli matrices. Each has useful symmetries, but their reductions have different scaling and require identifying the sector of interest. The shared module models.py supplies these constructions, and fci.py compares the resulting spectra.

The Lipkin model#

The Lipkin–Meshkov–Glick model describes \(N\) fermions distributed over two levels, each \(\Omega\)-fold degenerate, separated by an energy \(\varepsilon\). A single-particle state is labeled by \(p=1,\ldots,\Omega\) and by \(\sigma=\pm1\) for the upper and lower level, and the Hamiltonian is

\[ \hat{H} = \frac{\varepsilon}{2}\sum_{p\sigma}\sigma\, a^{\dagger}_{p\sigma}a_{p\sigma} + \frac{V}{2}\sum_{pp'\sigma} a^{\dagger}_{p\sigma}a^{\dagger}_{p'\sigma}a_{p'-\sigma}a_{p-\sigma} + \frac{W}{2}\sum_{pp'\sigma} a^{\dagger}_{p\sigma}a^{\dagger}_{p'-\sigma}a_{p'\sigma}a_{p-\sigma} .\tag{3.25} \]

The \(V\) term moves two particles from one level to the other; the \(W\) term moves one up and one down. Neither changes the label \(p\) of the particles it acts on, and this is the symmetry of the model. Defining the quasispin operators

\[ \hat{J}_z = \frac12\sum_{p\sigma}\sigma\,a^{\dagger}_{p\sigma}a_{p\sigma}, \qquad \hat{J}_+ = \sum_p a^{\dagger}_{p+}a_{p-}, \qquad \hat{J}_- = \hat{J}_+^{\dagger} ,\tag{3.26} \]

The anticommutators give the angular-momentum algebra,

\[\begin{align*} [\hat{J}_+,\hat{J}_-]&=2\hat{J}_z, & [\hat{J}_z,\hat{J}_\pm]&=\pm\hat{J}_\pm. \end{align*}\]

The Hamiltonian becomes

\[ \hat{H} = \varepsilon\hat{J}_z + \frac{V}{2}\left(\hat{J}_+^2+\hat{J}_-^2\right) + \frac{W}{2}\left(\hat{J}_+\hat{J}_- + \hat{J}_-\hat{J}_+ - \hat{N}\right) .\tag{3.27} \]

Since \(\hat{H}\) commutes with \(\hat{J}^2\), it is block diagonal in the basis \(\vert J,J_z\rangle\), and we use the maximal-quasispin block \(J=N/2\), of dimension \(N+1\), with \(N=\Omega\). For the attractive couplings used in the tables, direct comparison with the full particle-number sector confirms that it contains the ground state; commutation with \(\hat J^2\) alone does not establish this for arbitrary parameters. In that block the matrix elements follow from the ladder relations \(\hat{J}_\pm\vert J,J_z\rangle = \sqrt{J(J+1)-J_z(J_z\pm1)}\,\vert J,J_z\pm1\rangle\), and the \(V\) term connects \(J_z\) to \(J_z\pm2\) only, so the block splits further according to the parity \((-1)^{J_z+J}\) of the number of promoted particles. This definition also applies to half-integer \(J\). For \(N=4\), \(J=2\), the matrix in the basis \(\vert 2,-2\rangle,\ldots,\vert 2,2\rangle\) is

\[\begin{equation*} \hat{H} = \begin{pmatrix} -2\varepsilon & 0 & \sqrt{6}\,V & 0 & 0 \\ 0 & -\varepsilon + 3W & 0 & 3V & 0 \\ \sqrt{6}\,V & 0 & 4W & 0 & \sqrt{6}\,V \\ 0 & 3V & 0 & \varepsilon + 3W & 0 \\ 0 & 0 & \sqrt{6}\,V & 0 & 2\varepsilon \end{pmatrix},\tag{3.28} \end{equation*}\]

where the \(W\) term contributes \(\frac{W}{2}[2J(J+1)-2J_z^2-N]\) on the diagonal. For \(\varepsilon=2\), \(V=-1/3\) and \(W=-1/4\) the \(5\times5\) matrix has the eigenvalues \(-4.21288\), \(-2.98607\), \(-0.91914\), \(1.48607\) and \(4.13201\), and the ground state has weight \(0.936\) on the reference \(\vert 2,-2\rangle\), all four particles in the lower level. Diagonalizing the full \(\binom{8}{4}=70\)-dimensional four-particle space of Eq. (3.25) gives the same lowest eigenvalue to all digits, which is a check of both the quasispin algebra and the general machinery. Table 3.1 lists a second, more strongly coupled case where the reference state has lost half of its weight. In the mean-field language of Section Hartree–Fock theory the dimensionless coupling \(\chi=\vert V\vert(N-1)/\varepsilon\) controls the stability threshold for \(W=0\) and \(V<0\), and the Lipkin model is the standard example of a mean-field phase transition.

\(V\)

\(W\)

eigenvalues of the \(J=2\) block

\(\vert\langle 2,-2\vert\Psi_0\rangle\vert^2\)

\(E_0\) (\(70\times70\))

\(-1/3\)

\(-1/4\)

\(-4.21288,\ -2.98607,\ -0.91914,\ 1.48607,\ 4.13201\)

\(0.93576\)

\(-4.21288\)

\(-4/3\)

\(-1\)

\(-7.75122,\ -7.47214,\ -1.55581,\ 1.47214,\ 5.30704\)

\(0.41303\)

\(-7.75122\)

Table 3.1: The Lipkin model with \(N=\Omega=4\), \(\varepsilon=2\): eigenvalues of the \(J=2\) block and the weight of the reference state \(\vert 2,-2\rangle\) in the ground state. The last column is the lowest eigenvalue in the full \(70\)-dimensional four-particle space. Produced by fci.py.

The pairing model#

The pairing model describes \(L\) doubly degenerate levels \(p=1,\ldots,L\) with energies \(\xi(p-1)\), each holding a pair of time-reversed states \((p+)\) and \((p-)\), and an interaction that scatters a pair from one level to another,

\[ \hat{H} = \xi\sum_{p\sigma}(p-1)\,a^{\dagger}_{p\sigma}a_{p\sigma} - \frac{g}{2}\sum_{pq} a^{\dagger}_{p+}a^{\dagger}_{p-}a_{q-}a_{q+} .\tag{3.29} \]

It is the simplest model of nuclear superfluidity and of the BCS mechanism of superconductivity. Its symmetry is expressed by the pair operators

\[ \hat{P}^{+}_p = a^{\dagger}_{p+}a^{\dagger}_{p-}, \qquad \hat{P}^{-}_p = a_{p-}a_{p+}, \qquad \hat{N}_p = a^{\dagger}_{p+}a_{p+} + a^{\dagger}_{p-}a_{p-},\tag{3.30} \]

in terms of which \(\hat{H} = \xi\sum_p(p-1)\hat{N}_p - \frac{g}{2}\sum_{pq}\hat{P}^+_p\hat{P}^-_q\). The interaction moves pairs as units, so the number of unpaired particles, the seniority, is conserved, and for attractive pairing (\(g>0\)) the even-system ground state is fully paired. For the repulsive values tabulated here we verify the ground-state sector explicitly rather than infer it from symmetry. At seniority zero, every level is either empty or doubly occupied. In the seniority-zero space a state is specified by the set of occupied levels, so with \(n\) pairs in \(L\) levels the dimension is \(\binom{L}{n}\) rather than \(\binom{2L}{2n}\). The matrix of \(\hat{H}\) in this basis has the diagonal elements \(2\xi\sum_{p\in\text{occ}}(p-1) - gn/2\), where the \(-gn/2\) comes from the \(p=q\) terms, and the off-diagonal element \(-g/2\) between any two configurations that differ by moving one pair. For \(L=4\) and two pairs the seniority-zero matrix is \(6\times6\), against \(70\times70\) for the full four-particle space, and Table 3.2 shows that the two agree. The table also defines the correlation energy \(E_{\mathrm{corr}}=E_0-E_{\mathrm{ref}}\), here defined relative to the chosen reference as the difference between the exact ground-state energy and the energy of the reference determinant with the two lowest levels filled, which equals the conventional correlation energy when this reference is the Hartree–Fock minimum, and is the quantity the approximate methods of Sections Hartree–Fock theory and Coupled-cluster theory try to capture.

\(g\)

\(E_{\mathrm{ref}}\)

\(E_0\) (\(6\times6\))

\(E_0\) (\(70\times70\))

\(E_{\mathrm{corr}}\)

\(-1.0\)

\(3.0\)

\(2.77987014\)

\(2.77987014\)

\(-0.22012986\)

\(-0.5\)

\(2.5\)

\(2.43688426\)

\(2.43688426\)

\(-0.06311574\)

\(0.0\)

\(2.0\)

\(2.00000000\)

\(2.00000000\)

\(0.00000000\)

\(0.5\)

\(1.5\)

\(1.41677428\)

\(1.41677428\)

\(-0.08322572\)

\(1.0\)

\(1.0\)

\(0.63554847\)

\(0.63554847\)

\(-0.36445153\)

Table 3.2: The pairing model with \(L=4\) levels, two pairs and \(\xi=1\): the reference energy \(E_{\mathrm{ref}}=2-g\), the lowest eigenvalue in the seniority-zero space and in the full four-particle space, and the correlation energy. Produced by fci.py.

The energy relative to this reference is nonpositive for either sign of \(g\), as it must be for a variational ground state, and it is not additive in the number of pairs: at \(g=1\) it is \(-0.182\) per pair for \(L=4\), \(-0.233\) for \(L=6\) and \(-0.278\) for \(L=8\), a first sign that the pairs are not independent objects. We shall also use a variant of the model with an additional particle-hole term,

\[ \hat{V}_{\mathrm{ph}} = -\frac{f}{2}\sum_{pqr} \left(a^{\dagger}_{p+}a^{\dagger}_{p-}a_{q-}a_{r+} + \mathrm{h.c.}\right),\tag{3.31} \]

which contains pair-breaking terms (\(q\ne r\)) and pair-scattering terms (\(q=r\)), and therefore does not conserve seniority in general; with it the full space is needed. Its effect is small for small \(f\) but its consequences for the qubit encoding, in Section The four models on a qubit register, are drastic.

The Hubbard model#

The Hubbard model describes electrons hopping between the sites of a lattice, with an energy cost \(U\) when two electrons of opposite spin occupy the same site,

\[ \hat{H} = -t\sum_{\langle ij\rangle\sigma}\left(a^{\dagger}_{i\sigma}a_{j\sigma} + a^{\dagger}_{j\sigma}a_{i\sigma}\right) + U\sum_i \hat{n}_{i\uparrow}\hat{n}_{i\downarrow} ,\tag{3.32} \]

where \(\langle ij\rangle\) runs over nearest-neighbor bonds. It is the minimal model of correlated electrons in a solid, and despite its simplicity its general two-dimensional interacting form has no known closed-form solution. In the form of Eq. (3.10) the one-body matrix has the entries \(-t\) on the bonds and the two-body tensor has the single type of element \(\langle i{\uparrow}\,i{\downarrow}\vert v\vert i{\uparrow}\,i{\downarrow}\rangle=U\). The model conserves the number of electrons of each spin, so with \(N_\uparrow=N_\downarrow=N_s/2\), half filling, the relevant space has dimension \(\binom{N_s}{N_s/2}^2\), which is \(36\) for a ring of four sites. Table 3.3 lists the ground-state energy and the double occupancy \(\langle\sum_i\hat{n}_{i\uparrow}\hat{n}_{i\downarrow}\rangle\) of the four-site ring as \(U/t\) grows. At \(U=0\) the electrons are free and the energy is that of the four lowest plane-wave states, \(-4t\); as \(U\) increases the double occupancy is suppressed and the energy approaches zero from below on the scale \(t^2/U\). In this limit charge fluctuations are virtual and the low-energy states have one electron per site. Second-order perturbation theory gives a Heisenberg interaction with \(J=4t^2/U\) and a constant shift \(-J/4\) per bond. Thus for the four-site ring the leading energy is \(-2J-J=-3J=-12t^2/U\), or \(-3t^2/U\) per bond. The constant cannot be omitted when comparing the absolute Hubbard and Heisenberg energies.

The derivation is short enough to give. At \(t=0\) and half filling the ground states are the \(2^{N_s}\) configurations with exactly one electron per site, all degenerate at energy zero, and the first excited states, with one doubly occupied and one empty site, lie at energy \(U\). The hopping term connects the two sets, and second-order perturbation theory in \(t/U\) gives an effective Hamiltonian in the degenerate subspace, \(\hat{H}_{\mathrm{eff}}=-\hat P\hat{T}\hat{Q}\hat{T}\hat P/U\), where \(\hat P\) projects onto the singly occupied subspace and \(\hat Q\) onto the intermediate states with one double occupancy. Here \(U>0\) and \(U\gg |t|\). A hop from site \(j\) to a neighboring site \(i\) and back is possible only if the two electrons have opposite spins, and it either returns them to their sites or exchanges them. Working out the four spin configurations of a bond one finds

\[ \hat{H}_{\mathrm{eff}} = \frac{4t^2}{U}\sum_{\langle ij\rangle} \left(\hat{\bfv{S}}_i\cdot\hat{\bfv{S}}_j - \frac14\right) = J\sum_{\langle ij\rangle}\hat{\bfv{S}}_i\cdot\hat{\bfv{S}}_j - \frac{N_bJ}{4}, \qquad J = \frac{4t^2}{U},\tag{3.33} \]

where \(N_b\) is the number of bonds (\(N_b=N_s\) on the ring). On a single bond, the singlet has the shift \(-J\) and every triplet has shift zero. This gives a direct check of both the exchange sign and the constant; opposite-spin product states are superpositions of singlet and triplet. Away from half filling the same expansion produces in addition constrained hole hopping and three-site terms. Omitting the latter gives the usual \(t\)–\(J\) model, which is one of the standard models of high-temperature superconductivity. The last column of Table 3.3 shows the convergence to Eq. (3.33): by \(U/t=128\) the Hubbard energy in units of \(J\) is within \(0.061\%\) of the Heisenberg value.

\(U/t\)

\(E_0/t\)

\(E_0/(N_st)\)

\(\langle\sum_i\hat{n}_{i\uparrow}\hat{n}_{i\downarrow}\rangle\)

\(E_0/J\)

\(2\)

\(-2.82842712\)

\(-0.707107\)

\(0.453082\)

\(-1.41421\)

\(4\)

\(-2.10274848\)

\(-0.525687\)

\(0.287325\)

\(-2.10275\)

\(8\)

\(-1.32023496\)

\(-0.330059\)

\(0.129992\)

\(-2.64047\)

\(16\)

\(-0.72286432\)

\(-0.180716\)

\(0.042033\)

\(-2.89146\)

\(32\)

\(-0.37141042\)

\(-0.092853\)

\(0.011387\)

\(-2.97128\)

\(64\)

\(-0.18704455\)

\(-0.046761\)

\(0.002908\)

\(-2.99271\)

\(128\)

\(-0.09369285\)

\(-0.023423\)

\(0.000731\)

\(-2.99817\)

Table 3.3: The half-filled four-site Hubbard ring: ground-state energy per site, double occupancy and the energy in units of \(J=4t^2/U\), which approaches the Heisenberg value \(-3\) (that is \(-2J-N_sJ/4\)) as \(U/t\to\infty\). Produced by fci.py.

The Heisenberg model#

The Heisenberg model is a model of interacting spins-\(1/2\) on a lattice,

\[ \hat{H} = J\sum_{\langle ij\rangle}\hat{\bfv{S}}_i\cdot\hat{\bfv{S}}_j = J\sum_{\langle ij\rangle}\left[\hat{S}^z_i\hat{S}^z_j + \frac12\left(\hat{S}^+_i\hat{S}^-_j + \hat{S}^-_i\hat{S}^+_j\right)\right],\tag{3.34} \]

with \(J>0\) for an antiferromagnet. It is not a fermionic model: the spins on different sites commute, and \(\hat{\bfv{S}}_i=\frac12(X_i,Y_i,Z_i)\) in terms of the Pauli matrices of site \(i\). Here \(|0\rangle=|\uparrow\rangle\) and \(|1\rangle=|\downarrow\rangle\), so \(S^+=(X+iY)/2\). This physical spin-raising operator differs from the occupation-raising \(a^\dagger=(X-iY)/2\) used for fermion encoding. In the language of Chapter 2 the Heisenberg Hamiltonian is already a sum of products of Pauli matrices on a register of \(N_s\) qubits,

\[ \hat{H} = \frac{J}{4}\sum_{\langle ij\rangle}\left(X_iX_j + Y_iY_j + Z_iZ_j\right),\tag{3.35} \]

which is why it is the easiest of the four models to put on a quantum computer, and why it appears in Section The four models on a qubit register as the reference against which the fermionic mappings are compared. Its symmetry is the conservation of the total \(\hat{S}^z=\frac12\sum_i Z_i\): the flip-flop term \(\hat{S}^+_i\hat{S}^-_j\) exchanges an up and a down spin but does not change their number, so the Hamiltonian is block diagonal in the number of up spins and the ground state of an even ring lies in the \(S^z=0\) block of dimension \(\binom{N_s}{N_s/2}\). Table 3.4 lists the ground-state energy per site of rings of increasing length, which converges to the Bethe-ansatz value \(E_0/(N_sJ)\to\frac14-\ln 2=-0.443147\) of the infinite chain with corrections of order \(1/N_s^2\). For the four-site ring \(E_0=-2J\), with nearest-neighbor correlation \(\langle\hat{\bfv{S}}_i\cdot\hat{\bfv{S}}_{i+1}\rangle=-1/2\) and next-nearest \(+1/4\), the antiferromagnetic alternation of a resonating-valence-bond state.

\(N_s\)

dimension

\(E_0/J\)

\(E_0/(N_sJ)\)

deviation

\(4\)

\(6\)

\(-2.00000000\)

\(-0.50000000\)

\(-0.056853\)

\(6\)

\(20\)

\(-2.80277564\)

\(-0.46712927\)

\(-0.023982\)

\(8\)

\(70\)

\(-3.65109341\)

\(-0.45638668\)

\(-0.013239\)

\(10\)

\(252\)

\(-4.51544635\)

\(-0.45154464\)

\(-0.008397\)

\(12\)

\(924\)

\(-5.38739092\)

\(-0.44894924\)

\(-0.005802\)

Table 3.4: The antiferromagnetic Heisenberg ring: dimension of the \(S^z=0\) block, ground-state energy, energy per site and its deviation from the Bethe-ansatz limit \(\frac14-\ln2=-0.44314718\). Produced by fci.py.

model

degrees of freedom

conserved quantity

reduced space

full space

Lipkin

\(N\) fermions, \(2\Omega\) states

quasispin \(\hat{J}^2\)

\(N+1\) (\(5\))

\(\binom{2\Omega}{N}\) (\(70\))

pairing

\(n\) pairs, \(2L\) states

seniority

\(\binom{L}{n}\) (\(6\))

\(\binom{2L}{2n}\) (\(70\))

Hubbard

\(N_s\) sites, \(2N_s\) states

\(N_\uparrow\), \(N_\downarrow\)

\(\binom{N_s}{N_s/2}^2\) (\(36\))

\(\binom{2N_s}{N_s}\) (\(70\))

Heisenberg

\(N_s\) spins

total \(S^z\)

\(\binom{N_s}{N_s/2}\) (\(6\))

\(2^{N_s}\) (\(16\))

Table 3.5: The four models at a glance: degrees of freedom, the symmetry that reduces the problem, and the dimension of the symmetry-adapted space against that of the full space for the sizes used in this chapter.

The four models under exact diagonalization. Top left the Lipkin groun

Figure 3.1: The four models under exact diagonalization. Top left: the Lipkin ground-state energy and the weight of the reference state as the coupling \(-V\) grows (\(N=4\), \(\varepsilon=2\), \(W=-1/4\)); the weight passes \(1/2\) near \(-V=2.15\). Top right: the correlation energy of the pairing model for \(L=4,6,8\) levels at half filling. Bottom left: energy per site and double occupancy of the four-site Hubbard ring against \(U/t\). Bottom right: the energy per site of the Heisenberg ring against \(1/N_s^2\), converging to the Bethe-ansatz value. Produced by fci.py.

Table 3.5 summarizes the four models, and Fig. 3.1 collects their exact solutions as the coupling is varied. The full spaces used here are themselves small enough for exact diagonalization; symmetry makes the benchmarks cleaner and extends the accessible sizes. The reduction is not always exponential: fixing \(S^z=0\) in an even spin chain saves a factor of order \(\sqrt{N_s}\), whereas the maximal-quasispin Lipkin block has only \(N+1\) states. An encoding of a \(d\)-dimensional sector needs at least \(\lceil\log_2d\rceil\) qubits, although practical encodings may use more to preserve simple operators. A factor \(r\) reduction in dimension therefore saves approximately \(\log_2r\) qubits, not a factor \(r\) in the qubit count.

Full configuration interaction#

The configuration-interaction expansion#

The Slater determinants built from \(M\) single-particle states form a complete basis of the \(N\)-particle space, so any \(N\)-particle state can be written as

\[ \vert\Psi\rangle = C_0\vert\Phi_0\rangle + \sum_{ia}C_i^a\vert\Phi_i^a\rangle + \sum_{i<j,\,a<b}C_{ij}^{ab}\vert\Phi_{ij}^{ab}\rangle + \cdots ,\tag{3.36} \]

organized by the number of excitations from the reference. Finding the coefficients that minimize \(\langle\Psi\vert\hat{H}\vert\Psi\rangle/\langle\Psi\vert\Psi\rangle\) is the Rayleigh–Ritz variational problem, and its solution is the eigenvalue equation

\[ \sum_{\beta}\langle\Phi_\alpha\vert\hat{H}\vert\Phi_\beta\rangle C_\beta = E\,C_\alpha ,\tag{3.37} \]

that is the diagonalization of the Hamiltonian matrix in the determinant basis. When all determinants are kept this is full configuration interaction (FCI), which is nothing but exact diagonalization in the given single-particle basis: the lowest eigenvalue is the exact ground-state energy within that basis, and the other eigenvalues are the excited states. The method is exact, it is variational, its error is controlled only by the single-particle basis, and a complete dense diagonalization provides all eigenstates; an iterative calculation usually targets only a few. Its one defect is that it does not scale, and the purpose of this section is to make that statement quantitative.

The eigenvalues of the truncated problem obey a useful ordering principle. If \(\hat{H}\) is diagonalized in a subspace and the subspace is then enlarged by one determinant, the new eigenvalues interlace the old ones: \(E_k^{(d+1)}\le E_k^{(d)}\le E_{k+1}^{(d+1)}\). Every eigenvalue can therefore only go down as the space grows, and every truncated-CI energy is an upper bound on the corresponding exact eigenvalue. This is the Hylleraas–Undheim–MacDonald theorem, a consequence of the min-max characterization of the eigenvalues (Section The variational characterization), and it is what gives the tables of this chapter their monotone structure.

The structure of the matrix#

By the Slater–Condon rules of Eqs. (3.12)–(3.14) the matrix \(\langle\Phi_\alpha\vert\hat{H}\vert\Phi_\beta\rangle\) is sparse: each row has non-zero entries only for determinants that differ from \(\vert\Phi_\alpha\rangle\) by at most two particle replacements. Furthermore, when \(\hat{H}\) commutes with an operator such as \(\hat{S}^z\), \(\hat{J}^2\) or the seniority, the matrix is block diagonal in the eigenvalue of that operator, and only the block containing the ground state needs to be built. The program fockspace.py implements the general case: it represents determinants as integers whose bits are the occupation numbers of Eq. (3.5), applies strings of creation and annihilation operators with the sign rule of Eq. (3.7), and assembles the matrix column by column from the tabulated \(h_{pq}\) and \(\langle pq\vert v\vert rs\rangle\),

import numpy as np
from fockspace import SlaterBasis, FockSpace
from models import PairingModel
model = PairingModel(4, g=1.0)
basis = SlaterBasis(model.n_modes, 4)
H = basis.hamiltonian_matrix(model.h, model.v)
print(basis.dim, np.linalg.eigvalsh(H)[0])  # 70, 0.63554847...
# In SlaterBasis.apply, mode p is bit 1 << (M - 1 - p).
p, state = 2, int("11001000", 2)
left = state >> (basis.n - p)              # occupied modes q < p
sign = (-1) ** bin(left).count("1")
print(basis.apply([('+', p)], state), sign)
70 0.6355484735756012
(1, 232) 1

The leftmost mode is the most significant bit, so shifting by \(M-p\) retains precisely the modes with indices smaller than \(p\). Masking with bit - 1 would count the modes to the right and give the wrong single-operator sign for our convention. Operator lists are written in algebraic order and applied from right to left. The implementation uses only nonzero tensor entries, assembles a dense matrix for these small examples, and preserves complex matrix elements. Its worst-case construction work is of order \(M^4\binom{M}{N}\); production methods exploit sparsity more fully. FockSpace instead constructs full \(2^M\times2^M\) matrices and is used for small-system algebra checks.

Iterative eigensolvers#

The matrices of Section The structure of the matrix are sparse and only a few of their lowest eigenvalues are wanted, and for both reasons one does not diagonalize them completely; Section Dense diagonalization gives the cost of doing so. The method of choice is the Lanczos iteration: starting from a random vector \(\vert v_0\rangle\), one builds the Krylov space spanned by \(\vert v_0\rangle,\hat{H}\vert v_0\rangle,\ldots,\hat{H}^{m-1}\vert v_0\rangle\), orthonormalized step by step, in which \(\hat{H}\) is represented by an \(m\times m\) tridiagonal matrix with diagonal elements \(\alpha_k=\langle v_k\vert\hat{H}\vert v_k\rangle\) and off-diagonal elements \(\beta_k=\Vert(\hat{H}-\alpha_k)\vert v_k\rangle-\beta_{k-1}\vert v_{k-1}\rangle\Vert\). The eigenvalues of the tridiagonal matrix, the Ritz values, often converge to the extreme eigenvalues of \(\hat{H}\) with \(m\) much smaller than the dimension, provided the initial vector has overlap with the target and the spectral separation is favorable, because the power iteration implicit in the Krylov space amplifies the components of \(\vert v_0\rangle\) along the extreme eigenvectors, and the only operation on the large matrix is the product \(\hat{H}\vert v\rangle\), which for a sparse matrix costs as much as its number of non-zero elements. Section The Lanczos algorithm derives the recurrence, its rate of convergence and the residual estimate used below, and compares the iteration with the power method. Table 3.6 shows the convergence for the \(14\)-site Heisenberg ring, whose \(S^z=0\) block has dimension \(3432\): twenty steps give an error of about \(2\times10^{-4}J\), and forty reduce it below \(10^{-8}J\) for the specified seed. The function lanczos in fci.py is twenty lines, with full reorthogonalization of each new vector against all previous ones to suppress the loss of orthogonality that plagues the plain iteration in finite-precision arithmetic. The example retains a dense matrix and uses dense diagonalization to check the answer. Large production calculations instead apply \(H\) without storing it, and use restarting or selective reorthogonalization to control memory. A Ritz residual, rather than energy changes alone, is a useful stopping criterion: for a normalized Ritz vector with last Krylov coefficient \(y_{m-1}\) its residual norm is \(|\beta_{m-1}y_{m-1}|\) in exact arithmetic. The quantum phase estimation algorithm of Chapter 5 and the filtering methods of Chapter 7 are the quantum analogues of this idea: they too extract eigenvalues by applying functions of \(\hat{H}\) to a starting state, and they too converge faster the larger the overlap of that state with the target eigenvector.

\(m\)

lowest Ritz value

error

\(5\)

\(-4.94003212\)

\(1.3\)

\(10\)

\(-6.13896624\)

\(1.2\times10^{-1}\)

\(20\)

\(-6.26335838\)

\(1.9\times10^{-4}\)

\(40\)

\(-6.26354953\)

\(<10^{-8}\)

Table 3.6: Convergence of the Lanczos iteration for the \(S^z=0\) block of the \(14\)-site antiferromagnetic Heisenberg ring (dimension \(3432\), exact ground-state energy \(-6.26354953J\)) from a random start vector: the lowest Ritz value after \(m\) steps and its error. Produced by fci.py.

The exponential wall#

The dimension of the \(N\)-particle space, \(\binom{M}{N}\), grows exponentially with the size of the system. At half filling \(\binom{M}{M/2}\approx 2^M\sqrt{2/(\pi M)}\), up to a subexponential factor. This is a fixed-filling statement; with \(N\) fixed and \(M\to\infty\), \(\binom{M}{N}\sim M^N/N!\). Table 3.7 quantifies the fixed-filling growth. With \(M=40\) one vector already has about \(1.4\times10^{11}\) components, or roughly \(2.2\) TB at sixteen bytes per complex amplitude. With \(M=80\) the dimension is about \(1.1\times10^{23}\), and with \(M=160\) it is about \(9.2\times10^{46}\). For eight protons and eight neutrons, each in forty spin orbitals, \(\binom{40}{8}^2\approx5.9\times10^{15}\); a half-filled \(6\times6\) Hubbard cluster with equal spin populations has \(\binom{36}{18}^2\approx8.2\times10^{19}\) determinants. These are unrestricted coefficient-storage costs, not universal limits on every classical method. Some symmetries yield only polynomial savings; the maximal-quasispin Lipkin sector is a particularly strong exception.

\(M\)

\(\binom{M}{M/2}\)

\(2^M/\sqrt{M}\)

\(10\)

\(2.5\times10^{2}\)

\(3.2\times10^{2}\)

\(20\)

\(1.8\times10^{5}\)

\(2.3\times10^{5}\)

\(40\)

\(1.4\times10^{11}\)

\(1.7\times10^{11}\)

\(80\)

\(1.1\times10^{23}\)

\(1.4\times10^{23}\)

\(160\)

\(9.2\times10^{46}\)

\(1.2\times10^{47}\)

Table 3.7: The dimension of the half-filled \(N\)-particle space, exactly and in the asymptotic form \(2^M/\sqrt{M}\) up to a constant. Produced by fci.py.

Classical many-body theory has developed three responses. The first is to keep only a part of the expansion of Eq. (3.36), which is the subject of the next subsection and leads, through its failure, to the coupled-cluster method of Section Coupled-cluster theory. The second is to give up the wave function in favor of a stochastic sampling of it, quantum Monte Carlo, which can give controlled estimates for sign-free problems, subject to statistical and discretization errors. General fermionic problems and some frustrated spin or boson problems instead suffer a sign or phase problem; its occurrence depends on the representation and Hamiltonian, not only on particle statistics. A third response compresses the coefficient tensor into a tensor network. For a one-dimensional matrix product state, the exact bond dimension is set by Schmidt ranks, while approximation errors depend on the discarded Schmidt weights. Bounded von Neumann entropy alone does not imply an exact small-bond representation. Local, gapped one-dimensional ground states admit efficient MPS approximations under the usual finite-local- dimension assumptions; the gapless Heisenberg chain is also very successfully treated by DMRG, with accuracy controlled by bond dimension. The quantum computer offers a fourth response: a register of \(M\) qubits represents a state in the \(2^M\)-dimensional occupation space natively, and the remaining question, which occupies the rest of this book, is how to prepare and interrogate the state one wants.

Truncated configuration interaction and size consistency#

The obvious way to escape the wall is to truncate Eq. (3.36) at a fixed excitation level: CIS keeps the reference and the single excitations, CID the reference and the doubles, CISD singles and doubles, and so on. Table 3.8 shows what this gives for the pairing model with \(L=4\) and two pairs, where the dimensions through excitation ranks \(0,1,2,3,4\) are respectively \(1,17,53,69,70\). CID keeps ranks \(0\) and \(2\) only, so its dimension is \(1+\binom42^2=37\); CISD has \(53\) determinants. For the tabulated couplings, singles do not lower the reference energy, because the pairing interaction cannot move a single particle out of a pair: CIS returns the reference energy. Doubles capture most of the correlation energy at weak coupling but a decreasing fraction as \(g\) grows, and CISD equals CID for the same reason that CIS is inert. The remaining error is the contribution of the quadruple excitations, which for this model means both pairs moved at once.

\(g\)

\(E_{\mathrm{ref}}\)

CIS

CID

CISD

FCI

\(0.25\)

\(1.75\)

\(1.75000000\)

\(1.73050700\)

\(1.73050700\)

\(1.73045985\)

\(0.50\)

\(1.50\)

\(1.50000000\)

\(1.41759645\)

\(1.41759645\)

\(1.41677428\)

\(1.00\)

\(1.00\)

\(1.00000000\)

\(0.64890655\)

\(0.64890655\)

\(0.63554847\)

\(2.00\)

\(0.00\)

\(0.00000000\)

\(-1.35208670\)

\(-1.35208670\)

\(-1.48965216\)

Table 3.8: Truncated CI for the pairing model with \(L=4\) levels, two pairs and \(\xi=1\). The dimensions of the spaces are \(1\) (reference), \(17\) (CIS), \(37\) (CID), \(53\) (CISD) and \(70\) (FCI). Produced by fci.py.

The deeper problem with truncated CI is not the size of the error but the way it scales with the system. Consider two copies \(A\) and \(B\) of the same system, infinitely far apart so that they do not interact. The exact ground state is the product \(\vert\Psi_A\rangle\vert\Psi_B\rangle\) and the exact energy is \(E_A+E_B\). A method is called size consistent if it reproduces this additivity. CID does not: the product of the CID wave functions of \(A\) and \(B\) contains terms in which both \(A\) and \(B\) are doubly excited, that is quadruple excitations of the combined system, and these are precisely the terms that CID of the combined system drops. Table 3.9 makes this explicit for two non-interacting copies of a two-level pairing system with one pair each: FCI of the combined system reproduces \(2E_A\) to machine precision, while CID misses it by an amount that grows with \(g\). For \(m\) copies the missing fraction of the correlation energy grows with \(m\), so that truncated CI becomes useless for extended systems, however small the error is for one unit. The cure, in Section Coupled-cluster theory, is to build the quadruples from products of doubles instead of dropping them.

\(g\)

\(2E_A\)

FCI

CID

CID error

\(0.25\)

\(-0.26556444\)

\(-0.26556444\)

\(-0.26550480\)

\(6.0\times10^{-5}\)

\(0.50\)

\(-0.56155281\)

\(-0.56155281\)

\(-0.56066017\)

\(8.9\times10^{-4}\)

\(1.00\)

\(-1.23606798\)

\(-1.23606798\)

\(-1.22474487\)

\(1.1\times10^{-2}\)

Table 3.9: Size consistency: two non-interacting copies of the two-level pairing model with one pair each (\(\xi=1\)). FCI of the combined eight-orbital, four-particle system reproduces twice the energy of one copy; CID does not. Produced by fci.py.

Hartree–Fock theory#

The energy functional and the Hartree–Fock equations#

Instead of an exponentially large superposition of determinants one can keep exactly one, and ask which one is best. The energy of a single determinant \(\vert\Phi\rangle\) built from orthonormal orbitals \(\vert\psi_i\rangle=\sum_\alpha C_{\alpha i}\vert\phi_\alpha\rangle\), \(i=1,\ldots,N\), follows from Eq. (3.12),

\[ E[\Phi] = \sum_{i}\langle\psi_i\vert\hat{h}\vert\psi_i\rangle + \frac12\sum_{ij}\langle\psi_i\psi_j\vert v\vert\psi_i\psi_j\rangle = \sum_{\alpha\beta} h_{\alpha\beta}\rho_{\beta\alpha} + \frac12\sum_{\alpha\beta\gamma\delta}\langle\alpha\gamma\vert v\vert\beta\delta\rangle \rho_{\beta\alpha}\rho_{\delta\gamma} ,\tag{3.38} \]

where the second form uses the one-body density matrix

\[ \rho_{\beta\alpha} = \sum_{i=1}^{N} C_{\beta i}C^{*}_{\alpha i} , \qquad \bfv{\rho} = \bfv{C}_{\mathrm{occ}}\bfv{C}_{\mathrm{occ}}^{\dagger}, \qquad \bfv{\rho}^2=\bfv{\rho},\quad \mathrm{Tr}\,\bfv{\rho}=N,\tag{3.39} \]

the projector onto the occupied orbitals. The orbitals are to be chosen such that \(E[\Phi]\) is minimal subject to their orthonormality, \(\sum_\alpha C^{*}_{\alpha i}C_{\alpha j}=\delta_{ij}\). Introducing a Hermitian matrix of Lagrange multipliers \(\Lambda_{ij}\) enforces all orthonormality constraints:

\[ \mathcal L[C]=E[\Phi]-\sum_{ij}\Lambda_{ji} \left(\sum_\alpha C^*_{\alpha i}C_{\alpha j}-\delta_{ij}\right).\tag{3.40} \]

Varying with respect to \(C^{*}_{\alpha i}\), treating \(C\) and \(C^{*}\) as independent, the one-body term gives \(\sum_\beta h_{\alpha\beta}C_{\beta i}\) directly, and in the two-body term \(C^{*}_{\alpha i}\) appears in both the first and the second factor; the two contributions are equal by the antisymmetry of Eq. (3.11) under the simultaneous interchange of both pairs of indices, and together they cancel the factor \(\frac12\). The result is \(f C_{\mathrm{occ}}=C_{\mathrm{occ}}\Lambda\) . A unitary rotation within the occupied subspace diagonalizes \(\Lambda\) without changing the determinant. Choosing canonical occupied and virtual orbitals then gives the Hartree–Fock equations

\[ \sum_\beta f_{\alpha\beta}\,C_{\beta i} = \varepsilon_i\, C_{\alpha i}, \qquad f_{\alpha\beta} = h_{\alpha\beta} + \sum_{\gamma\delta}\rho_{\delta\gamma}\langle\alpha\gamma\vert v\vert\beta\delta\rangle .\tag{3.41} \]

This is an eigenvalue problem for the Fock matrix of Eq. (3.21), now written in the fixed basis \(\vert\phi_\alpha\rangle\) and with the occupied orbitals expressed through \(\bfv{\rho}\); the one complication is that \(\bfv{f}\) depends on its own eigenvectors through \(\bfv{\rho}\). The standard solution is the self-consistent field iteration: guess the occupied orbitals, build \(\bfv{\rho}\) and \(\bfv{f}\), diagonalize \(\bfv{f}\), occupy its \(N\) lowest eigenvectors, and repeat until the occupied projector stops changing and \(\Vert[f,\rho]\Vert\) is small. Stable eigenvalues alone can hide an oscillating density. Mixing may help convergence, but is not a guarantee. No matrix elements are recomputed during the iteration; each step is a contraction and a diagonalization. The class HartreeFock in hartreefock.py does exactly this,

import numpy as np
from models import PairingModel
from hartreefock import HartreeFock
model = PairingModel(4, g=1.0)
hf = HartreeFock(model.h, model.v, 4)
C, eps, E, iterations = hf.solve()
rho = hf.density_matrix(C)
f = hf.fock_matrix(rho)
print(E, hf.brillouin(C), np.linalg.norm(f @ rho - rho @ f))
assert np.allclose(rho @ rho, rho)
assert abs(np.trace(rho) - 4) < 1e-12
1.0 0.0 0.0

and the Hartree–Fock energy is \(E[\Phi]\) evaluated at the converged density matrix. Note that \(E_{\mathrm{HF}}\ne\sum_i\varepsilon_i\): the sum of the eigenvalues counts the interaction twice, and \(E_{\mathrm{HF}} = \sum_i\varepsilon_i - \frac12\sum_{ij}\langle ij\vert v\vert ij\rangle\).

Two properties of the solution follow immediately. In the basis of the Hartree–Fock orbitals the Fock matrix is diagonal, so in particular \(f_{ai}=0\) between occupied and unoccupied orbitals. By Eq. (3.22) this means that

\[ \langle\Phi_i^a\vert\hat{H}\vert\Phi_{\mathrm{HF}}\rangle = f_{ai} = 0 ,\tag{3.42} \]

Brillouin’s theorem: the Hartree–Fock determinant does not interact with its single excitations, so the reference decouples from the singles block. At a stable HF minimum, CIS does not lower the reference energy. Brillouin stationarity alone does not exclude a lower eigenvalue in the singles block of an unstable reference. And the normal-ordered Hamiltonian of Eq. (3.20) with respect to \(\vert\Phi_{\mathrm{HF}}\rangle\) has a diagonal one-body part, \(\hat{F}_N=\sum_p\varepsilon_p N[a^{\dagger}_pa_p]\), so that all the remaining physics is in \(\hat{V}_N\). This is the starting point of every post-Hartree–Fock method.

Thouless’ theorem and the second-quantized form#

The derivation above varied the orbitals. It is illuminating, and necessary for what follows, to vary the determinant itself. After rescaling to intermediate normalization, any determinant \(\vert\Phi'\rangle\) that is not orthogonal to \(\vert\Phi_0\rangle\) can be written as

\[ \vert\Phi'\rangle = \exp\Big(\sum_{ia}t_{ai}\,a^{\dagger}_a a_i\Big)\vert\Phi_0\rangle = e^{\hat{T}_1}\vert\Phi_0\rangle,\tag{3.43} \]

with intermediate normalization \(\langle\Phi_0\vert\Phi'\rangle=1\). This is Thouless’ theorem. Its content is that the exponential of a one-body particle-hole operator maps determinants onto determinants: the operator \(\hat{T}_1\) commutes with itself term by term (all \(a^{\dagger}_aa_i\) commute, since \(a\ne i\) always), so \(e^{\hat{T}_1}=\prod_{i}(1+\sum_a t_{ai}a^{\dagger}_aa_i)\), and each factor replaces the occupied orbital \(i\) by the rotated orbital \(\vert\psi_i\rangle+\sum_a t_{ai}\vert\psi_a\rangle\). The program hartreefock.py checks this numerically: the state \(e^{\hat{T}_1}\vert\Phi_0\rangle\) computed as a matrix exponential in Fock space coincides with the antisymmetrized product of rotated orbitals to floating-point accuracy. The linearization \((1+\hat{T}_1)\vert\Phi_0\rangle\) omits the doubly excited cross terms \(t_{ai}t_{bj}\).

Thouless’ theorem turns the variation of the determinant into a variation of the amplitudes \(t_{ai}\). The energy changes to first order by \(\sum_{ia}t^*_{ai}\langle\Phi_i^a\vert\hat{H}\vert\Phi_0\rangle+\mathrm{c.c.}\), so the stationarity condition is again Brillouin’s theorem, Eq. (3.42), now derived without any reference to orbitals. The second-order variation decides whether the stationary point is a minimum: expanding to second order in \(t\) and using Wick’s theorem one finds

\[\begin{equation*} \delta^2 E = \frac12 \begin{pmatrix} \bfv{t}^{*} & \bfv{t}\end{pmatrix} \begin{pmatrix} \bfv{A} & \bfv{B} \\ \bfv{B}^{*} & \bfv{A}^{*}\end{pmatrix} \begin{pmatrix} \bfv{t} \\ \bfv{t}^{*}\end{pmatrix}, \qquad A_{ai,bj} = (\varepsilon_a-\varepsilon_i)\delta_{ab}\delta_{ij} + \langle aj\vert v\vert ib\rangle, \quad B_{ai,bj} = \langle ab\vert v\vert ij\rangle ,\tag{3.44} \end{equation*}\]

where \(\delta^2E\) denotes the quadratic energy change of the normalized Thouless state at a stationary determinant. Positive definiteness on the independent occupied–virtual variations is sufficient for a strict local minimum; a negative eigenvalue identifies a downhill direction. Zero eigenvalues require higher-order analysis and can represent a broken continuous symmetry. Thus positive semidefiniteness alone is not an “if and only if” test of a minimum.

The RPA frequencies solve the generalized eigenproblem

\[\begin{equation*} \bfv M\begin{pmatrix}X\\Y\end{pmatrix} =\omega\begin{pmatrix}I&0\\0&-I\end{pmatrix} \begin{pmatrix}X\\Y\end{pmatrix}.\tag{3.45} \end{equation*}\]

They are not the eigenvalues of \(\bfv M\). A positive definite \(\bfv M\) gives real frequencies, but a negative eigenvalue does not invariably imply an imaginary frequency. For example \(A=-2\), \(B=0\) gives \(M=-2I\) and real frequencies \(\pm2\). Energetic stability and dynamical stability must be distinguished.

The Baker–Campbell–Hausdorff expansion and Trotter splitting#

Exponentials of operators, as in Eq. (3.43), are the recurring theme of this book: the time-evolution operator \(e^{-i\hat{H}t}\), the coupled-cluster wave operator \(e^{\hat{T}}\), the unitary rotations \(e^{\hat{T}-\hat{T}^\dagger}\) of Section Unitary coupled cluster, and every quantum gate. Two facts about them are needed everywhere. The first is that for non-commuting \(X\) and \(Y\) the product \(e^Xe^Y\) is not \(e^{X+Y}\), but it is still a single exponential,

\[ e^{X}e^{Y} = e^{Z}, \qquad Z = X + Y + \frac12[X,Y] + \frac1{12}\big([X,[X,Y]]+[Y,[Y,X]]\big) - \frac1{24}[Y,[X,[X,Y]]] + \cdots ,\tag{3.46} \]

the Baker–Campbell–Hausdorff (BCH) expansion, whose terms are all nested commutators. The series terminates when \([X,Y]\) commutes with both \(X\) and \(Y\), which is the case for Thouless’ theorem, where the generators commute outright, and for the harmonic oscillator, where \([a,a^\dagger]=1\). For finite matrices the BCH series converges in a neighborhood of zero; its convergence and logarithm branch cannot be assumed for arbitrary large operators. In the small-matrix example for the \(2\times2\) matrices \(X=0.1\,a\) and \(Y=0.1\,a^{\dagger}\) the program trotter.py finds \(\Vert e^Xe^Y-e^{Z_n}\Vert = 7.1\times10^{-3}\), \(2.4\times10^{-4}\), \(1.2\times10^{-5}\) and \(4.8\times10^{-7}\) when \(Z_n\) is truncated after the first, second, third and fourth order (Frobenius norm), each order gaining a factor of order \(\Vert X\Vert\).

The second fact is the converse: an exponential of a sum can be approximated by a product of exponentials, provided the exponent is divided into small enough pieces. From Eq. (3.46), \(e^{X/n}e^{Y/n} = e^{(X+Y)/n + [X,Y]/(2n^2)+\cdots}\), and raising to the \(n\)-th power,

\[ e^{X+Y} = \lim_{n\to\infty}\left(e^{X/n}e^{Y/n}\right)^n, \qquad \left\Vert e^{X+Y} - \left(e^{X/n}e^{Y/n}\right)^n\right\Vert \le \frac{1}{2n}\Vert[X,Y]\Vert\, e^{\Vert X\Vert+\Vert Y\Vert} ,\tag{3.47} \]

the Lie–Trotter formula for finite matrices and the spectral operator norm of Section Matrix norms. One way to prove the bound is to integrate the local commutator defect, bounding it by \(\Vert[X,Y]\Vert e^{(\Vert X\Vert+\Vert Y\Vert)/n}/(2n^2)\), and telescope the difference of the two \(n\)th powers. For anti-Hermitian \(X,Y\), unitary stability removes the exponential prefactor. The error is of order \(1/n\) and proportional to the commutator; it vanishes when the pieces commute. The symmetric or Strang splitting

\[ e^{X+Y} \approx \left(e^{X/2n}e^{Y/n}e^{X/2n}\right)^n\tag{3.48} \]

cancels the \([X,Y]\) term and has an error of order \(1/n^2\); higher-order Suzuki products cancel more terms at the price of more factors. Applied to \(e^{-i\hat{H}t}\) with \(\hat{H}=\sum_\alpha\hat{H}_\alpha\) the formula reads

\[ e^{-i\hat{H}t}\approx\left(\prod_\alpha e^{-i\hat{H}_\alpha t/n}\right)^n ,\tag{3.49} \]

and it is the basis of Hamiltonian simulation on a quantum computer, Chapter 4: if each \(\hat{H}_\alpha\) acts on a few qubits, each factor is a small gate, and the number of gates is the number of terms times the number of steps. Table 3.10 shows the two splittings for the simplest non-trivial case, a single qubit with \(\hat{H}=X+Z\), where \(\Vert[X,Z]\Vert=2\); the errors fall exactly as \(1/n\) and \(1/n^2\) once \(n\) is moderately large. Figure 3.2 shows the same for the four-site Heisenberg ring split into the two bonds \((01)\), \((23)\) and the two bonds \((12)\), \((30)\), each group consisting of commuting two-qubit operators, so that every factor in Eq. (3.49) is a two-qubit gate; the asymptotic slopes on the log-log plot are \(-1.00\) and \(-2.00\).

\(n\)

first order

ratio

second order

ratio

\(1\)

\(7.99\times10^{-1}\)

—

\(3.14\times10^{-1}\)

—

\(2\)

\(3.62\times10^{-1}\)

\(2.21\)

\(7.11\times10^{-2}\)

\(4.41\)

\(4\)

\(1.76\times10^{-1}\)

\(2.06\)

\(1.73\times10^{-2}\)

\(4.12\)

\(8\)

\(8.75\times10^{-2}\)

\(2.01\)

\(4.29\times10^{-3}\)

\(4.03\)

\(16\)

\(4.37\times10^{-2}\)

\(2.00\)

\(1.07\times10^{-3}\)

\(4.01\)

\(32\)

\(2.18\times10^{-2}\)

\(2.00\)

\(2.67\times10^{-4}\)

\(4.00\)

\(64\)

\(1.09\times10^{-2}\)

\(2.00\)

\(6.68\times10^{-5}\)

\(4.00\)

Table 3.10: Trotter splitting of \(e^{-i(X+Z)t}\) at \(t=1\): the spectral norm of the difference between the exact exponential and the first-order product of Eq. (3.47) or the second-order product of Eq. (3.48) with \(n\) steps, and the ratio of successive errors. Produced by trotter.py.

Trotter splitting of the time-evolution operator of the four-site Heis

Figure 3.2: Trotter splitting of the time-evolution operator of the four-site Heisenberg ring, \(t=2\), into even and odd bonds. The dotted lines are the \(1/n\) and \(1/n^2\) references through the first point. Produced by trotter.py.

BCH describes the effective generator of a product locally, while Trotter splitting approximates a prescribed sum exponential by elementary factors. The BCH commutators can generate new operator directions beyond the original linear span. Therefore a product ansatz need not be a mere reparametrization of the sum-exponential ansatz, an important distinction when parameters are optimized in Section Trotterized unitary coupled cluster.

Stability and the Lipkin model#

The Lipkin model with \(W=0\), \(V<0\) and \(N=\Omega\) is the standard illustration of the stability analysis because everything is in closed form. The mean-field ansatz rotates every doublet by the same angle, \(\vert\psi_p\rangle = \cos\frac{\alpha}{2}\vert p-\rangle +\sin\frac{\alpha}{2}\vert p+\rangle\), a Thouless rotation with \(t_{ai}=\tan(\alpha/2)\delta_{pq}\), and the energy per particle is

\[ \frac{E(\alpha)}{N} = -\frac{\varepsilon}{2}\cos\alpha - \frac{\varepsilon\chi}{4}\sin^2\alpha, \qquad \chi = \frac{\vert V\vert(N-1)}{\varepsilon} .\tag{3.50} \]

Its derivative \(\frac{\varepsilon}{2}\sin\alpha(1-\chi\cos\alpha)\) has the spherical stationary point \(\alpha=0\) for every \(\chi\) and, for \(\chi\ge1\), a second, deformed one at \(\cos\alpha=1/\chi\), with energy \(-\frac{\varepsilon}{4}(\chi+1/\chi)\) per particle. The second derivative at \(\alpha=0\) is \(\frac{\varepsilon}{2}(1-\chi)\): for \(\chi>1\) the spherical solution is a maximum along this collective coordinate, at the bifurcation where the deformed solutions appear. At \(\chi=1\) the quadratic term vanishes but the quartic coefficient is positive: \(E(\alpha)/N=-\varepsilon/2+\varepsilon\alpha^4/16+O(\alpha^6)\). The stability matrix of Eq. (3.44) reproduces this without any parametrization. Since the interaction changes \(J_z\) by two units it has no particle-hole matrix elements, so \(\bfv{A}\) is \(\varepsilon\) times the unit matrix, while \(\bfv{B}\) has entries \(\pm V\) with largest eigenvalue \(\vert V\vert(N-1)\), and the lowest eigenvalue of \(\bfv{M}\) is \(\lambda_{\min}=\varepsilon(1-\chi)\).

\(\chi\)

\(E_{\mathrm{spherical}}\)

\(E_{\mathrm{HF}}\)

\(\lambda_{\min}\)

\(E_{\mathrm{exact}}\)

solution

\(0.25\)

\(-2.000000\)

\(-2.000000\)

\(0.75\)

\(-2.020726\)

spherical

\(0.50\)

\(-2.000000\)

\(-2.000000\)

\(0.50\)

\(-2.081666\)

spherical

\(0.90\)

\(-2.000000\)

\(-2.000000\)

\(0.10\)

\(-2.253886\)

spherical

\(1.00\)

\(-2.000000\)

\(-2.000000\)

\(0.00\)

\(-2.309401\)

critical

\(1.50\)

\(-2.000000\)

\(-2.166667\)

\(-0.50\)

\(-2.645751\)

deformed

\(2.00\)

\(-2.000000\)

\(-2.500000\)

\(-1.00\)

\(-3.055050\)

deformed

\(2.50\)

\(-2.000000\)

\(-2.900000\)

\(-1.50\)

\(-3.511885\)

deformed

Table 3.11: Hartree–Fock for the Lipkin model with \(N=4\), \(\varepsilon=1\), \(W=0\): the energy of the spherical solution, the energy of the self-consistent solution initialized at the collective mean-field rotation, the lowest eigenvalue of the stability matrix of the spherical solution, and the exact energy. Produced by hartreefock.py.

The Lipkin model at the mean-field level N4, varepsilon1, W0. Left the

Figure 3.3: The Lipkin model at the mean-field level (\(N=4\), \(\varepsilon=1\), \(W=0\)). Left: the energy surface of Eq. (3.50) for several couplings; the minimum moves away from \(\alpha=0\) once \(\chi>1\). Right: the lowest eigenvalue of the stability matrix of the spherical solution, \(\lambda_{\min}=\varepsilon(1-\chi)\), which crosses zero at \(\chi=1\), and the error \(E_{\mathrm{HF}}-E_{\mathrm{exact}}\) of the self-consistent solution, which keeps growing even after the deformed solution takes over. Produced by hartreefock.py.

Table 3.11 and Fig. 3.3 compare these stationary solutions with exact diagonalization. The program starts the SCF iteration at the spherical orbitals and at the analytically predicted collective rotation, checks the density and Brillouin residuals, and confirms their energies. This is a check of the formulas and solver, not a global-convergence claim for arbitrary initial orbitals. Two lessons follow. A solution can satisfy the Hartree–Fock equations, obey Brillouin’s theorem and still be a saddle point, which is why the stability matrix is needed. And the deformed solution lowers the energy by breaking a symmetry, the parity \((-1)^{J_z+J}\), that the exact ground state does not break; the energy gain, \(0.17\) at \(\chi=1.5\) and \(0.5\) at \(\chi=2\), captures part of the correlation energy but the determinant has the wrong finite-system symmetry, and the remaining error, \(0.48\) and \(0.56\), is larger than the gain. Restoring symmetry by projection or going beyond the mean field with the methods of Section Coupled-cluster theory, is needed for a symmetry-respecting correlated description. In Chapter 6 the Lipkin model will show the same transition in a variational quantum calculation, where the symmetry-broken ansatz is a rotation of every qubit by the same angle.

When the mean field does nothing: pairing and Hubbard#

For the attractive pairing parameters in Table 3.12, the level-filled determinant is self-consistent and its energy is \(2-g\). Pair transfer couples it directly to doubles, so its Brillouin elements vanish. This stationarity does not by itself prove global optimality over all determinants. For this reduced, attractive pairing Hamiltonian the filled determinant does minimize the determinant energy: if \(P\) is its rank-\(2n\) one-body projector and \(J\) pairs time-reversed modes, Wick’s theorem gives \(\langle S^+S^-\rangle=\frac12\mathrm{Tr}(PJP^TJ^\dagger) \le n\), with \(S^+=\sum_pP_p^+\) and the real antisymmetric matrix \(J=I_L\otimes\begin{pmatrix}0&1\\-1&0\end{pmatrix}\) in the adjacent-partner basis. Since \(JP^TJ^\dagger\) is another rank-\(2n\) projector, its overlap trace with \(P\) cannot exceed \(2n\). The filled determinant saturates this bound and minimizes the one-body energy, so for \(g\ge0\) both terms are minimized simultaneously. This argument does not extend to repulsive pairing or the added pair-breaking interaction without reanalysis.

All energy gained below that HF reference in the table is therefore correlation energy. BCS/Hartree–Fock–Bogoliubov theory introduces anomalous pair densities and uses a quasiparticle vacuum with fluctuating particle number; number projection can restore a fixed particle number. It is a richer variational family than ordinary Slater-determinant HF.

\(g\)

\(E_{\mathrm{ref}}\)

\(E_{\mathrm{HF}}\)

\(E_{\mathrm{exact}}\)

iterations

\(\max\vert f_{ai}\vert\)

\(0.25\)

\(1.75\)

\(1.75000000\)

\(1.73045985\)

\(1\)

\(0\)

\(0.50\)

\(1.50\)

\(1.50000000\)

\(1.41677428\)

\(1\)

\(0\)

\(1.00\)

\(1.00\)

\(1.00000000\)

\(0.63554847\)

\(1\)

\(0\)

Table 3.12: Hartree–Fock for the pairing model with \(L=4\), two pairs and \(\xi=1\): the mean field returns the reference energy. Produced by hartreefock.py.

The Hubbard model shows the other face of the mean field, symmetry breaking as in the Lipkin model. With the constraint that spin-up and spin-down electrons occupy the same spatial orbitals, the plane waves of the non-interacting ring are self-consistent and the paramagnetic energy of the half-filled four-site ring is \(E=-4t+U\), the kinetic energy plus the double occupancy of a uniform density, \(1/4\) per site. Allowing the two spin species to occupy different orbitals, the unrestricted Hartree–Fock solution develops a staggered magnetization, up spins preferring the even sites and down spins the odd ones, which reduces the double occupancy at the cost of kinetic energy. Table 3.13 shows the two energies against the exact ones: the unrestricted solution is much better, and the staggered magnetization grows with \(U\), but the exact ground state of the finite ring at \(U>0\) is a singlet with zero one-point staggered magnetization, although it has nonzero antiferromagnetic spin correlations. Once again the mean field trades a symmetry for energy, and once again the correlated methods have to repair it.

\(U/t\)

\(E_{\mathrm{para}}\)

\(E_{\mathrm{UHF}}\)

\(E_{\mathrm{exact}}\)

\(m_{\mathrm{stagger}}\)

\(1\)

\(-3.000000\)

\(-3.285509\)

\(-3.340848\)

\(0.2853\)

\(2\)

\(-2.000000\)

\(-2.661001\)

\(-2.828427\)

\(0.3279\)

\(4\)

\(0.000000\)

\(-1.763298\)

\(-2.102748\)

\(0.4081\)

\(8\)

\(4.000000\)

\(-0.968871\)

\(-1.320235\)

\(0.4708\)

Table 3.13: The half-filled four-site Hubbard ring at the mean-field level: the paramagnetic energy \(-4t+U\), the unrestricted Hartree–Fock energy, the exact energy, and the staggered magnetization \(\left|\frac{1}{2N_s}\sum_i(-1)^i\langle\hat{n}_{i\uparrow}-\hat{n}_{i\downarrow}\rangle\right|\) of the unrestricted solution. Produced by hartreefock.py.

Coupled-cluster theory#

The exponential ansatz#

The failure of truncated CI in Section Truncated configuration interaction and size consistency had a precise cause: the product of two double excitations, one on each subsystem, is a quadruple excitation that a linear truncation drops. Coupled-cluster theory keeps such products by writing the wave function as an exponential,

\[ \vert\Psi_{\mathrm{CC}}\rangle = e^{\hat{T}}\vert\Phi_0\rangle, \qquad \hat{T} = \hat{T}_1 + \hat{T}_2 + \cdots, \qquad \hat{T}_1 = \sum_{ia}t_i^a\,a^{\dagger}_a a_i, \quad \hat{T}_2 = \frac14\sum_{ijab}t_{ij}^{ab}\,a^{\dagger}_a a^{\dagger}_b a_j a_i ,\tag{3.51} \]

where the cluster operator \(\hat{T}\) is a sum of excitation operators with unknown amplitudes \(t\). Expanding the exponential, \(e^{\hat{T}_2}=1+\hat{T}_2+\frac12\hat{T}_2^2+\cdots\), one sees that even with \(\hat{T}=\hat{T}_2\) the wave function contains quadruple excitations with coefficients \(t_{ij}^{ab}t_{kl}^{cd}\), sextuples with products of three, and so on: all of the terms that CID drops are present, with coefficients determined by the doubles. This is exactly the structure that size consistency demands, since for two non-interacting systems \(e^{\hat{T}_A+\hat{T}_B}=e^{\hat{T}_A}e^{\hat{T}_B}\) and the wave function factorizes. Truncating \(\hat{T}\) at doubles gives CCD, at singles and doubles CCSD, and adding a perturbative estimate of the triples gives CCSD(T), the workhorse of quantum chemistry. All excitation operators commute with each other, since they only contain \(a^{\dagger}_a\) and \(a_i\) and the anticommutators of these vanish, so the exponential is unambiguous and \(e^{\hat{T}}\) is easy to manipulate.

The amplitudes are not determined variationally. Instead one inserts the ansatz into the Schrödinger equation and multiplies from the left by \(e^{-\hat{T}}\),

\[ e^{-\hat{T}}\hat{H}e^{\hat{T}}\vert\Phi_0\rangle = \bar{H}\vert\Phi_0\rangle = E\vert\Phi_0\rangle .\tag{3.52} \]

The similarity-transformed Hamiltonian \(\bar{H}\) is not Hermitian but it has the same spectrum as \(\hat{H}\), and the BCH expansion of Eq. (3.46) gives it as a sum of nested commutators,

\[ \bar{H} = \hat{H} + [\hat{H},\hat{T}] + \frac12[[\hat{H},\hat{T}],\hat{T}] + \frac1{6}[[[\hat{H},\hat{T}],\hat{T}],\hat{T}] + \frac1{24}[[[[\hat{H},\hat{T}],\hat{T}],\hat{T}],\hat{T}] .\tag{3.53} \]

Here the series terminates: each commutator with \(\hat{T}\) removes one of the operators of \(\hat{H}\) by a contraction, since \(\hat{T}\) commutes with itself and only its contractions with \(\hat{H}\) survive, and a two-body Hamiltonian has four operators. This termination holds for pure excitation clusters relative to a determinant and a Hamiltonian with at most two-body terms. A fixed-rank cluster truncation is still an approximation; full CC is equivalent to FCI only when all required ranks are retained and the reference overlap is nonzero. Projecting Eq. (3.52) onto the reference and the chosen excited determinants (doubles for CCD) gives the energy and the amplitude equations,

\[ E = \langle\Phi_0\vert\bar{H}\vert\Phi_0\rangle, \qquad 0 = \langle\Phi_{ij}^{ab}\vert\bar{H}\vert\Phi_0\rangle ,\tag{3.54} \]

as many equations as amplitudes. For \(\hat{T}=\hat{T}_2\) the energy is

\[ E_{\mathrm{CCD}} = E_{\mathrm{ref}} + \frac14\sum_{ijab}\langle ij\vert v\vert ab\rangle\, t_{ij}^{ab} ,\tag{3.55} \]

which involves only the doubles amplitudes and the two-body matrix elements: all the higher excitations enter the energy through the amplitude equations, not directly.

The CCD equations#

Evaluating \(\langle\Phi_{ij}^{ab}\vert\bar{H}\vert\Phi_0\rangle\) with Wick’s theorem, with \(\hat{H}\) in the normal-ordered form of Eq. (3.20) and the occupied and virtual blocks of the Fock matrix, gives the CCD amplitude equations

\[\begin{align*} 0 &= \langle ab\vert v\vert ij\rangle + P(ab)\sum_c f_{bc}\,t_{ij}^{ac} - P(ij)\sum_k f_{kj}\,t_{ik}^{ab} + \frac12\sum_{cd}\langle ab\vert v\vert cd\rangle t_{ij}^{cd} + \frac12\sum_{kl}\langle kl\vert v\vert ij\rangle t_{kl}^{ab}\\ & + P(ij)P(ab)\sum_{kc}\langle kb\vert v\vert cj\rangle t_{ik}^{ac} + \frac14\sum_{klcd}\langle kl\vert v\vert cd\rangle t_{ij}^{cd}t_{kl}^{ab} + \frac12 P(ij)P(ab)\sum_{klcd}\langle kl\vert v\vert cd\rangle t_{ik}^{ac}t_{jl}^{bd}\\ & - \frac12 P(ij)\sum_{klcd}\langle kl\vert v\vert cd\rangle t_{jl}^{cd}t_{ik}^{ab} - \frac12 P(ab)\sum_{klcd}\langle kl\vert v\vert cd\rangle t_{kl}^{bd}t_{ij}^{ac} ,\tag{3.56} \end{align*}\]

where \(P(ij)X_{ij}=X_{ij}-X_{ji}\) antisymmetrizes. The terms linear in the amplitudes are the driving term, the one-body terms, the particle-particle and hole-hole ladders and the ring term; the four quadratic terms come from \(\frac12[[\hat{H},\hat{T}],\hat{T}]\). The equations are solved by iteration: the diagonal parts of the one-body terms are moved to the left, giving the denominator \(D_{ij}^{ab}=f_{ii}+f_{jj}-f_{aa}-f_{bb}\), the remaining terms are evaluated with the current amplitudes and the new amplitudes are the result divided by \(D\). Starting from \(t=0\) the first iteration gives \(t_{ij}^{ab}=\langle ab\vert v\vert ij\rangle/D_{ij}^{ab}\), which, for canonical HF orbitals with nonzero denominators, inserted into Eq. (3.55) gives the second-order Møller–Plesset correlation energy,

\[ E^{(2)} = \frac14\sum_{ijab} \frac{\vert\langle ab\vert v\vert ij\rangle\vert^2}{f_{ii}+f_{jj}-f_{aa}-f_{bb}} ,\tag{3.57} \]

the MP2 correlation energy. Iterating the CCD equations resums the retained ladder, ring and quadratic contributions. For the pairing model the structure of Eq. (3.56) simplifies considerably. The only non-zero elements \(\langle ab\vert v\vert ij\rangle\) are those with \((a,b)\) and \((i,j)\) both time-reversed partners, so the only amplitudes driven by the interaction are the pair amplitudes \(t_{i\bar\imath}^{a\bar a}\), one per pair of levels, four in all for \(L=4\) and two pairs; the ring term vanishes for the same reason; and the MP2 energy of Eq. (3.57) reduces to a sum over pairs of levels,

\[ E^{(2)} = -\frac{g^2}{4}\sum_{i\le n}\sum_{a>n}\frac{1}{2\xi(a-i)+g},\tag{3.58} \]

since the occupied levels have \(f_{ii}=\xi(i-1)-g/2\) and the empty ones \(f_{aa}=\xi(a-1)\). For \(L=4\), two pairs and \(g=1\) this is \(-\frac14(\frac15+\frac13+\frac17+\frac15)=-0.219048\), which added to \(E_{\mathrm{ref}}=1\) gives the \(0.78095238\) of Table 3.14. Nothing in the program exploits this: the general equations are solved in the full spin-orbital basis, and the seniority structure emerges from the matrix elements. With numpy the equations are nine contractions, and coupledcluster.py writes them exactly in the form of Eq. (3.56),

import numpy as np
from models import PairingModel
from coupledcluster import CCD
model = PairingModel(4, g=1.0)
cc = CCD(model.h, model.v, 4)
correlation, t, iterations, mp2 = cc.solve()
# residual() returns the Jacobi numerator R, excluding diagonal Fock terms.
projected_residual = cc.residual(t) - cc.D * t
print(cc.E_ref + mp2, cc.E_ref + correlation)
print(np.max(np.abs(projected_residual)))
0.780952380952381 0.6304427536287531
4.3443026953582375e-13

The implementation retains the off-diagonal occupied and virtual Fock blocks in the numerator. Convergence requires both a small energy change and a small projected residual \(R-Dt\); it raises an error for zero denominators or failed convergence. The explicit matrix calculation in validation.py checks the tensor equations against \(e^{-T_2}He^{T_2}\) for random complex interactions, not only pairing.

\(g\)

MP2

CCD

FCI

CCD \(-\) FCI

iterations

\(0.25\)

\(1.73320261\)

\(1.73045621\)

\(1.73045985\)

\(-3.6\times10^{-6}\)

\(13\)

\(0.50\)

\(1.43760684\)

\(1.41663766\)

\(1.41677428\)

\(-1.4\times10^{-4}\)

\(18\)

\(1.00\)

\(0.78095238\)

\(0.63044275\)

\(0.63554847\)

\(-5.1\times10^{-3}\)

\(26\)

\(1.50\)

\(0.05974026\)

\(-0.38416526\)

\(-0.34819051\)

\(-3.6\times10^{-2}\)

\(30\)

\(2.00\)

\(-0.70833333\)

\(-1.60959440\)

\(-1.48965216\)

\(-1.2\times10^{-1}\)

\(31\)

Table 3.14: Coupled-cluster doubles for the pairing model with \(L=4\), two pairs and \(\xi=1\) (reference energy \(2-g\)): the second-order (MP2) energy of the first iteration, the converged CCD energy, the exact energy and the number of iterations to \(10^{-12}\). Produced by coupledcluster.py.

Table 3.14 shows the result for the pairing model. At weak coupling CCD is essentially exact, about thirteen times more accurate than CID at \(g=0.25\) (compare Table 3.8), because the quadruples that CID drops are well approximated by products of doubles. As \(g\) grows the approximation deteriorates, and the CCD energy falls below the exact one: the method is not variational, because projection onto a truncated excitation space is not a Hermitian Rayleigh–Ritz minimization. The full similarity-transformed operator still has exactly the spectrum of \(H\); it is the projected CC solution that lacks an upper-bound guarantee. At \(g=2\) the error is \(0.12\), comparable to CID’s \(0.14\) but with the opposite sign. The strength of the method is at the same time its limitation: the coupled equations converge more slowly as \(g\) grows, and beyond the range of the table they may not converge at all. Size extensivity, however, holds for consistently chosen, converged fragment roots: for the two non-interacting copies of Table 3.9 CCD reproduces \(2E_A\) exactly, since the amplitude equations of the combined system decouple into those of the two parts (Exercise 3.6).

Unitary coupled cluster#

The non-variational character of coupled-cluster theory can be removed by making the wave operator unitary,

\[ \vert\Psi_{\mathrm{UCC}}\rangle = e^{\hat{T}-\hat{T}^{\dagger}}\vert\Phi_0\rangle, \qquad E_{\mathrm{UCC}}(t) = \langle\Phi_0\vert e^{-(\hat{T}-\hat{T}^{\dagger})}\hat{H} e^{\hat{T}-\hat{T}^{\dagger}}\vert\Phi_0\rangle ,\tag{3.59} \]

the unitary coupled-cluster ansatz. Since \(\hat{T}-\hat{T}^\dagger\) is anti-Hermitian its exponential is unitary, the state is normalized, \(E_{\mathrm{UCC}}(t)\) is an expectation value and therefore an upper bound on the exact ground-state energy, and the amplitudes can be found by minimizing it. The price is that the BCH expansion of the similarity-transformed Hamiltonian no longer terminates: \(\hat{T}^\dagger\) contains \(a^{\dagger}_i a_a\), which does contract with \(\hat{T}\), so every order of the commutator series contributes, and a general exact classical evaluation need not have polynomial cost. The small symmetry sectors used here remain tractable, and additional structure or controlled approximations can help in other cases. On a quantum computer the situation is reversed: the unitary can be approximated by a circuit, and repeated measurements of Hamiltonian terms estimate its expectation value, and the ansatz of Eq. (3.59) becomes the natural trial state of the variational quantum eigensolver of Chapter 6. This section computes it classically, on the small pairing model where the full space is available, to establish what the quantum algorithm should reproduce.

The program coupledcluster.py builds the generators \(\hat{\kappa}_k=\hat{A}_k-\hat{A}_k^\dagger\) as matrices directly in the four-particle sector (and the six-dimensional seniority-zero block for pair-only generators), forms \(\vert\Psi(t)\rangle=\exp(\sum_k t_k\hat{\kappa}_k)\vert\Phi_0\rangle\) with the matrix exponential of matrixfunctions.py, and minimizes \(\langle\Psi(t)\vert\hat{H}\vert\Psi(t)\rangle\) with the BFGS routine of optimize.py,

from models import PairingModel
from coupledcluster import pairing_ucc
model = PairingModel(4, g=1.0)
ucc = pairing_ucc(model, n_pairs=2)
t, energy, iterations = ucc.optimise()
print(energy, model.exact(4)[0])  # 0.6369869810..., 0.63554847...
0.6369869810445543 0.635548473575598

Which generators to include is a choice. For the pairing model the natural ones are the four pair excitations \(\hat{P}^+_a\hat{P}^-_i\) that move a pair from an occupied level \(i\in\{1,2\}\) to an empty level \(a\in\{3,4\}\); the general doubles \(a^{\dagger}_aa^{\dagger}_ba_ja_i\) number \(36\) and singles and doubles together \(52\). Table 3.15 reports the same energy, \(0.6369869810\), from zero-amplitude starts for all three choices at \(g=1\). This is a statement about these optimizations, not a proof of redundant generators or equal global minima. Seniority-breaking directions have zero first derivative at a seniority-zero state under a seniority-conserving Hamiltonian, so a local optimizer can remain in that symmetric submanifold. Symmetry-aware pair generators are economical, but they do not parameterize every state in the six-dimensional seniority-zero sector with one exponential.

generators

amplitudes

\(E_{\mathrm{UCC}}\) (\(g=1\))

pair excitations

\(4\)

\(0.6369869810\)

all doubles

\(36\)

\(0.6369869810\)

singles and doubles

\(52\)

\(0.6369869810\)

\(g\)

CCD

UCCD

FCI

CCD \(-\) FCI

UCCD \(-\) FCI

\(0.25\)

\(1.73045621\)

\(1.73046012\)

\(1.73045985\)

\(-3.6\times10^{-6}\)

\(2.8\times10^{-7}\)

\(0.50\)

\(1.41663766\)

\(1.41679562\)

\(1.41677428\)

\(-1.4\times10^{-4}\)

\(2.1\times10^{-5}\)

\(1.00\)

\(0.63044275\)

\(0.63698698\)

\(0.63554847\)

\(-5.1\times10^{-3}\)

\(1.4\times10^{-3}\)

\(1.50\)

\(-0.38416526\)

\(-0.33675149\)

\(-0.34819051\)

\(-3.6\times10^{-2}\)

\(1.1\times10^{-2}\)

\(2.00\)

\(-1.60959440\)

\(-1.45347633\)

\(-1.48965216\)

\(-1.2\times10^{-1}\)

\(3.6\times10^{-2}\)

Table 3.15: Unitary coupled cluster for the pairing model with \(L=4\), two pairs and \(\xi=1\). Top: the locally optimized energy at \(g=1\) from zero amplitudes for three choices of generators. Bottom: UCCD with the four pair excitations against CCD and the exact energy; UCCD is variational and lies above, CCD below. Produced by coupledcluster.py.

The lower part of Table 3.15 and the left panel of Fig. 3.4 compare UCCD with CCD. The unitary energy is above the exact one at every coupling, as it must be, and its error is three to four times smaller than that of CCD and grows more slowly. Both methods restrict connected excitations to doubles; a small reference weight can signal the need for a richer ansatz, but does not alone prove failure. Here the exact real normalized ground state belongs to a six-dimensional real vector space (five continuous parameters up to normalization and a discrete sign). The four real amplitudes in \(e^{\sum_k t_k\kappa_k}|\Phi_0\rangle\) describe at most a four-dimensional manifold. Its nonzero variational error measures this restriction for the present Hamiltonian. Additional factors with independent amplitudes can enlarge the reachable set; how many suffice must be checked, not inferred from parameter counting alone.

Trotterized unitary coupled cluster#

To implement \(\exp(\sum_k t_k\hat{\kappa}_k)\) with elementary gates, one possible compilation is a product formula. By Section The Baker–Campbell–Hausdorff expansion and Trotter splitting the natural gate sequence is the Trotter product

\[ \vert\Psi_n(t)\rangle = \left(\prod_k e^{t_k\hat{\kappa}_k/n}\right)^n\vert\Phi_0\rangle ,\tag{3.60} \]

in which each factor is the exponential of a single excitation operator, which Section A first variational circuit: unitary coupled cluster for the pairing model will turn into a short circuit. The factors do not commute, since \(\hat{\kappa}_k\) contains both \(\hat{A}_k\) and \(\hat{A}_k^\dagger\), so Eq. (3.60) differs from Eq. (3.59) by the Trotter error, and one may ask how large \(n\) has to be. Table 3.16 answers the question in two ways. With the amplitudes frozen at the optimized sum-exponential values, the observed state error decreases as \(1/n\) and the energy difference as \(1/n^2\). The latter is not guaranteed merely by variational stationarity. For two normalized states \(|\psi\rangle\) and \(|\psi_n\rangle=|\psi\rangle+|\delta\psi\rangle\), with \(E=\langle\psi|H|\psi\rangle\),

\[ E_n-E=2\mathrm{Re}\langle\delta\psi|(H-E)|\psi\rangle +\langle\delta\psi|(H-E)|\delta\psi\rangle .\tag{3.61} \]

At an exact eigenstate the linear term vanishes for every perturbation. At an ansatz optimum it vanishes only in tangent directions to the variational manifold. A Trotter perturbation can point outside it, so a linear \(1/n\) energy error is possible. The quadratic scaling in this pairing example is an observed cancellation, tested in the program.

Reoptimizing for \(n=1,2,4,8\) gives the same energy to the displayed precision for the specified ordering. The product is written in the order \((i,a)=(1,3),(1,4),(2,3),(2,4)\), with the rightmost factor acting first. This convention is implemented in trotter_state. BCH produces commutators outside the original linear span of these four generators, so it does not prove that the product and sum-exponential ansatz are reparametrizations. In general, optimized energies depend on the operator order and number of layers. With frozen amplitudes, \(n\) is a convergence parameter for the prescribed exponential; with optimized amplitudes it also defines the variational family. Small \(n\) may be useful, but its accuracy and optimization cost must be assessed for the problem.

\(n\)

\(\Vert\Psi_n-\Psi\Vert\)

ratio

\(E_n-E\)

ratio

\(1\)

\(3.56\times10^{-3}\)

—

\(6.78\times10^{-5}\)

—

\(2\)

\(1.14\times10^{-3}\)

\(3.13\)

\(6.38\times10^{-6}\)

\(10.63\)

\(4\)

\(4.56\times10^{-4}\)

\(2.50\)

\(9.37\times10^{-7}\)

\(6.81\)

\(8\)

\(2.11\times10^{-4}\)

\(2.16\)

\(1.93\times10^{-7}\)

\(4.85\)

\(16\)

\(1.03\times10^{-4}\)

\(2.04\)

\(4.57\times10^{-8}\)

\(4.23\)

\(32\)

\(5.14\times10^{-5}\)

\(2.01\)

\(1.13\times10^{-8}\)

\(4.06\)

\(64\)

\(2.57\times10^{-5}\)

\(2.00\)

\(2.81\times10^{-9}\)

\(4.01\)

Table 3.16: The Trotterized UCCD state of Eq. (3.60) for the pairing model at \(g=1\) with the amplitudes frozen at the optimum of the full exponential: the distance to the full-exponential state, the energy error, and the ratios of successive entries, which approach \(2\) and \(4\). With re-optimized amplitudes the energy is \(0.6369869810\) for the tested \(n=1,2,4,8\) and the stated operator ordering. Produced by coupledcluster.py.

Left the error of CCD and UCCD for the pairing model with L4 and two p

Figure 3.4: Left: the error of CCD and UCCD for the pairing model with \(L=4\) and two pairs as a function of \(g\); CCD undershoots, UCCD is an upper bound. Right: the Trotter error of the UCCD state with frozen amplitudes at \(g=1\), in the norm of the state and in the energy, with \(1/n\) and \(1/n^2\) reference lines. Produced by coupledcluster.py.

From fermions to qubits#

Chapter 2 described a quantum computer as a register of qubits acted on by unitary gates and read out by measurements in the computational basis; the preceding sections described a many-body system as a Fock space acted on by creation and annihilation operators. To run a many-body calculation on a quantum computer the two descriptions have to be connected, and this section and the next are about that connection. Three things must be translated. The states: an occupation-number state \(\vert n_0n_1\cdots n_{M-1}\rangle\) of \(M\) fermionic modes looks exactly like a computational basis state of \(M\) qubits, and the obvious identification, one qubit per mode with \(\vert 1\rangle\) meaning occupied, is the one we shall use. The operators: the creation and annihilation operators anticommute, whereas operators on different qubits commute, and the resolution of this conflict is the Jordan–Wigner transformation, which we have in fact already met as the string of \(Z\) matrices in Eq. (3.9). And the Hamiltonian: once every \(a^{\dagger}_pa_q\) and \(a^{\dagger}_pa^{\dagger}_qa_sa_r\) is a product of Pauli matrices, the Hamiltonian is a sum of such products, a Pauli sum, and it is in this form that every quantum algorithm of the following chapters consumes it. Product-formula time evolution (Chapter 4) exponentiates the Pauli sum term by term; phase estimation (Chapter 5) applies the resulting circuit under control of an ancilla; the variational algorithms (Chapter 6) measure the Pauli sum term by term.

The two sections give what those chapters need and no more: the Jordan–Wigner transformation, the qubit form of the four models of Section Four model Hamiltonians in the encodings used later, the circuit that exponentiates a Pauli string, the Trotter step, the preparation of a reference state, the measurement of an energy from a finite number of shots, and a first variational circuit. They condense the chapter on mapping many-body Hamiltonians to qubits of [QCbook], where the parity and Bravyi–Kitaev mappings, the alternative encodings of each model, bosonic modes and a longer set of exercises are worked out.

Pauli strings and Pauli sums#

A Pauli string on \(n\) qubits is a tensor product of one Pauli matrix or identity per qubit,

\[ P = \sigma_0\otimes\sigma_1\otimes\cdots\otimes\sigma_{n-1}, \qquad \sigma_q\in\{I,X,Y,Z\},\tag{3.62} \]

which we write as a word such as \(ZZXI\), or as \(Z_0Z_1X_2\) when the identities are left out, with qubit \(0\) the leftmost factor as in Chapter 2 and the earlier sections of this chapter. The weight of a string is the number of factors different from \(I\). There are \(4^n\) strings, they are Hermitian and unitary, they square to the identity, and the product of two strings is again a string up to a phase \(\pm1\) or \(\pm i\), obtained factor by factor from the single-qubit rule \(\sigma_i\sigma_j=\delta_{ij}I+i\epsilon_{ijk}\sigma_k\). Two strings either commute or anticommute: they anticommute if and only if they differ, both being non-identity, on an odd number of qubits. Finally the strings are orthogonal with respect to the trace inner product, \(\mathrm{Tr}(PQ)=2^n\delta_{PQ}\), and since there are \(4^n\) of them they form a basis of the \(2^n\times2^n\) matrices. Every Hermitian operator on the register is therefore a Pauli sum

\[ \hat{H} = \sum_\alpha h_\alpha P_\alpha, \qquad h_\alpha = \frac{1}{2^n}\mathrm{Tr}\left(P_\alpha\hat{H}\right)\in\mathbb{R} ,\tag{3.63} \]

with real coefficients. The strings are orthogonal in the Hilbert–Schmidt inner product, and the coefficient formula is the projection on a basis element (Section The norms of a Pauli sum). Equation (3.63) is a constructive statement: given any matrix, \(4^n\) traces produce its Pauli decomposition, and the class PauliSum in pauli.py does this, more cleverly than by \(4^n\) full traces, by contracting one qubit at a time. It stores a Pauli sum as a dictionary from strings to coefficients and implements the algebra,

import numpy as np
from pauli import PauliSum
X0 = PauliSum.single(2, 0, "X")
Y0 = PauliSum.single(2, 0, "Y")
Z1 = PauliSum.single(2, 1, "Z")
print(X0 * Y0, X0.commutator(Z1))
H = PauliSum({"ZZ": .5, "XX": .25, "YY": .25, "IZ": -.3})
print(H.n_strings(), H.max_weight(), H.weights())
assert np.allclose(PauliSum.from_matrix(H.matrix()).matrix(), H.matrix())
+(0.0000+1.0000j) ZI 0
4 2 {1: 1, 2: 3}

A structured Hamiltonian has far fewer strings than the \(4^n\) of a generic matrix, and the point of this section is to show how many.

Why this form? Because Pauli strings admit explicit gate decompositions and measurement procedures. The exponential of a single string, \(e^{-i\theta P}\), is a short circuit (Section From Pauli sums to circuits and measurements); the expectation value of a single string is obtained from measurements in the computational basis after a layer of single-qubit rotations (Section Measuring a Pauli sum); The rotation requires entangling gates, whereas a single-string measurement requires only local basis changes and readout. A Pauli sum with \(K\) strings of weight at most \(w\) can thus be time-evolved with \(\mathcal{O}(Kw)\) gates per Trotter step and its energy can be measured with at most \(K\) distinct measurement settings. These counts assume the required qubit pairs can interact. Routing, fault-tolerant rotation synthesis, coefficient magnitudes, commutators and the number of shots add costs that string counts alone do not capture.

Two numbers that will be needed in Chapter 4 are also read off from the Pauli sum. The triangle inequality gives \(\Vert\hat{H}\Vert\le\sum_\alpha\vert h_\alpha\vert\), an upper bound on the largest eigenvalue in absolute value which fixes the time scale of the dynamics, and the first-order Trotter error of Eq. (3.47) is bounded by the sum of the commutators of the pieces, \(\sum_{\alpha<\beta}\vert h_\alpha h_\beta\vert\,\Vert[P_\alpha,P_\beta]\Vert\), which for Pauli strings is simply twice the sum of \(\vert h_\alpha h_\beta\vert\) over the pairs of strings that anticommute, since \([P_\alpha,P_\beta]\) is either zero or \(2P_\alpha P_\beta\) with \(\Vert P_\alpha P_\beta\Vert=1\). Table 3.17 lists both for the Hamiltonians of Section The four models on a qubit register. Writing this commutator sum as \(C\), the spectral-norm error for a fixed-order product of Hermitian terms obeys

\[ \left\|e^{-it\hat H}-U_r(t)\right\| \le \frac{t^2}{2r}C,\qquad C=2\!\sum_{\alpha<\beta:\{P_\alpha,P_\beta\}=0} |h_\alpha h_\beta| .\tag{3.64} \]

The factor \(t^2/(2r)\) follows by bounding each local splitting error and summing \(r\) unitary steps. This is a sufficient bound, not the observed error or a necessary step count. In Table 3.17, the Hubbard value is about \(3.7\) times the pairing value and \(24\) times the Heisenberg value. These norms refer to the entire encoded registers, which can contain several particle-number sectors. Subtracting a known identity term can sharpen the norm estimate without changing \(C\).

Hamiltonian

\(\sum_\alpha\vert h_\alpha\vert\)

\(\Vert\hat{H}\Vert\)

commutator bound

Lipkin, one qubit per doublet

\(6.000\)

\(4.213\)

\(8.583\)

pairing \(L=4\), one qubit per level

\(13.500\)

\(10.672\)

\(19.500\)

pairing \(L=4\), one qubit per orbital

\(14.500\)

\(10.672\)

\(19.500\)

Hubbard ring, spin-major ordering

\(24.000\)

\(16.000\)

\(72.000\)

Heisenberg ring

\(3.000\)

\(2.000\)

\(3.000\)

Table 3.17: Two bounds read off from a Pauli sum: \(\sum_\alpha\vert h_\alpha\vert\) against the exact spectral norm, and the commutator sum \(\sum_{\alpha<\beta}\vert h_\alpha h_\beta\vert\,\Vert[P_\alpha,P_\beta]\Vert\) that controls the first-order Trotter error, for the Hamiltonians of Section The four models on a qubit register at \(\xi=g=J=t=1\), \(U=4\); the Lipkin parameters are \(\varepsilon=2\), \(V=-1/3\), \(W=-1/4\). Produced by mapped_models.py.

The Jordan–Wigner transformation#

A single fermionic mode is a two-level system, and Eq. (3.8) identified its operators with those of a qubit: \(a^{\dagger}=\vert 1\rangle\langle 0\vert=\sigma^+\) and \(a=\vert 0\rangle\langle 1\vert=\sigma^-\) with

\[ \sigma^{\pm} = \frac{X\mp iY}{2}, \qquad \hat{n} = \sigma^+\sigma^- = \frac{I-Z}{2} .\tag{3.65} \]

Note the sign: with \(\vert 1\rangle\) occupied and the matrix convention of Chapter 2, \(Z\vert 1\rangle=-\vert 1\rangle\), the raising operator that creates an occupation is \((X-iY)/2\). For \(M\) modes one is tempted to write \(a_p=I\otimes\cdots\otimes\sigma^-\otimes\cdots\otimes I\), that is \(\sigma^-_p\) on qubit \(p\). This reproduces \(\{a_p,a^{\dagger}_p\}=I\) and \(a_p^2=0\) on every single qubit, but operators on different qubits commute, so \(\{a_0,a_1\}=2\sigma^-_0\sigma^-_1\) instead of zero; jw_basics.py prints its Pauli form, \(\frac12(XX+iXY+iYX-YY)\), and its spectral norm, \(2\). A Hamiltonian built from such operators would describe hard-core bosons (Section Bosons and spins), not fermions, and in general changes fermionic exchange amplitudes.

The correct answer was derived in Section Operators as matrices. The sign rule of Eq. (3.7) requires \(a_p\) to multiply the state by \((-1)^{\sum_{q<p}n_q}\), and this is the eigenvalue of \(\prod_{q<p}Z_q\); inserting it turns Eq. (3.9) into

\[ a_p = Z_0Z_1\cdots Z_{p-1}\,\sigma^-_p = Z_0Z_1\cdots Z_{p-1}\,\frac{X_p+iY_p}{2}, \qquad a^{\dagger}_p = Z_0Z_1\cdots Z_{p-1}\,\frac{X_p-iY_p}{2},\tag{3.66} \]

the Jordan–Wigner transformation. The product of \(Z\)’s is the parity string: it measures the parity of the number of occupied modes to the left of \(p\), and it is what a fermionic operator has to know about the rest of the register. That Eq. (3.66) satisfies the anticommutation relations of Eq. (3.3) can be checked symbolically: for \(p<q\), \(a_pa_q\) and \(a_qa_p\) differ by the order of \(\sigma^-_p\) and the \(Z_p\) in the parity string of \(a_q\), and \(Z\sigma^-=-\sigma^-Z\) supplies the sign, while all other factors commute. The program jordanwigner.py performs this check for all pairs of modes, and also verifies that the Pauli sums of Eq. (3.66) equal, as matrices, the operators of FockSpace from Section Operators as matrices, which is the statement that the Fock-space and the qubit descriptions use one and the same convention. The implementation is in the shared module; this short example checks its convention directly,

import numpy as np
from jordanwigner import JordanWigner
from fockspace import FockSpace
jw, fs = JordanWigner(4), FockSpace(4)
print(jw.create(2))
assert np.allclose(jw.create(2).matrix(), fs.create(2))
assert not (jw.annihilate(0)*jw.annihilate(2)
            + jw.annihilate(2)*jw.annihilate(0)).simplify().terms
+0.5000 ZZXI
+(0.0000-0.5000j) ZZYI

The method map_hamiltonian does nothing more than multiply out the products of Eq. (3.10) as Pauli sums, letting the dictionary collect the strings. Two remarks on conventions. First, the ordering of the modes is a choice, and a different ordering gives a different, unitarily equivalent set of strings; Section The four models on a qubit register shows that the choice matters. Second, the literature is divided on whether \(\vert 0\rangle\) or \(\vert 1\rangle\) means occupied and hence on the sign of \(Y\) in Eq. (3.66); the physics is the same, but Pauli forms copied from different sources cannot be combined without checking. We use \(\vert 1\rangle\) for occupied throughout.

Every term of a many-body Hamiltonian is a product of two or four of the operators of Eq. (3.66), and a handful of identities cover all of them. The number operator has no parity string, since \(Z^2=I\),

\[ \hat{n}_p = a^{\dagger}_pa_p = \frac{I-Z_p}{2}, \qquad \sum_p\varepsilon_p\hat{n}_p = \frac12\sum_p\varepsilon_p\left(I-Z_p\right) ,\tag{3.67} \]

so a non-interacting Hamiltonian is diagonal on the register and needs no circuit to find its spectrum, only to prepare its eigenstates. The hopping term between modes \(p<q\) carries the parity string of the modes in between,

\[ a^{\dagger}_pa_q + a^{\dagger}_qa_p = \frac12\left(X_pZ_{p+1}\cdots Z_{q-1}X_q + Y_pZ_{p+1}\cdots Z_{q-1}Y_q\right) ,\tag{3.68} \]

two strings of weight \(q-p+1\): a hop has to know how many particles it jumps over. The pair-creation term differs from it by one sign,

\[ a^{\dagger}_pa^{\dagger}_q + a_qa_p = \frac12\left(X_pZ_{p+1}\cdots Z_{q-1}X_q - Y_pZ_{p+1}\cdots Z_{q-1}Y_q\right) ,\tag{3.69} \]

Here two particles are created or destroyed: the term preserves number parity but not particle number. A pair transfer in the pairing model instead contains four fermionic operators and conserves number. A two-body monomial with four distinct indices, added to its Hermitian conjugate with a real coefficient, produces eight strings. Their support includes the four endpoints and any surviving parity strings, so their weight need not be four. For four consecutive modes it is four and the coefficients are \(\pm1/8\):

\[\begin{align*} a^{\dagger}_0a^{\dagger}_1a_3a_2 + \mathrm{h.c.} &= \frac18\big(XXXX + XYXY + XYYX + YXXY + YXYX + YYYY\\ & \qquad - XXYY - YYXX\big) ,\tag{3.70} \end{align*}\]

where \(XYXY\) means \(X_0Y_1X_2Y_3\). All four identities are printed and asserted by jw_basics.py, which also confirms that the eight-string form is what the pair-transfer term \(\hat{P}^+_p\hat{P}^-_q+\mathrm{h.c.}\) of the pairing model becomes when the modes are ordered \((p+,p-,q+,q-)\). For separated indices, additional \(Z\) factors may extend the support across the register. Complex hopping adds the current-like \(XY-YX\) combination, and a complex two-body coefficient can give both sets of eight Hermitian strings. A general dense one- plus two-body Hamiltonian still has \(\mathcal{O}(M^4)\) strings, with maximum weight up to \(M\).

The Jordan–Wigner transformation is exact and the easiest to derive, but it is not the only fermion-to-qubit mapping. Its occupation numbers are local, \(\hat{n}_p=(I-Z_p)/2\), while the parity needed by \(a_p\) is spread over all qubits to its left, so that the weight of a ladder operator grows linearly with the number of modes. The parity mapping stores cumulative parities instead and moves the linear cost to the update of the occupations; the Bravyi–Kitaev mapping stores partial parities in a binary tree and reduces both costs to \(\mathcal{O}(\log M)\) qubits. For a generic real one- plus two-body Hamiltonian on \(M\) modes the Jordan–Wigner image has \(6\), \(19\), \(55\), \(136\) and \(292\) strings for \(M=2,\ldots,6\), consistent with \(\mathcal{O}(M^4)\), with a largest weight equal to \(M\), and this is the situation in which the logarithmic mapping pays off. For the small, structured models of this text, whose operators act on adjacent modes when the modes are ordered well, the Jordan–Wigner strings are already short, and we use nothing else. The classes ParityMapping and BravyiKitaev in jordanwigner.py implement the two alternatives, and [QCbook] compares the three mappings on the models of this chapter.

A Hamiltonian on two qubits#

The two-mode Hamiltonian of Eq. (3.23) is the smallest complete example. With Eqs. (3.67) and (3.68), and \(\hat{n}_0\hat{n}_1=(I-Z_0)(I-Z_1)/4\),

\[ \hat{H} = \left(\frac{\varepsilon_0+\varepsilon_1}{2}+\frac{U}{4}\right)I - \frac{2\varepsilon_0+U}{4}Z_0 - \frac{2\varepsilon_1+U}{4}Z_1 + \frac{U}{4}Z_0Z_1 + \frac{t}{2}\left(X_0X_1+Y_0Y_1\right) ,\tag{3.71} \]

six Pauli strings, none of weight greater than two. Its matrix in the basis \(\vert 00\rangle,\vert 01\rangle,\vert 10\rangle,\vert 11\rangle\) is Eq. (3.24), block diagonal because the strings \(Z_0\), \(Z_1\), \(Z_0Z_1\) are diagonal and \(X_0X_1+Y_0Y_1\) flips the two qubits in opposite directions, conserving the number of ones. For \(\varepsilon_0=1\), \(\varepsilon_1=2\), \(t=0.3\) and \(U=0.5\) the coefficients are \(1.625\), \(-0.625\), \(-1.125\), \(0.125\) and \(0.15\), and the one-particle block has the eigenvalues \(0.9169\) and \(2.0831\) of Section A worked example: two modes. Everything a quantum computer will be asked to do with a Hamiltonian in this text can be practised on Eq. (3.71): a Trotter step is five rotations, the energy is three measurement settings, and the exact ground state in the one-particle sector is reached from \(\vert 10\rangle\) by a single two-qubit rotation.

The four models on a qubit register#

The generic mapping of Section The Jordan–Wigner transformation uses one qubit per single-particle mode and lets the Hamiltonian act on the whole Fock space, all particle numbers included. That is wasteful for the same reason that full diagonalization is wasteful in Section Full configuration interaction: a symmetry of the Hamiltonian restricts the physics to a sector, and if the sector can be parametrized by fewer bits, fewer qubits are needed although the resulting operators need not be shorter or sparser. Every model of Section Four model Hamiltonians is a case in point, and we take them in turn. The recipe is always the same. Identify the conserved quantity; choose a basis of the relevant sector whose states are labeled by bit strings; write the Hamiltonian in that basis in terms of operators that act on single bits; and map those operators onto Pauli matrices. In the local doublet and pair encodings below, the effective spin or hard-core boson operators commute between sites, so no fermionic parity strings are needed. This simplification is a property of these encodings, not of every sector restriction.

We keep the conventions of Chapter 2 and of the earlier sections: an occupied fermionic mode or pairing level is \(\vert1\rangle\), and the Lipkin upper level is \(\vert1\rangle\). Their occupation-raising operator is \((X-iY)/2\). For physical Heisenberg spins we retain \(S^z=Z/2\), \(\vert0\rangle=\vert\uparrow\rangle\) and \(S^+=(X+iY)/2\). These are distinct meanings of the bit label, not conflicting Pauli matrices. Swapping the two local basis states conjugates by \(X\), taking \(Y\to-Y\) and \(Z\to-Z\); a magnetic-field term must transform too. The zero-field Heisenberg exchange is unchanged.

The Lipkin model. The Lipkin Hamiltonian of Eq. (3.25) can be mapped mode by mode with Eq. (3.66); for \(N=\Omega=4\) this needs eight qubits and gives \(61\) strings of weight up to four. Its quasispin structure allows a cheaper encoding with one qubit per doublet. At half filling, \(N=\Omega\), each doublet \(\{(p,-),(p,+)\}\) holds exactly one particle in every state that the Hamiltonian can reach from the reference, so one bit per doublet suffices: \(\vert 0\rangle_p\) for the particle in the lower level and \(\vert 1\rangle_p\) for the upper. The quasispin of a single doublet, \(j_z^{(p)}=\frac12\sum_\sigma\sigma\,a^{\dagger}_{p\sigma}a_{p\sigma}\) and \(j_+^{(p)}=a^{\dagger}_{p+}a_{p-}\), is a spin-\(1/2\) on that bit,

\[ j_z^{(p)} \longrightarrow -\frac{Z_p}{2}, \qquad j_{\pm}^{(p)} \longrightarrow \frac{X_p\mp iY_p}{2} ,\tag{3.72} \]

with no parity strings, because the operators \(a^{\dagger}_{p+}a_{p-}\) of different doublets commute: each contains two fermionic operators and the two signs cancel. Inserting \(\hat{J}_z=\sum_pj_z^{(p)}\) and \(\hat{J}_\pm=\sum_pj_\pm^{(p)}\) into Eq. (3.27) gives, for \(N=4\), \(\varepsilon=2\), \(V=-1/3\), \(W=-1/4\),

\[ \hat{H} = -\sum_{p}Z_p - \frac7{24}\sum_{p<q}X_pX_q + \frac1{24}\sum_{p<q}Y_pY_q ,\tag{3.73} \]

sixteen strings of weight at most two on four qubits. The coefficients follow from \(j_+^{(p)}j_+^{(q)}+j_-^{(p)}j_-^{(q)} =\frac12(X_pX_q-Y_pY_q)\) and \(j_+^{(p)}j_-^{(q)}+j_-^{(p)}j_+^{(q)} =\frac12(X_pX_q+Y_pY_q)\): each pair of doublets receives \(\frac{V}{2}(X_pX_q-Y_pY_q)\) from the \(\hat{J}_\pm^2\) terms and \(\frac{W}{2}(X_pX_q+Y_pY_q)\) from the \(\hat{J}_+\hat{J}_-+\hat{J}_-\hat{J}_+\) terms, so that the \(XX\) coefficient is \((V+W)/2=-0.2917\) and the \(YY\) coefficient \((W-V)/2=0.0417\), while the \(p=q\) terms of \(\hat{J}_+\hat{J}_-+\hat{J}_-\hat{J}_+\) give the constant \(N\) that the \(-\hat{N}\) in Eq. (3.27) removes. The \(16\)-dimensional register contains \(J=0,1,2\), with multiplicities; the \(J=2\) eigenvalues occur in it. For the stated parameters the ground state lies in \(J=2\), as checked against the full fixed-\(N\) calculation. This is not a consequence of symmetry alone. Starting in the reference and using \(J^2\)-preserving evolution stays in \(J=2\); an unrestricted variational circuit need not do so.

The doublet encoding is the natural one: it keeps all quasispin sectors within the one-particle-per-doublet subspace, while excluding empty and doubly occupied doublets. Its Hamiltonian is a sum of two-qubit terms, and its reference state, all particles in the lower level, is the register \(\vert 0000\rangle\). It is the encoding used in Chapter 6, where the symmetry-broken mean field of Section Stability and the Lipkin model reappears as the product state in which every qubit is rotated by the same angle. One-hot and binary encodings of a single quasispin block are alternatives with different trade-offs between qubits and Pauli weight [QCbook].

The pairing model. We begin with one qubit per spin-orbital. In the following pairing formulas physical levels are labeled \(p=1,\ldots,L\); Python arrays and qubits use \(0,\ldots,L-1\), so qubit \(p-1\) represents level \(p\). Order the spin-orbitals so that the two partners of a level are adjacent, \((1+,1-,2+,2-,\ldots)\), which keeps the parity strings inside a level empty, and apply Eq. (3.66) to Eq. (3.29). The one-body term and the diagonal part of the interaction, \(-\frac{g}{2}\hat{P}^+_p\hat{P}^-_p =-\frac{g}{2}\hat{n}_{p+}\hat{n}_{p-}\), are diagonal,

\[ \hat{H}_0 + \hat{V}_{\mathrm{diag}} = \sum_p\left\{ \frac{\xi(p-1)}{2}\left[(I-Z_{p+})+(I-Z_{p-})\right] - \frac{g}{8}\left(I-Z_{p+}\right)\left(I-Z_{p-}\right)\right\} ,\tag{3.74} \]

and the pair transfers between different levels are the eight-string operators of Eq. (3.70). For \(L=2\), \(\xi=1\) and \(g=1\) the result is fifteen strings on four qubits,

\[\begin{align*} \hat{H} &= \tfrac34\,IIII - \tfrac38\left(IIZI+IIIZ\right) + \tfrac18\left(ZIII+IZII\right) - \tfrac18\left(ZZII+IIZZ\right)\\ & - \tfrac1{16}\big(XXXX+XYXY+XYYX+YXXY+YXYX+YYYY-XXYY-YYXX\big) ,\tag{3.75} \end{align*}\]

seven diagonal strings and eight of weight four, produced by mapped_models.py from the tabulated matrix elements, so that it is an exact decomposition rather than a hand calculation to be trusted. For \(L\) levels the count is \(4L(L-1)+3L+1\) strings: one identity, \(2L\) single \(Z\)’s, \(L\) strings \(Z_{p+}Z_{p-}\) and eight weight-four strings for each of the \(L(L-1)/2\) pairs of levels. The largest weight stays at four however large \(L\) becomes, because the operators come in pairs acting on adjacent modes \(2p\) and \(2p+1\), whose parity strings differ by a single \(Z\) and cancel.

A second encoding uses one qubit per level. Section The pairing model showed that the reduced pairing interaction conserves seniority. In the attractive regime considered here, the even-particle ground state lies in seniority zero: every level is either empty or holds a pair. In that space a level is one bit, and the pair operators of Eq. (3.30) act on it as a spin-\(1/2\),

\[ \hat{S}^+_p = \hat{P}^+_p,\qquad \hat{S}^-_p = \hat{P}^-_p,\qquad \hat{S}^z_p = \frac12\left(\hat{N}_p-1\right), \qquad [\hat{S}^z_p,\hat{S}^\pm_p]=\pm\hat{S}^\pm_p,\quad [\hat{S}^+_p,\hat{S}^-_p]=2\hat{S}^z_p ,\tag{3.76} \]

with operators of different levels commuting. Each level carries its own \(su(2)\), the same algebra that organized the Lipkin model, and the map to Pauli matrices is Eq. (3.65) without any parity string,

\[ \hat{S}^+_p = \frac{X_p-iY_p}{2},\qquad \hat{S}^-_p = \frac{X_p+iY_p}{2},\qquad \hat{S}^z_p = -\frac{Z_p}{2},\qquad \hat{N}_p = I-Z_p ,\tag{3.77} \]

with \(\vert 0\rangle_p\) an empty level and \(\vert 1\rangle_p\) a full one. The \(p=q\) part of the interaction is \(-\frac{g}{2}\sum_p\hat{S}^+_p\hat{S}^-_p=-\frac{g}{4}\sum_p(I-Z_p)\) and merges with the one-body term, \(\xi(p-1)\hat{N}_p=\xi(p-1)(I-Z_p)\); the \(p\ne q\) part uses \(\hat{S}^+_p\hat{S}^-_q+\hat{S}^+_q\hat{S}^-_p=\frac12(X_pX_q+Y_pY_q)\), the imaginary parts cancelling between the two orderings. The result is

\[ \hat{H} = \sum_{p=1}^{L}\left[\xi(p-1)-\frac{g}{4}\right]\left(I-Z_p\right) - \frac{g}{4}\sum_{p<q}\left(X_pX_q+Y_pY_q\right) ,\tag{3.78} \]

\(L^2+1\) nonzero strings for generic parameters, of weight at most two on \(L\) qubits. Special parameter choices can cancel coefficients. For two levels with \(\xi=1\) and \(g=1\),

\[ \hat{H}^{(L=2)} = \tfrac12\,II + \tfrac14\,ZI - \tfrac34\,IZ - \tfrac14\left(XX+YY\right) ,\tag{3.79} \]

five strings on two qubits against the fifteen strings on four qubits of Eq. (3.75). Equation (3.78) also identifies what kind of spin model the pairing Hamiltonian is: an \(XY\) model with couplings of infinite range in an inhomogeneous field, the Heisenberg model of Eq. (3.35) with the \(ZZ\) term removed and every site coupled to every other. The compact form is a restriction, not an approximation. Its spectrum in the sector with \(n\) ones is exactly the seniority-zero spectrum of the full Hamiltonian with \(2n\) particles, and mapped_models.py checks this for \(L=2\) and \(3\) and every \(n\), eigenvalue by eigenvalue, and checks as well that each of these eigenvalues appears in the spectrum of the full encoding. The compact encoding exists because seniority is conserved. Once the particle-hole term of Eq. (3.31) is switched on, the Hamiltonian connects the seniority-zero states to states with a broken pair, which have no representative on an \(L\)-qubit register, and the full \(2L\)-qubit orbital encoding has to be used: for \(L=3\) and \(f=0.5\) it has \(118\) strings of maximum weight six, against the \(10\) strings of weight two of the compact form.

The Hubbard model. For the Hubbard model of Eq. (3.32) we first use the full \(2N_s\)-qubit orbital encoding and examine the mode ordering. This is a choice, not a lower bound: at fixed \(N_\uparrow,N_\downarrow\) the sector dimension is \(\binom{N_s}{N_\uparrow}\binom{N_s}{N_\downarrow}\), and the two spin-number parities can also be tapered. For \(N_s=4\), \(N_\uparrow=N_\downarrow=2\), the sector has \(36\) states and needs at least six qubits. The interaction \(U\hat{n}_{i\uparrow}\hat{n}_{i\downarrow}\) is diagonal and has no parity strings whatever the order. The hopping terms are the two strings of Eq. (3.68), whose weight is the distance between the two modes in the chosen order plus one. Two natural orders for the four-site ring are the site-major order \((0{\uparrow},0{\downarrow},1{\uparrow},1{\downarrow},\ldots)\) and the spin-major order \((0{\uparrow},1{\uparrow},2{\uparrow},3{\uparrow}, 0{\downarrow},\ldots)\). In the first, a hop between neighboring sites jumps over the partner spin-orbital and has weight three, and the bond that closes the ring, between sites \(3\) and \(0\), has weight seven. In the second, the same hop has weight two and the closing bond weight four. The number of strings, \(29\), is the same, but the longest string is seven in one case and four in the other. The simple gadget cost of Section The exponential of a Pauli string depends on the sum \(2\sum_\alpha(w_\alpha-1)\) over nonidentity strings. Here spin-major ordering lowers the hopping cost from \(96\) to \(48\) CNOTs per first-order step, before routing or cancellations; the four interaction \(ZZ\) strings add eight in either ordering. For a two-dimensional lattice no order makes all bonds short, and the weight of the worst hop grows with the linear size of the lattice; this is the case in which the Bravyi–Kitaev mapping, or one of the local encodings that add auxiliary qubits to cancel the parity strings, pays off. The ground-state energy of the eight-qubit Hamiltonian in the four-particle sector is \(-2.10274848\) at \(U=4t\), the value of Table 3.3.

The Heisenberg model. The Heisenberg model is the easiest of all, because Eq. (3.35) is already a sum of Pauli strings of weight two, \(\frac{J}{4}(X_iX_j+Y_iY_j+Z_iZ_j)\) per bond, twelve strings for the four-site ring: there is no transformation to perform and no parity string to pay for.

model

encoding

qubits

Pauli strings

largest weight

Lipkin, \(N=\Omega=4\)

one per doublet

\(4\)

\(16\)

\(2\)

pairing, \(L=4\)

one per level

\(4\)

\(17\)

\(2\)

pairing, \(L=4\)

one per orbital

\(8\)

\(61\)

\(4\)

Hubbard ring, \(N_s=4\)

one per orbital, spin-major

\(8\)

\(29\)

\(4\)

Heisenberg ring, \(N_s=4\)

one per spin

\(4\)

\(12\)

\(2\)

Table 3.18: The four models at the sizes used in this chapter on a qubit register, in the encoding that uses the symmetry of each model.

Table 3.18 collects the encodings that the following chapters use. Three of the four models fit on four qubits with two-qubit strings only; the pairing model with \(L=4\) and two pairs, the example of every method in this chapter, is a four-qubit calculation with seventeen strings, and the two-level version is a genuine two-qubit calculation that can be tested on a device with the required gates and measurements. With the particle-hole term switched on it is an eight-qubit calculation, which is a rather different proposition.

Tapering a discrete symmetry#

The encodings above restrict the basis using conserved quantum numbers, such as particle number and seniority. A discrete symmetry can be used after the mapping, to remove a qubit from a Pauli sum that already exists. Suppose a Pauli string \(Q\) commutes with every string of \(\hat{H}\); the parity of the particle number, \(Q=Z_0Z_1\cdots Z_{M-1}\), is the standard example, since every term of a number-conserving Hamiltonian contains an even number of \(X\)’s and \(Y\)’s. Then \(\hat{H}\) is block diagonal in the eigenvalues \(\pm1\) of \(Q\), and a Clifford circuit \(U\) that maps \(Q\) onto a single-qubit operator, \(UQU^\dagger=Z_j\), maps \(\hat{H}\) onto a Pauli sum in which qubit \(j\) appears only through \(I_j\) or \(Z_j\). In the sector of interest \(Z_j\) is a number, \(\pm1\), so it can be replaced by that number and qubit \(j\) dropped. For the two-level pairing Hamiltonian of Eq. (3.79) the symmetry is \(Q=Z_0Z_1\) and the circuit is a single CNOT, which maps \(Z_1\to Z_0Z_1\) and hence \(Z_0Z_1\to Z_1\), \(X_0X_1\to X_0\) and \(Y_0Y_1\to -X_0Z_1\). In the one-pair sector \(Q=-1\), and mapped_models.py finds

\[ \hat{H}^{(L=2)} \;\longrightarrow\; \frac12\,I + Z - \frac12\,X , \qquad E_\pm = \frac12\pm\frac{\sqrt5}{2} = -0.618034,\ 1.618034 ,\tag{3.80} \]

a single-qubit Hamiltonian whose spectrum is the seniority-zero spectrum with one pair. The two-level pairing model with one pair is a one-qubit problem, and its ground state is a single rotation \(R_y(\theta)\vert 0\rangle\) with \(\theta=\pi-\arctan(1/2)\) modulo \(2\pi\); the tangent alone does not distinguish the ground state from the excited state. Under the CNOT, \(\vert10\rangle\) and \(\vert01\rangle\) map to \(\vert11\rangle\) and \(\vert01\rangle\), so the retained qubit basis is explicit. The procedure, known as qubit tapering, removes one qubit per independent, mutually commuting Pauli \(Z_2\) symmetry whose eigenvalue is fixed. Independence is over binary Pauli labels. Tapering parity does not generally fix particle number: for \(L=3\) the odd-pair-parity sector contains both one and three pairs. Initial states, observables and subsequent operations must be transformed consistently; an observable changing the symmetry sector cannot simply have the same qubit deleted.

From Pauli sums to circuits and measurements#

A Pauli sum becomes a calculation through a small number of circuits: the exponential of a single string, from which Trotter steps and variational ansätze are built; the preparation of a reference state; and the measurement of the energy. This section constructs them and closes with the first variational quantum calculation of the text, the unitary coupled-cluster circuit for the pairing model, which reproduces the numbers of Section Unitary coupled cluster with four rotation angles on four qubits.

The exponential of a Pauli string#

Every algorithm of the following chapters needs the unitary \(e^{-i\theta P}\) for a Pauli string \(P\) and a real angle \(\theta\): the Trotter steps of Chapter 4 are products of such factors with \(\theta=h_\alpha\Delta t\), and the unitary coupled-cluster circuits of Chapter 6 are products of such factors with variational angles. For a single qubit and \(P=Z\) the operator is the rotation \(R_z(2\theta)\) of Chapter 2. For a string of weight \(w\) the construction rests on two facts. First, the single-qubit Clifford gates rotate the Pauli matrices into each other, \(HXH=Z\) and \((HS^\dagger)Y(HS^\dagger)^\dagger=Z\). Thus \(B_X=H\) and \(B_Y=HS^\dagger\): on a state, apply \(S^\dagger\) first and then \(H\) for a \(Y\) factor. The inverse change applies \(H\) and then \(S\). Second, a chain of CNOT gates along the support of the string collects the parity of the \(w\) qubits onto the last one: after applying \(\mathrm{CNOT}_{q_1q_2}\) first and \(\mathrm{CNOT}_{q_{w-1}q_w}\) last, the last qubit holds \(z_{q_1}\oplus\cdots\oplus z_{q_w}\), whose \(Z\) eigenvalue is \((-1)^{z_{q_1}\oplus\cdots\oplus z_{q_w}}\), and \(R_z(2\theta)\) on that qubit multiplies each basis state by \(e^{\mp i\theta}\) according to it. Undoing the chain and the basis change gives

\[ e^{-i\theta P} = B^\dagger\, C^\dagger\, R_z^{(q_w)}(2\theta)\, C\, B ,\tag{3.81} \]

with \(B\) the basis change and \(C\) the CNOT chain, a circuit with \(2(w-1)\) CNOT gates, one rotation and at most \(4w\) single-qubit gates, with a chain depth linear in \(w\), before routing. This construction assumes \(w\ge1\). For the identity, \(e^{-i\theta I}\) is a known global phase; the implementation omits it. Under coherent control this becomes a relative phase and must be restored on the control. Figure 3.5 shows it for \(P=X_0Y_1\). The function pauli_rotation in pauli_circuits.py appends this sequence to a Circuit of Chapter 2; the example checks it against \(e^{-i\theta P}=I\cos\theta-iP\sin\theta\),

import numpy as np
from circuit import Circuit
from pauli import string_matrix
from pauli_circuits import pauli_rotation, gate_counts
P, theta = "XY", 0.37
circ = pauli_rotation(Circuit(2), P, theta)
exact = np.cos(theta)*np.eye(4) - 1j*np.sin(theta)*string_matrix(P)
assert np.allclose(circ.unitary(), exact)
print("gates, CNOTs, depth:", gate_counts(circ))
gates, CNOTs, depth: (9, 2, 7)

The full program also checks that the unitary of the circuit equals the matrix exponential of \(-i\theta P\) for \(ZZ\), \(XX\), \(YY\), \(XZZY\) and \(XYXY\); the gate counts are \(3\), \(7\), \(11\), \(13\) and \(19\) gates with \(2\), \(2\), \(2\), \(6\) and \(6\) CNOTs. The weight of a string is thus, up to a factor two, the number of entangling gates its exponential costs, which is why the tables of Section The four models on a qubit register list it.

The circuit of Eq. 3.81 for  a basis change on each qubit of the suppo

Figure 3.5: The circuit of Eq. (3.81) for \(e^{-i\theta X_0Y_1}\): a basis change on each qubit of the support, a CNOT that collects the parity on the last qubit, the rotation, and the inverse of the first two steps. For a string of weight \(w\) the CNOT chain has \(w-1\) gates on each side. Verified in pauli_circuits.py.

Trotter steps as circuits and a first time evolution#

With Eq. (3.81) the Trotter formula of Eq. (3.49) becomes a circuit: one Pauli rotation with \(\theta_\alpha=h_\alpha\Delta t\) per string of the Hamiltonian, in some fixed order, repeated \(n\) times, with the identity string contributing a known phase. The circuits below omit that phase for uncontrolled dynamics; phase estimation must account for it. The function trotter_step in pauli_circuits.py builds it for any PauliSum, in the first-order form and in the symmetric form of Eq. (3.48). Table 3.19 gives the cost of one first-order step for the two-level pairing model in the compact encoding and for the four-site Heisenberg ring: \(4\) and \(24\) CNOT gates respectively, and depths \(14\) and \(55\). A bond unitary \(e^{-i\theta(XX+YY+ZZ)}\) can be synthesized with at most three CNOTs instead of the six in three separate Pauli gadgets, a factor of two in this count; special angles can be cheaper, which is one of the optimizations Chapter 4 discusses. The splitting error behaves as in Section The Baker–Campbell–Hausdorff expansion and Trotter splitting: for the pairing Hamiltonian at \(t=1\) the spectral-norm distance between the \(n\)-step circuit and the exact exponential after removing the identity phase is \(0.243\), \(0.106\), \(0.051\), \(0.025\) and \(0.013\) for \(n=1,2,4,8,16\) in first order and \(0.056\), \(0.012\), \(0.0030\), \(0.00075\) and \(0.00019\) in second order, the expected \(1/n\) and \(1/n^2\).

Hamiltonian

strings

gates

CNOTs

depth

pairing, \(L=2\), one qubit per level, Eq. (3.79)

\(5\)

\(20\)

\(4\)

\(14\)

Heisenberg ring, \(N_s=4\), Eq. (3.35)

\(12\)

\(84\)

\(24\)

\(55\)

Table 3.19: One first-order Trotter step as a circuit of Pauli rotations: the number of strings, gates, CNOT gates and the circuit depth. Produced by pauli_circuits.py.

The Trotter circuit can be run as it stands. Prepare the two-level pairing model in the reference state \(\vert 10\rangle\), the pair in the lower level, apply the step circuit of Table 3.19 repeatedly, and record after each step the probability \(P(t)=\vert\langle 01\vert\Psi(t)\rangle\vert^2\) that the pair has been transferred to the upper level. The exact answer is the Rabi oscillation of a two-level system, \(P(t)=\frac{H_{12}^2}{\omega^2}\sin^2\omega t\) with \(\omega=\sqrt{(H_{22}-H_{11})^2/4+H_{12}^2}=\sqrt5/2\) for \(\xi=g=1\), of amplitude \(0.2\) and period \(2\pi/\sqrt5=2.81\). Figure 3.6 shows the circuit results: with \(\Delta t=0.5\) the first-order circuit overshoots the maxima by \(0.03\) and the second-order one undershoots them by \(0.012\), while \(\Delta t=0.1\) in first order is accurate to \(10^{-3}\) at the cost of \(320\) CNOT gates for the full time span. The inset shows a second example that is not a two-level system: the four-site Heisenberg ring started in the Néel state \(\vert 0101\rangle\), which is not an eigenstate, and the staggered magnetization \(m_s(t)=\frac14\sum_i(-1)^i\langle Z_i\rangle/2\) that it develops as the spins exchange; the second-order circuit with \(\Delta t=0.25\), \(46\) CNOT gates per step, follows the exact curve to \(1.93\times10^{-3}\). The normalization gives \(m_s(0)=1/2\) for this Néel state. This is Hamiltonian simulation in its simplest form, and Chapter 4 is about doing it better, with higher-order formulas, with error bounds that use the commutators of the strings, and with methods that are not products of exponentials at all.

Pair-transfer probability in the two-level pairing model xi1, g1 from

Figure 3.6: Pair-transfer probability in the two-level pairing model (\(\xi=1\), \(g=1\)) from the reference state \(\vert 10\rangle\): the exact result and three Trotter circuits, first order with \(\Delta t=0.5\) and \(0.1\) and second order with \(\Delta t=0.5\). Inset: the staggered magnetization of the four-site Heisenberg ring started in \(\vert 0101\rangle\), exact and from first- and second-order circuits with \(\Delta t=0.25\). Produced by pauli_circuits.py.

Reference states and fermionic rotations#

A determinant whose occupied orbitals coincide with the encoded modes is a computational basis state. It needs one \(X\) gate per occupied mode: \(\vert1\cdots10\cdots0\rangle\) in the orbital encoding, the corresponding pair-occupation string in the compact pairing encoding, and \(\vert0\cdots0\rangle\) for the lower-level Lipkin reference. In a binary sector encoding one must first identify the codeword assigned to that reference. Parity and Bravyi–Kitaev encodings similarly require the encoded bit string, not the original occupation bits.

A general Hartree–Fock determinant is a product of occupied-orbital creation operators, but it need not be a tensor product of the original mode qubits. For example, \((a_0^\dagger+a_1^\dagger)\vert\mathrm{vac}\rangle/\sqrt2 =(\vert10\rangle+\vert01\rangle)/\sqrt2\) is one Slater determinant and an entangled two-qubit state. Thouless’ intermediate-normalization operator \(e^{T_1}\) is not unitary and cannot itself be used as a gate. Instead choose an orbital unitary \(U=e^\kappa\), \(\kappa^\dagger=-\kappa\):

\[ \vert\Phi(U)\rangle=\widehat U\vert\Phi_0\rangle,\qquad \widehat U=\exp\!\left(\sum_{pq}\kappa_{pq}a_p^\dagger a_q\right).\tag{3.82} \]

An orbital rotation admits a Givens decomposition into two-mode rotations and phases. Preparing an \(N\)-particle determinant takes \(\mathcal{O}(N(M-N))\) two-mode rotations, with mapped gate and routing costs depending on their placement. Alternatively one may first transform the Hamiltonian into the HF orbital basis, where the reference is a bit string, at the possible cost of less sparse integrals.

Number conservation is a property of the complete implemented unitary. The hopping rotation \(e^{-i\theta(XX+YY)}\) preserves the number of ones; a single \(XX\) or \(YY\) rotation generally does not. Exact paired factors restore that symmetry because \(XX\) and \(YY\) commute. Arbitrary term splitting, noise, and unrestricted variational gates need not preserve every symmetry of the original Hamiltonian.

The single excitation \(a^{\dagger}_qa_p\), the building block of Thouless’ theorem and of the singles part of coupled cluster, has the anti-Hermitian combination

\[ a^{\dagger}_qa_p - a^{\dagger}_pa_q = \frac{i}{2}\left(Y_pZ_{p+1}\cdots Z_{q-1}X_q - X_pZ_{p+1}\cdots Z_{q-1}Y_q\right), \qquad p<q ,\tag{3.83} \]

from Eq. (3.66), two strings that commute, so that its exponential is again a product of two Pauli rotations, with the parity string in between: four CNOT gates for adjacent modes and \(4(q-p)\) in general. Acting on a state with mode \(p\) occupied and \(q\) empty it produces \(\cos\theta\,\vert 1_p0_q\rangle+\sin\theta\,\vert 0_p1_q\rangle\) with the sign of the parity in between, the fermionic analogue of Eq. (3.89). The function single_excitation in pauli_circuits.py builds it and checks it against the matrix exponential; applied to the two-mode Hamiltonian of Eq. (3.71) from \(\vert 10\rangle\), a single such rotation reaches the one-particle ground state \(0.916905\) at \(\theta=-0.2702\), that is \(\tan2\theta=2t/(\varepsilon_0-\varepsilon_1)\).

A product of such rotations, together with orbital phase gates for complex coefficients, prepares any Slater determinant from a computational basis state. The Lipkin model shows this most simply. In the doublet encoding the mean-field state of Section Stability and the Lipkin model, every doublet rotated by the same angle \(\alpha\), is the product state \(\prod_pR_y(\alpha)_p\vert 0000\rangle\), one single-qubit gate per qubit and no entanglement at all. Minimizing the expectation value of the doublet Hamiltonian with \(\varepsilon=1\), \(W=0\) and \(V=-\chi/(N-1)\) in this state over \(\alpha\) reproduces the Hartree–Fock energies of Table 3.11 to six digits, Table 3.20, with \(\alpha=0\) below \(\chi=1\) and \(\cos\alpha=1/\chi\) above, \(0.8411\) at \(\chi=1.5\) and \(\pi/3\) at \(\chi=2\). In this doublet encoding, the mean field is a layer of single-qubit rotations; everything the mean field misses, the difference between the last two columns of the table, requires entangling gates, and the variational algorithms of Chapter 6 are about adding them economically.

\(\chi\)

\(\alpha\)

\(E\)(product state)

\(E_{\mathrm{HF}}\)

\(E_{\mathrm{exact}}\)

\(0.5\)

\(0\)

\(-2.000000\)

\(-2.000000\)

\(-2.081666\)

\(1.0\)

\(0\)

\(-2.000000\)

\(-2.000000\)

\(-2.309401\)

\(1.5\)

\(0.8411\)

\(-2.166667\)

\(-2.166667\)

\(-2.645751\)

\(2.0\)

\(1.0472\)

\(-2.500000\)

\(-2.500000\)

\(-3.055050\)

\(2.5\)

\(1.1593\)

\(-2.900000\)

\(-2.900000\)

\(-3.511885\)

Table 3.20: The Lipkin mean field as a product state on four qubits (\(N=\Omega=4\), \(\varepsilon=1\), \(W=0\)): the optimal common rotation angle, the energy of the product state, the self-consistent Hartree–Fock energy of Table 3.11 and the exact energy. Produced by pauli_circuits.py.

Measuring a Pauli sum#

The last ingredient is the readout. A quantum computer measures in the computational basis, which gives the eigenvalue \(\pm1\) of every \(Z_q\) at once; the expectation value of a string of \(Z\)’s in a state \(\vert\Psi\rangle\) is therefore the average of \((-1)^{z_{q_1}\oplus\cdots\oplus z_{q_w}}\) over repeated preparations and measurements, the shots. A string containing \(X\) or \(Y\) is measured the same way after the basis change \(B\) of Eq. (3.81), \(H\) on the \(X\) qubits and \(HS^\dagger\) on the \(Y\) qubits, that is \(S^\dagger\) followed by \(H\) on the state. The energy of a Pauli sum is then

\[ \langle\Psi\vert\hat{H}\vert\Psi\rangle = \sum_\alpha h_\alpha\langle\Psi\vert P_\alpha\vert\Psi\rangle \approx \sum_\alpha h_\alpha\,\frac{1}{S}\sum_{s=1}^{S}(-1)^{\pi_\alpha(s)} ,\tag{3.84} \]

with \(\pi_\alpha(s)\) the parity of shot \(s\) on the support of \(P_\alpha\). For independent preparations each sample mean has standard deviation \(\sigma_\alpha/\sqrt S\), where \(\sigma_\alpha^2=1-\langle P_\alpha\rangle^2\). Here “accuracy” will mean root-mean-square (RMS) sampling error, not a guaranteed decimal digit or a confidence bound. The identity coefficient is known exactly and costs no shots. Sampling can dominate a variational calculation, but state preparation and optimization also contribute to the total cost. Not every string needs its own circuit. Strings that commute qubit by qubit, meaning that wherever both are not the identity they carry the same Pauli matrix, can be read off from the same basis rotation and the same shots, so the strings are first partitioned into such groups, and the number of groups, not the number of strings, is the number of measurement settings. The two-level pairing Hamiltonian of Eq. (3.79) has three: \(\{II, ZI, IZ\}\), which need no rotation, \(\{XX\}\) and \(\{YY\}\). Table 3.21 gives the number of settings for the models of Section The four models on a qubit register, obtained by a greedy grouping in pauli.py: the doublet Lipkin, compact pairing and spin Heisenberg examples need three, the \(XX\), \(YY\) and \(ZZ\) types of strings, whereas the one-qubit-per-orbital pairing Hamiltonian with its eight-string pair transfers needs seventeen. Better groupings exist, using strings that commute without commuting qubit by qubit and entangling measurements to read them out, but the qubit-wise grouping is what is routinely done, and the table makes the point once more that the chosen compact encodings have cheaper measurement groupings in these examples; this need not hold for arbitrary compression. The function energy_from_shots in pauli_circuits.py does all of this on the simulator of Chapter 2, whose sample method draws bit strings from the exact probabilities,

import numpy as np
from statevector import StateVector
from models import PairingModel
from pauli_circuits import compact_pairing, sector_ground_state
from pauli_circuits import energy_from_shots, measurement_variances
H = compact_pairing(PairingModel(2, g=1.0))
exact, psi = sector_ground_state(H, 1)
rng = np.random.default_rng(7)
estimate, settings = energy_from_shots(H, StateVector(2, psi), 1000, rng)
variance = sum(row[2] for row in measurement_variances(H, psi))/1000
print(exact, estimate, settings, np.sqrt(variance))
-0.6180339887498948 -0.6175 3 0.017320508075688777

Table 3.22 shows the estimate of the ground-state energy of the two-level pairing model, \(-0.618034\), from \(S\) shots per setting: the root-mean-square error over twenty repetitions is consistent with \(1/\sqrt{S}\) scaling. The exact equal-allocation variance is \(\mathrm{Var}(\widehat E)=0.30/S\): \(0.20/S\) from the diagonal group and \(0.05/S\) from each of \(XX\) and \(YY\). Hence the asymptotic RMS is \(\sqrt{0.30}/\sqrt S\simeq0.5477/\sqrt S\), consistent with the finite repetition estimates. An RMS target of \(10^{-3}\) requires \(3\times10^5\) shots per setting, or \(9\times10^5\) total. A confidence requirement must be specified separately. On hardware the same numbers are affected in addition by readout errors and by the imperfections of the state-preparation circuit, which error mitigation and, eventually, quantum error correction have to deal with.

For separate measurements of each nonidentity string, independent shot batches give \(\mathrm{Var}(\widehat E)=\sum_\alpha h_\alpha^2 \sigma_\alpha^2/S_\alpha\). Minimizing at fixed total \(S_{\mathrm{tot}}\) using a Lagrange multiplier gives

\[ S_\alpha=S_{\mathrm{tot}} \frac{|h_\alpha|\sigma_\alpha}{\sum_\beta|h_\beta|\sigma_\beta},\qquad \mathrm{Var}_{\min}(\widehat E) =\frac{(\sum_\alpha|h_\alpha|\sigma_\alpha)^2}{S_{\mathrm{tot}}} .\tag{3.85} \]

This continuous allocation ignores integer rounding and presumes the variances are known; pilot measurements estimate them in practice. Replacing every \(\sigma_\alpha\) by one gives a sufficient worst-case bound, with the identity excluded. Equal shots per term instead give \(K\sum_\alpha h_\alpha^2\sigma_\alpha^2/S_{\mathrm{tot}}\).

Grouping changes the variance because strings share the same bit strings. For group \(g\), let \(A_g=\sum_{\alpha\in g}h_\alpha P_\alpha\) and define

\[\begin{align*} v_g&=\langle A_g^2\rangle-\langle A_g\rangle^2 =\sum_{\alpha,\beta\in g}h_\alpha h_\beta \left(\langle P_\alpha P_\beta\rangle -\langle P_\alpha\rangle\langle P_\beta\rangle\right),\\ \mathrm{Var}(\widehat E)&=\sum_g\frac{v_g}{S_g},\qquad S_g\propto\sqrt{v_g},\qquad S_{\mathrm{tot}}=\frac{(\sum_g\sqrt{v_g})^2}{\epsilon^2} \quad\hbox{at the optimum}.\tag{3.86} \end{align*}\]

The last equality gives the continuous shot budget for an RMS target \(\epsilon\). Covariances can help or hurt; commuting alone does not make them vanish. Take the four-level pairing Hamiltonian in the compact encoding (\(\xi=g=1\), seventeen strings) and its ground state in the two-pair sector, \(E_0=0.63554847\), the sector used for the unitary coupled-cluster calculation of Section A first variational circuit: unitary coupled cluster for the pairing model. For this two-pair state, independent optimal term measurements require about \(2.99\times10^7\) shots at \(\epsilon=10^{-3}\), compared with the worst-case nonidentity-coefficient bound \(7.225\times10^7\). The three group variances are \(v_X=v_Y=0.67877752\) and \(v_Z=1.35219637\). Using their covariances, optimal group allocation needs about \(7.90\times10^6\) total shots; equal allocation over the three groups needs \(8.13\times10^6\). These compare statistical budgets for one fixed state, not the total cost of optimizing a variational circuit.

Hamiltonian

qubits

strings

settings

Lipkin, one qubit per doublet

\(4\)

\(16\)

\(3\)

pairing \(L=4\), one qubit per level

\(4\)

\(17\)

\(3\)

pairing \(L=4\), one qubit per orbital

\(8\)

\(61\)

\(17\)

Hubbard ring, spin-major ordering

\(8\)

\(29\)

\(5\)

Heisenberg ring

\(4\)

\(12\)

\(3\)

Table 3.21: Measurement settings: the number of groups of qubit-wise commuting strings for the Hamiltonians of Section The four models on a qubit register, by greedy grouping. Produced by mapped_models.py.

\(S\)

one estimate

rms error

rms error \(\times\sqrt{S}\)

\(10^2\)

\(-0.63000\)

\(6.5\times10^{-2}\)

\(0.65\)

\(10^3\)

\(-0.61500\)

\(1.6\times10^{-2}\)

\(0.52\)

\(10^4\)

\(-0.60780\)

\(5.5\times10^{-3}\)

\(0.55\)

\(10^5\)

\(-0.61936\)

\(1.7\times10^{-3}\)

\(0.54\)

Table 3.22: The ground-state energy of the two-level pairing model (\(\xi=1\), \(g=1\), exact value \(-0.61803399\)) estimated from \(S\) shots per measurement setting with three settings: one estimate, the root-mean-square error over twenty repetitions, and the latter scaled by \(\sqrt{S}\). Produced by pauli_circuits.py.

A first variational circuit: unitary coupled cluster for the pairing model#

Everything is now in place to redo the unitary coupled-cluster calculation of Section Unitary coupled cluster as a quantum circuit. In the compact encoding of Section The four models on a qubit register a pair excitation from level \(i\) to level \(a\) is \(\hat{S}^+_a\hat{S}^-_i\), and its anti-Hermitian combination is, by Eq. (3.77),

\[ \hat{S}^+_a\hat{S}^-_i - \hat{S}^+_i\hat{S}^-_a = \frac{i}{2}\left(Y_iX_a - X_iY_a\right) ,\tag{3.87} \]

two Pauli strings that commute with each other, so that the exponential factorizes exactly,

\[ e^{\theta(\hat{S}^+_a\hat{S}^-_i - \mathrm{h.c.})} = e^{-i(-\theta/2)Y_iX_a}\,e^{-i(\theta/2)X_iY_a} ,\tag{3.88} \]

two Pauli rotations of Eq. (3.81), four CNOT gates in all, shown in Fig. 3.7. Acting on a register in which level \(i\) is full and level \(a\) empty, the gate produces

\[ e^{\theta(\hat{S}^+_a\hat{S}^-_i - \mathrm{h.c.})}\vert 1_i0_a\rangle = \cos\theta\,\vert 1_i0_a\rangle + \sin\theta\,\vert 0_i1_a\rangle ,\tag{3.89} \]

a rotation in the one-pair subspace, acting as the identity on \(\vert00\rangle\) and \(\vert11\rangle\), and it leaves the number of ones unchanged. For the two-level model with one pair this is already the complete ansatz: \(\vert\Psi(\theta)\rangle=\cos\theta\vert 10\rangle+\sin\theta\vert 01\rangle\), the energy is \(E(\theta)=H_{11}\cos^2\theta+H_{22}\sin^2\theta+H_{12}\sin2\theta\) with the \(2\times2\) seniority-zero matrix of Section The pairing model, that is \(-\frac12\cos^2\theta+\frac32\sin^2\theta-\frac12\sin2\theta\) for \(\xi=g=1\), and its minimum, at \(\theta=0.2318\), is the exact ground state \(-0.618034=\frac12-\frac{\sqrt5}{2}\), as the right panel of Fig. 3.8 shows. The program pauli_circuits.py checks Eq. (3.89) against the circuit for every \(\theta\) on a grid.

The pair-excitation gate of Eq. 3.88,  in the one-qubit-per-level enco

Figure 3.7: The pair-excitation gate of Eq. (3.88), \(\exp[\theta(\hat{S}^+_a\hat{S}^-_i-\mathrm{h.c.})]\) in the one-qubit-per-level encoding: the rotation \(e^{i(\theta/2)Y_iX_a}\) followed by \(e^{-i(\theta/2)X_iY_a}\), each built as in Fig. 3.5. Four CNOT gates and one parameter. Verified in pauli_circuits.py.

For \(L=4\) and two pairs the ansatz of Section Unitary coupled cluster has the four generators \(\hat{S}^+_a\hat{S}^-_i\) with zero-based qubit labels \(i\in\{0,1\}\) and \(a\in\{2,3\}\), and its one-step Trotterized form, Eq. (3.60) with \(n=1\), is the circuit

\[ \vert\Psi(\theta)\rangle = U_4(\theta_4)U_3(\theta_3) U_2(\theta_2)U_1(\theta_1)X_0X_1\vert0000\rangle,\qquad U_k(\theta_k)=e^{\theta_k(\hat S^+_{a_k}\hat S^-_{i_k}-\mathrm{h.c.})} ,\tag{3.90} \]

where \((i_k,a_k)=(0,2),(0,3),(1,2),(1,3)\) and \(U_1\) acts first. These are four pair-excitation gates after the two \(X\) gates that prepare \(\vert 1100\rangle\): \(74\) gates, \(16\) CNOTs, depth \(38\), four parameters. The program evaluates the energy of the circuit state with the seventeen-string Hamiltonian of Eq. (3.78) and minimizes it with the BFGS routine of Section Unitary coupled cluster. Table 3.23 shows the result against the UCCD energies of Table 3.15, recomputed with the program of Section Unitary coupled cluster: they agree to all eight digits, at every coupling. This is a numerical agreement for this model, generator order and local optimization, not an identity between the product ansatz and the single exponential. Section Trotterized unitary coupled cluster writes its product with the rightmost listed generator acting first; the chronological convention here is stated explicitly. Reversing or otherwise changing the order generally changes the variational family. Both circuits give variational upper bounds when evaluated exactly in the correct particle sector, but neither local optimization proves a global minimum. The comparison is a noiseless state-vector simulation, with exact energy evaluation. Replacing the exact expectation value by Eq. (3.84) and the simulator by hardware is the variational quantum eigensolver of Chapter 6.

\(g\)

\(E_{\mathrm{ref}}\)

circuit

UCCD, Sec. Unitary coupled cluster

FCI

\(0.25\)

\(1.75\)

\(1.73046012\)

\(1.73046012\)

\(1.73045985\)

\(0.50\)

\(1.50\)

\(1.41679562\)

\(1.41679562\)

\(1.41677428\)

\(1.00\)

\(1.00\)

\(0.63698698\)

\(0.63698698\)

\(0.63554847\)

\(1.50\)

\(0.50\)

\(-0.33675149\)

\(-0.33675149\)

\(-0.34819051\)

\(2.00\)

\(0.00\)

\(-1.45347633\)

\(-1.45347633\)

\(-1.48965216\)

Table 3.23: The unitary coupled-cluster circuit of Eq. (3.90) for the pairing model with \(L=4\) and two pairs (\(\xi=1\)): the optimized energy of the four-parameter circuit, the UCCD energy of Table 3.15, and the exact energy. Produced by pauli_circuits.py.

Left the splitting error of the n-step Trotter circuit for the two-lev

Figure 3.8: Left: the splitting error of the \(n\)-step Trotter circuit for the two-level pairing Hamiltonian at \(t=1\), first and second order. Right: the energy of the state of Eq. (3.89) as a function of the angle of a single pair-excitation gate, for the two-level model with one pair; the minimum is the exact ground-state energy. Produced by pauli_circuits.py.

Summary#

The chapter connects occupation-number algebra to small, reproducible many-body calculations. The three fermionic models use one- and two-body matrix elements, while Heisenberg acts directly on spins. Symmetry helps identify suitable sectors and encodings, but its quantitative benefit depends on the model.

FCI is exact within the chosen basis and sector. HF minimizes over Slater determinants, subject to checking convergence and stability. Truncated CI is variational but generally not size consistent; truncated CC restores the disconnected excitation products and size extensivity, but its projected energy is not a variational upper bound. UCC gives a normalized variational state at increased evaluation cost, and a product of excitation exponentials is a circuit-oriented ansatz whose ordering and expressivity must be specified.

On the quantum computer the same Hamiltonians are sums of Pauli strings. The Jordan–Wigner transformation of Eq. (3.66) supplies them exactly, and the symmetry of each model fixes an encoding in which three of the four models fit on four qubits with strings of weight two. A Pauli rotation costs \(2(w-1)\) CNOT gates for a string of weight \(w\), a Trotter step is one rotation per string, and an energy is estimated from one measurement setting per group of qubit-wise commuting strings, with \(1/\sqrt{S}\) statistics per setting. The pair-excitation gate of Eq. (3.88) assembles these pieces into a four-parameter circuit that reproduces the classical unitary coupled-cluster energies. The following chapters take the same Pauli sums and circuits in three directions: Chapter 4 develops the Trotter circuit into an accurate time evolution, Chapter 5 uses that time evolution to read off eigenvalues, and Chapter 6 develops the variational circuit into the algorithms that run on today’s hardware.

Exercises#

  1. The anticommutator algebra. Using only Eq. (3.3), show that (a) \(\hat{n}_p^2=\hat{n}_p\); (b) \([\hat{n}_p,a^{\dagger}_q]=\delta_{pq}a^{\dagger}_q\) and \([\hat{n}_p,a_q]=-\delta_{pq}a_q\), so that \(a^{\dagger}_q\) raises the occupation of \(q\) by one; (c) the one-body operator \(\hat{F}=\sum_{pq}f_{pq}a^{\dagger}_pa_q\) commutes with \(\hat{N}\); (d) the quasispin operators of Eq. (3.26) satisfy \([\hat{J}_+,\hat{J}_-]=2\hat{J}_z\).

  2. Signs. Write the state \(\vert 0\,2\,3\rangle\) of a four-state system as a bit string and apply, in turn, \(a^{\dagger}_1\), \(a_2\), \(a_1a^{\dagger}_1\) and \(a^{\dagger}_1a_1\), keeping track of the signs of Eq. (3.7). Check your result with apply_creation and with the matrices of FockSpace. Then show, from Eq. (3.9), that \(a_pa_q=-a_qa_p\) for \(p<q\) by locating the single tensor factor on which the two matrices anticommute.

  3. Wick’s theorem. (a) Evaluate \(\langle 0\vert a_sa_ra^{\dagger}_pa^{\dagger}_q\vert 0\rangle\) by anticommuting the operators through each other, and again by listing the three full pairings; the result is \(\delta_{rp}\delta_{sq}-\delta_{sp}\delta_{rq}\). (b) Show that a two-body operator has vanishing matrix elements between determinants that differ by more than two particle replacements, and count the non-zero elements per row of the FCI matrix for the pairing model with \(L=4\) and two pairs in the full \(70\)-dimensional space. (c) Derive the reference energy and the Fock matrix of Eq. (3.21) by normal ordering \(\hat{H}\) with respect to \(\vert\Phi_0\rangle\).

  4. The pairing model in the seniority-zero space. Write the matrix of Eq. (3.29) in the basis of the six pair configurations of \(L=4\), \(n=2\), and diagonalize it for \(g=1\) by hand or with numpy. Compare with Table 3.2. Then add the particle-hole term of Eq. (3.31) with \(f=0.5\), diagonalize in the full space with PairingModel(4, g=1, f=0.5) and show that the ground state acquires seniority-two components. What is the largest matrix element between the seniority-zero block and the rest?

  5. Lipkin mean field. (a) Derive Eq. (3.50) by evaluating \(\langle\Phi(\alpha)\vert\hat{H}\vert\Phi(\alpha)\rangle\) for the rotated determinant, using the quasispin form of Eq. (3.27) with \(W=0\) and the fact that the rotated state is a coherent state of \(\hat{J}\). (b) Find the two stationary points and the energy of the deformed one. (c) Verify with hartreefock.py that the self-consistent iteration reproduces the deformed energy for \(\chi=1.5\) and \(2\) and that the lowest eigenvalue of the stability matrix is \(\varepsilon(1-\chi)\). (d) Explain why the exact ground state has a definite promotion parity \((-1)^{J_z+J}\) and the deformed mean-field state does not.

  6. Size consistency and extensivity. For the two non-interacting copies of Table 3.9: (a) write the CID wave function of one copy, \(\vert\Phi_0\rangle+c\vert\Phi_{\mathrm{D}}\rangle\), and show that the product of two such states contains a quadruple excitation with coefficient \(c^2\); (b) show that the CCD amplitude equations of the combined system separate into those of the parts, so that \(E_{\mathrm{CCD}}(A+B)=E_{\mathrm{CCD}}(A)+E_{\mathrm{CCD}}(B)\); (c) run CCD on NonInteractingCopies(2, g) from fci.py, first permuting the orbitals to put the occupied modes \(0,1,4,5\) before the virtual modes \(2,3,6,7\) in both \(h\) and \(v\), and confirm (b) numerically; (d) is UCCD size extensive?

  7. Trotter errors. (a) Derive the first-order error bound of Eq. (3.47) using a local commutator integral and a telescoping sum; use BCH to identify the leading term. (b) Show that the Strang splitting of Eq. (3.48) has no term of order \(1/n\). (c) For the Heisenberg ring of Fig. 3.2, split the Hamiltonian instead into the \(XX\), \(YY\) and \(ZZ\) parts and compare the errors with the even/odd bond splitting at the same \(n\). Which commutator norm decides?

  8. UCC by hand. For the pairing model with \(L=2\) and one pair, the seniority-zero space is two-dimensional. (a) Write \(\hat{H}\) as a \(2\times2\) matrix and the single pair-excitation generator \(\hat{\kappa}=\hat{P}^+_2\hat{P}^-_1-\mathrm{h.c.}\) in the same basis. (b) Show that \(e^{\theta\hat{\kappa}}\vert\Phi_0\rangle =\cos\theta\,\vert\Phi_0\rangle+\sin\theta\,\vert\Phi_{\mathrm{D}}\rangle\) and that minimizing the energy over \(\theta\) gives the exact ground state. (c) Why does the same argument fail for \(L=4\) and two pairs?

  9. The Jordan–Wigner transformation by hand. (a) Verify \(\hat{n}_p=(I-Z_p)/2\) and \(\{a_p,a^{\dagger}_p\}=I\) from Eq. (3.66). (b) Show that \(a_0\) and \(a_1\) anticommute and locate the factor where the parity string does the work. (c) Derive the hopping identity of Eq. (3.68) for \(q=p+1\). (d) Derive the pair identity of Eq. (3.69) for the same pair and explain the sign difference. (e) Derive Eq. (3.70) for the modes \(0,1,2,3\), or at least the coefficient of \(XXXX\), and check with jw_basics.py.

  10. Quasispin and the qubit encodings of the pairing model. (a) Verify the algebra of Eq. (3.76) from the fermionic anticommutators. (b) Derive Eq. (3.78) from Eq. (3.29) and Eq. (3.77). (c) Show that its spectrum in the sector with \(n\) ones coincides with that of the seniority-zero matrix of Section The pairing model. (d) Explain, without computing anything, why the compact encoding cannot be used once the particle-hole term of Eq. (3.31) is present. (e) Count the strings of the compact Hamiltonian and show that the count is \(L^2+1\) when no coefficients vanish. Identify parameter choices for which it decreases.

  11. The Lipkin model on qubits. (a) Derive Eq. (3.73) from Eq. (3.27) and Eq. (3.72). (b) Show that the register state in which every qubit is rotated by the same angle, \(\prod_p R_y(\alpha)_p\vert 0000\rangle\), is the mean-field state of Section Stability and the Lipkin model, and evaluate its energy as a function of \(\alpha\) from the Pauli form. (c) Why does the doublet encoding contain the \(J=0\) and \(J=1\) sectors as well, and under what condition is this harmless for a ground-state calculation? Check that condition for the parameters of Eq. (3.73).

  12. Pauli rotations. (a) Show that \(HXH=Z\) and \((HS^\dagger)Y(HS^\dagger)^\dagger=Z\), and that \(\mathrm{CNOT}_{01}\,(I\otimes Z)\,\mathrm{CNOT}_{01}=Z\otimes Z\). (b) Use these to prove Eq. (3.81) for \(P=Z_0Z_1\) and for \(P=X_0Y_1\). (c) Build the circuit for \(e^{-i\theta XYZ}\) with pauli_rotation and compare its unitary with the matrix exponential. (d) Show that a Trotter step of the Heisenberg bond \(XX+YY+ZZ\) can be implemented with three CNOT gates instead of six.

  13. Symmetries and tapering. (a) Show that a Pauli string commutes with \(Z_0Z_1\cdots Z_{M-1}\) if and only if it contains an even number of \(X\) and \(Y\) factors, and that every string of a number-conserving Hamiltonian has this property. (b) For the compact pairing Hamiltonian with \(L=3\) find a Clifford circuit that maps \(Z_0Z_1Z_2\) onto \(Z_2\), apply it, fix the eigenvalue for one pair and write the resulting two-qubit Hamiltonian; check its spectrum against the union of the one-pair and three-pair seniority-zero spectra. Explain why parity alone does not select one pair. (c) Why can the total particle number, as opposed to its parity, not be tapered in the same way?

  14. A two-qubit variational calculation. Take the two-level pairing Hamiltonian of Eq. (3.79). (a) Derive the energy \(E(\theta)\) of the state of Eq. (3.89) and find the optimal angle analytically. (b) Estimate \(E(\theta)\) from \(S=1000\) shots per setting with energy_from_shots for twenty angles and locate the minimum; how does the noise affect the estimate of the angle? (c) Repeat with the Hamiltonian including the particle-hole term in the four-qubit encoding, at \(f=0.5\), starting from \(\vert1100\rangle\). Compare the ordered ansatz with generators \(T=a_2^\dagger a_3^\dagger a_1a_0\), \(a_2^\dagger a_0\) and \(a_3^\dagger a_1\), each used as \(e^{\theta(A-A^\dagger)}\) with an independent real angle and the pair factor acting first. Compare with the exact two-particle energy; does this variational family reach it?

Programs for this chapter#

Every number and figure in this chapter comes from the programs in LectureMaterial/BookPrograms/chapter3/ and from the shared modules in LectureMaterial/BookPrograms/common/ that this chapter introduces and Chapters 5 and 6 reuse. All of them are imported by the notebook LectureMaterial/Notebooks/chapter3/chapter3.ipynb, and all run on numpy and matplotlib alone.

  • common/fockspace.py The class FockSpace: the \(2^M\times2^M\) matrices of Eq. (3.9), number operators, one- and two-body operators from tabulated matrix elements, the particle-number sectors, and a check of all anticommutators; and the class SlaterBasis: determinants as bit strings, the sign rule of Eq. (3.7), excitation levels, and the Hamiltonian matrix of Section The structure of the matrix. Instantaneous.

  • common/models.py The classes LipkinModel, PairingModel, HubbardModel and HeisenbergModel: \(h_{pq}\) and \(\langle pq\vert v\vert rs\rangle\) for the fermionic models and direct spin matrices for Heisenberg, the quasispin, seniority-zero and \(S^z\) blocks, and exact diagonalization in a particle-number sector; run as a script it reproduces the reference numbers of Section Four model Hamiltonians. Instantaneous.

  • common/matrixfunctions.py Matrix exponentials of Hermitian and anti-Hermitian matrices by diagonalization, and of general matrices by scaling and squaring. Instantaneous.

  • common/optimize.py A BFGS minimizer with backtracking line search and numerical gradients, used for the unitary coupled-cluster amplitudes here and for the variational algorithms of Chapter 6. Instantaneous.

  • common/pauli.py The class PauliSum of Section Pauli strings and Pauli sums: Pauli strings as words, sums as dictionaries, products, commutators, the decomposition of a matrix by Eq. (3.63), weights, qubit-wise commuting groups, expectation values, a matrix-free product with a state and the norm and commutator bounds of Table 3.17. Instantaneous.

  • common/jordanwigner.py The class JordanWigner of Eq. (3.66) with map_hamiltonian for the general Hamiltonian of Eq. (3.10), and the classes ParityMapping and BravyiKitaev; run as a script it checks all three against the anticommutators and the first against the Fock-space matrices of Section Operators as matrices. Instantaneous.

  • second_quantization.py The worked examples of Section Second quantization: bit strings and signs, anticommutators as matrices, Wick’s theorem against brute force, the Slater–Condon rules, the reference energy, the Fock matrix and the Brillouin elements of Eq. (3.22), and the two-mode Hamiltonian of Section A worked example: two modes. Instantaneous.

  • fci.py Exact diagonalization of the four models, Tables 3.1–3.4 and 3.7, the Lanczos iteration of Table 3.6, truncated CI and the size-consistency test, Tables 3.8 and 3.9, and Fig. 3.1. A few seconds, dominated by the fourteen-site Heisenberg ring.

  • hartreefock.py The class HartreeFock of Section The energy functional and the Hartree–Fock equations with the stability matrix of Eq. (3.44) and the Thouless state of Eq. (3.43); the Lipkin, pairing and Hubbard results of Tables 3.11–3.13 and Fig. 3.3. Seconds.

  • trotter.py The BCH series order by order, the Lie–Trotter and Strang splittings of Table 3.10 and Fig. 3.2. Instantaneous.

  • coupledcluster.py The class CCD with the amplitude equations of Eq. (3.56) and the class UnitaryCC with the exact and Trotterized exponentials; Tables 3.14–3.16 and Fig. 3.4. About ten seconds on a suitable numerical Python installation.

  • validation.py Independent matrix checks of fermionic signs, CI dimensions, HF derivatives and stability, complex CCD residuals, fragment additivity and the limits of UCC/Trotter claims. Seconds.

  • jw_basics.py The failure of the naive map, the identities of Eqs. (3.67)–(3.70), the string counts of the generic Hamiltonian and of the three mappings quoted in Section The Jordan–Wigner transformation, and the two-qubit Hamiltonian of Eq. (3.71). About five seconds.

  • mapped_models.py The Lipkin model on one qubit per doublet, Eq. (3.73); the pairing model in both encodings, Eqs. (3.75) and (3.79); the Hubbard ring in two orderings; the Heisenberg ring; the bounds of Table 3.17, the measurement settings of Table 3.21 and the tapering of Eq. (3.80). Every spectrum is checked against the exact diagonalizations of Section Four model Hamiltonians. About one second.

  • pauli_circuits.py The Pauli rotation of Eq. (3.81), Trotter steps as circuits, Table 3.19 and the time evolutions of Fig. 3.6, energy estimation from shots and Table 3.22, the single-excitation gate of Eq. (3.83) and the Lipkin product states of Table 3.20, the pair-excitation gate of Fig. 3.7, the unitary coupled-cluster circuit of Eq. (3.90) and Table 3.23, and Fig. 3.8. About five seconds.

  • validation_mapping.py Independent matrix and state checks of the encodings, number sectors, tapering, boundary conditions, basis changes, shot covariances, Pauli circuits and ordered UCC products. A few seconds.

The three mapping programs also print the tables and write the figures of the longer treatment in [QCbook] that are not reproduced in Sections From fermions to qubits and From Pauli sums to circuits and measurements.

Running the programs of this chapter#

Each cell below runs one of the programs listed above as a script and shows the figures it writes to BookFigures/.

import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/fockspace.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
a =
 [[0. 1.]
 [0. 0.]] 
a^dagger a =
 [[0. 0.]
 [0. 1.]]
a_0 =
 [[0. 0. 1. 0.]
 [0. 0. 0. 1.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]] 
a_1 =
 [[ 0.  1.  0.  0.]
 [ 0.  0.  0.  0.]
 [ 0.  0. -0. -1.]
 [ 0.  0. -0. -0.]]
a_0^dag a_1^dag|0> = e_3, a_1^dag a_0^dag|0> = -e_3: verified
anticommutation relations hold as matrix identities for n = 2..5
N = 3 sector of 6 modes: 20 determinants; matrices and bit strings agree
particle number is conserved: True
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/models.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
Lipkin J=2 quasispin matrix:
 [[-4.      0.     -0.8165  0.      0.    ]
 [ 0.     -2.75    0.     -1.      0.    ]
 [-0.8165  0.     -1.      0.     -0.8165]
 [ 0.     -1.      0.      1.25    0.    ]
 [ 0.      0.     -0.8165  0.      4.    ]]
quasispin eigenvalues: [-4.21288 -2.98607 -0.91914  1.48607  4.13201]  lowest from 70x70 FCI: -4.212876697277941
pairing L=4, g=1: seniority-zero eigenvalues [0.63555 2.93538 5.      5.      7.20894 9.22013]  full-space lowest 0.635548473575598
pairing + p-h, g=1, f=0.05: 0.4505823424970814
Hubbard ring, 4 sites, U=4t: E0 = -2.102748483462075 double occupancy 0.28732537269005437
Heisenberg ring, 4 sites: E0 = -2.0 -1.9999999999999996  <S1.S2> = -0.4999999999999999
model checks passed
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/matrixfunctions.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
matrix-function checks passed
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/optimize.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
BFGS reached [1. 1.] in 36 iterations
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/pauli.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
random Hermitian 8x8 matrix: 64 Pauli strings, weights {0: 1, 1: 9, 2: 27, 3: 27}
groups of commuting strings: [['ZZ', 'IZ'], ['XX'], ['YY']]
matrix-free application and commutator bound checked
Pauli-sum checks passed
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'common/jordanwigner.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
Jordan-Wigner a_p^dagger equals the Fock-space matrices of chapter 3 for n = 4
{a_p, a_q^dagger} = delta_pq, {a_p, a_q} = 0 verified symbolically
parity mapping: anticommutators verified
Bravyi-Kitaev mapping: anticommutators verified; |1011> is stored as 1111
Jordan-Wigner checks passed
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/second_quantization.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
determinant |3 6 10 13> as bits: 0001001000100100
  a^dagger_4  -> -1 x |0001101000100100>
  a^dagger_6  -> 0
  a^dagger_12 -> -1 x |0001001000101100>
largest violation of the anticommutation relations, 4 modes: 0.0
<0|a_1 a_0 a^dag_0 a^dag_1|0> = +1  (Wick: +1)
<0|a_1 a_0 a^dag_1 a^dag_0|0> = -1  (Wick: -1)
<0|a_2 a_0 a^dag_0 a^dag_1|0> = +0  (Wick: +0)
M = 2: 1 pairings
M = 4: 3 pairings
M = 6: 15 pairings
M = 8: 105 pairings
<01|H|01> = 4.038893 = h_00 + h_11 + <01|v|01> = 4.038893
<02|H|01> = 2.285222 = h_21 + <02|v|01> = 2.285222
E_ref = 4.038893;  Fock matrix f_pq = h_pq + sum_i <pi|v|qi>:
 [[ 3.5925  0.8635 -1.8839 -0.5393]
 [ 0.8635  3.6933  2.2852  1.7593]
 [-1.8839  2.2852 -3.0004 -1.1373]
 [-0.5393  1.7593 -1.1373  0.1242]]
<Phi_i^a|H|c> = f_ai and <Phi_ij^ab|H|c> = <ab|v|ij>: verified
two-mode Hamiltonian (basis |00>,|01>,|10>,|11>):
 [[0.  0.  0.  0. ]
 [0.  2.  0.3 0. ]
 [0.  0.3 1.  0. ]
 [0.  0.  0.  3.5]]
eigenvalues: [0.     0.9169 2.0831 3.5   ]
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/fci.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== Lipkin model, N = 4, eps = 2 (Table 3.lipkin)
V = -0.3333, W = -0.2500: eigenvalues [-4.21288 -2.98607 -0.91914  1.48607  4.13201]
   ground state weights on |2,-2>,|2,0>,|2,2>: 0.93576 0.06361 0.00063; 70x70 space gives E0 = -4.21288
V = -1.3333, W = -1.0000: eigenvalues [-7.75122 -7.47214 -1.55581  1.47214  5.30704]
   ground state weights on |2,-2>,|2,0>,|2,2>: 0.41303 0.54488 0.04209; 70x70 space gives E0 = -7.75122
   reference weight passes 1/2 at -V = 2.15

=== Pairing model, L = 4, two pairs, xi = 1 (Table 3.pairing)
     g      E_ref     E0 (6x6)   E0 (70x70)       E_corr
 -1.00   3.000000   2.77987014   2.77987014  -0.22012986
 -0.50   2.500000   2.43688426   2.43688426  -0.06311574
  0.00   2.000000   2.00000000   2.00000000   0.00000000
  0.50   1.500000   1.41677428   1.41677428  -0.08322572
  1.00   1.000000   0.63554847   0.63554847  -0.36445153
   L = 4, n = 2: dim 6, E_corr(g=1) = -0.3645, per pair -0.1822
   L = 6, n = 3: dim 20, E_corr(g=1) = -0.6985, per pair -0.2328
   L = 8, n = 4: dim 70, E_corr(g=1) = -1.1108, per pair -0.2777

=== Truncated CI for the pairing model, L = 4, N = 4 (Table 3.citrunc)
    g     E_ref          CIS          CID         CISD          FCI
 0.25  1.750000   1.75000000   1.73050700   1.73050700   1.73045985
 0.50  1.500000   1.50000000   1.41759645   1.41759645   1.41677428
 1.00  1.000000   1.00000000   0.64890655   0.64890655   0.63554847
 2.00  0.000000   0.00000000  -1.35208670  -1.35208670  -1.48965216
   dimensions of the truncated spaces: [1, 17, 53, 69, 70]

=== Size consistency: two non-interacting copies of a two-level system (Table 3.sizecons)
    g         2E(A)           FCI           CID   CID error
 0.25   -0.26556444   -0.26556444   -0.26550480    5.96e-05
 0.50   -0.56155281   -0.56155281   -0.56066017    8.93e-04
 1.00   -1.23606798   -1.23606798   -1.22474487    1.13e-02

=== Half-filled four-site Hubbard ring (Tables 3.hubbard, 3.hubbardstrong)
  U/t          E0/t    E0/(Nt)  double occ      E0/J
    0   -4.00000000  -1.000000    0.815617       nan
    2   -2.82842712  -0.707107    0.453082  -1.41421
    4   -2.10274848  -0.525687    0.287325  -2.10275
    8   -1.32023496  -0.330059    0.129992  -2.64047
   16   -0.72286432  -0.180716    0.042033  -2.89146
   32   -0.37141042  -0.092853    0.011387  -2.97128
   64   -0.18704455  -0.046761    0.002908  -2.99271
  128   -0.09369285  -0.023423    0.000731  -2.99817

=== Antiferromagnetic Heisenberg ring, J = 1 (Table 3.heisenberg)
  N    dim          E0/J      E0/(NJ)  deviation
  4      6   -2.00000000  -0.50000000  -0.056853
  6     20   -2.80277564  -0.46712927  -0.023982
  8     70   -3.65109341  -0.45638668  -0.013239
 10    252   -4.51544635  -0.45154464  -0.008397
 12    924   -5.38739092  -0.44894924  -0.005802
  Bethe ansatz: E0/(NJ) -> 1/4 - ln 2 = -0.44314718
  four-site ring: <S_i.S_i+1> = -0.5000, <S_i.S_i+2> = 0.2500

=== The exponential wall (Table 3.wall)
   n     C(n,n/2)  2^n/sqrt(n)
  10    2.520e+02    3.238e+02
  20    1.848e+05    2.345e+05
  40    1.378e+11    1.738e+11
  80    1.075e+23    1.352e+23
 160    9.205e+46    1.155e+47
  oxygen-16 neutrons, 8 in 40 states: C(40,8) = 7.690e+07; protons and neutrons: 5.914e+15

=== Lanczos iteration for the 14-site Heisenberg ring (Table 3.lanczos)
  dimension 3432, exact E0 = -6.26354953
   m  lowest Ritz value      error
   5        -4.94003212   1.32e+00
  10        -6.13896624   1.25e-01
  20        -6.26335838   1.91e-04
  40        -6.26354953   8.88e-16
  80        -6.26354953  -5.33e-15
figure written to BookFigures/chapter3/models.pdf
../_images/d616e197162b2f1a9f4867f8367a9b978322b1f36b78a9f242fb752d988b276b.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/hartreefock.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== Lipkin model, N = 4, eps = 1, W = 0 (Table 3.lipkinhf)
  chi  E_spherical         E_HF  E_mf formula  lambda_min    E_exact  solution
 0.25    -2.000000    -2.000000     -2.000000      0.7500  -2.020726  spherical
 0.50    -2.000000    -2.000000     -2.000000      0.5000  -2.081666  spherical
 0.90    -2.000000    -2.000000     -2.000000      0.1000  -2.253886  spherical
 1.00    -2.000000    -2.000000     -2.000000      0.0000  -2.309401  critical
 1.50    -2.000000    -2.166667     -2.166666     -0.5000  -2.645751  deformed
 2.00    -2.000000    -2.500000     -2.500000     -1.0000  -3.055050  deformed
 2.50    -2.000000    -2.900000     -2.900000     -1.5000  -3.511885  deformed

=== Pairing model, L = 4, N = 4: the mean field does nothing (Table 3.pairinghf)
    g       E_ref        E_HF     E_exact iterations  max|f_ai|
 0.25  1.75000000  1.75000000  1.73045985          1    0.0e+00
 0.50  1.50000000  1.50000000  1.41677428          1    0.0e+00
 1.00  1.00000000  1.00000000  0.63554847          1    0.0e+00

=== Half-filled Hubbard ring, 4 sites: restricted vs unrestricted mean field (Table 3.hubbardhf)
 U/t     E_para      E_UHF    E_exact  m_stagger
   1  -3.000000  -3.285509  -3.340848     0.2853
   2  -2.000000  -2.661001  -2.828427     0.3279
   4   0.000000  -1.763298  -2.102748     0.4081
   8   4.000000  -0.968871  -1.320235     0.4708

=== Thouless' theorem: the rotated state is a single determinant
  ||exp(T)|c> - prod_i b_i^dagger|0>|| = 6.3e-18, <c|c'> = 1.000000
  ||exp(T)|c> - (1+T)|c>|| = 5.407e-01 (the 2p-2h cross terms)
figure written to BookFigures/chapter3/lipkin_hf.pdf
../_images/a57fcd45b9ce11611b8e4b6b17d49c32607a6344ed8519879a76ba5c7cc153cb.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/trotter.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== BCH expansion, X = [[0,0.1],[0,0]], Y = [[0,0],[0.1,0]] (Table 3.bch)
  order 1: ||e^X e^Y - e^Z_n|| = 7.075e-03
  order 2: ||e^X e^Y - e^Z_n|| = 2.379e-04
  order 3: ||e^X e^Y - e^Z_n|| = 1.179e-05
  order 4: ||e^X e^Y - e^Z_n|| = 4.757e-07

=== Trotter splitting of exp(-i(X+Z)t), t = 1 (Table 3.trotter)
   N  first order  ratio  second order  ratio
   1    7.992e-01    ---     3.137e-01    ---
   2    3.624e-01   2.21     7.113e-02   4.41
   4    1.763e-01   2.06     1.727e-02   4.12
   8    8.751e-02   2.01     4.286e-03   4.03
  16    4.368e-02   2.00     1.070e-03   4.01
  32    2.183e-02   2.00     2.673e-04   4.00
  64    1.091e-02   2.00     6.680e-05   4.00

=== Heisenberg ring, 4 sites, even/odd bond splitting (Fig. 3.trotter)
  n =   1: first order 1.782e+00, second order 1.192e+00
  n =   2: first order 8.911e-01, second order 3.354e-01
  n =   4: first order 4.089e-01, second order 8.097e-02
  n =   8: first order 1.988e-01, second order 1.998e-02
  n =  16: first order 9.868e-02, second order 4.978e-03
  n =  32: first order 4.925e-02, second order 1.243e-03
  n =  64: first order 2.461e-02, second order 3.108e-04
  n = 128: first order 1.230e-02, second order 7.769e-05
  asymptotic slopes: -1.00 (first order), -2.00 (second order)
  ||[H_even, H_odd]|| = 1.7321
figure written to BookFigures/chapter3/trotter.pdf
../_images/c4c0739be5d31b8d3e787974ba2a36b78f166c9905a7f433f539f86f961fc7c1.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/coupledcluster.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== CCD for the pairing model, L = 4, two pairs (Table 3.ccd)
    g    E_ref          MP2          CCD          FCI  CCD error  iter
 0.25  1.75000   1.73320261   1.73045621   1.73045985   -3.6e-06    13
 0.50  1.50000   1.43760684   1.41663766   1.41677428   -1.4e-04    18
 1.00  1.00000   0.78095238   0.63044275   0.63554847   -5.1e-03    26
 1.50  0.50000   0.05974026  -0.38416526  -0.34819051   -3.6e-02    30
 2.00  0.00000  -0.70833333  -1.60959440  -1.48965216   -1.2e-01    31

=== Unitary coupled cluster, g = 1: generator comparison from zero amplitudes
  pairs            :   4 amplitudes, E(UCC) = 0.6369869810 (11 BFGS iterations)
  doubles          :  36 amplitudes, E(UCC) = 0.6369869810 (20 BFGS iterations)
  singles+doubles  :  52 amplitudes, E(UCC) = 0.6369869810 (20 BFGS iterations)

=== UCCD against CCD and FCI (Table 3.uccd)
    g          CCD         UCCD          FCI  CCD error  UCCD error
 0.25   1.73045621   1.73046012   1.73045985   -3.6e-06     2.8e-07
 0.50   1.41663766   1.41679562   1.41677428   -1.4e-04     2.1e-05
 1.00   0.63044275   0.63698698   0.63554847   -5.1e-03     1.4e-03
 1.50  -0.38416526  -0.33675149  -0.34819051   -3.6e-02     1.1e-02
 2.00  -1.60959440  -1.45347633  -1.48965216   -1.2e-01     3.6e-02

=== Trotterised UCCD, g = 1: re-optimised amplitudes at each n
  exact exponential: E = 0.6369869810, error 1.44e-03
  n = 1: E = 0.6369869810, error 1.44e-03
  n = 2: E = 0.6369869810, error 1.44e-03
  n = 4: E = 0.6369869810, error 1.44e-03
  n = 8: E = 0.6369869810, error 1.44e-03

=== Trotterised UCCD with the amplitudes frozen (Table 3.ucctrotter)
   n ||psi_n - psi||  ratio  energy error  ratio
   1        3.56e-03    ---      6.78e-05    ---
   2        1.14e-03   3.13      6.38e-06  10.63
   4        4.56e-04   2.50      9.37e-07   6.81
   8        2.11e-04   2.16      1.93e-07   4.85
  16        1.03e-04   2.04      4.57e-08   4.23
  32        5.14e-05   2.01      1.13e-08   4.06
  64        2.57e-05   2.00      2.81e-09   4.01
figure written to BookFigures/chapter3/coupled_cluster.pdf
../_images/8c7139af03bd2930c1dbe464ed841d61ac8202a547d8fca8c8a4ec3992f5eb3b.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/validation.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
Signs, complex sector matrices, Lipkin, CI dimensions, Lanczos and superexchange: passed
HF complex functional, Thouless state, orbital Hessian and convergence checks: passed
Complex CCD tensor equations vs exp(-T)Hexp(T), BCH termination and fragment additivity: passed
UCC complex unitarity and stationary-manifold O(1/n) Trotter-energy counterexample: passed
All independent Chapter 3 validations passed.
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/jw_basics.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== Naive map a_p -> sigma^-_p (no parity string), Eq. (3.naive)
  {sigma^-_0, sigma^-_1} = {'XX': 0.5, 'XY': 0.5j, 'YX': 0.5j, 'YY': -0.5}
  spectral norm 2.0 instead of 0
  with the parity string, {a_0, a_1} = 0

=== Jordan-Wigner images on four qubits, Eqs. (3.jwnumber)-(3.jwtwobody)
a_2^dagger      : {'ZZXI': 0.5, 'ZZYI': -0.5j}
n_2             : {'IIII': 0.5, 'IIZI': -0.5}
a_0^+ a_3 + h.c.: {'YZZY': 0.5, 'XZZX': 0.5}
a_0^+ a_3^+ + h.c.: {'YZZY': -0.5, 'XZZX': 0.5}
a_0^+ a_1^+ a_3 a_2 + h.c.:
+0.1250 XXXX
-0.1250 XXYY
+0.1250 XYXY
+0.1250 XYYX
+0.1250 YXXY
+0.1250 YXYX
-0.1250 YYXX
+0.1250 YYYY

=== Generic real one- plus two-body Hamiltonian on M orbitals (Table 3.paulicount)
  M    4^M  strings  max weight
  2     16        6           2
  3     64       19           3
  4    256       55           4
  5   1024      136           5
  6   4096      292           6

=== Two-qubit Hamiltonian of Exercise 3.twoqubit
+1.6250 II
-1.1250 IZ
-0.6250 ZI
+0.1500 XX
+0.1500 YY
+0.1250 ZZ
matrix in the basis |00>,|01>,|10>,|11>:
 [[0.  0.  0.  0. ]
 [0.  2.  0.3 0. ]
 [0.  0.3 1.  0. ]
 [0.  0.  0.  3.5]]
one-particle block eigenvalues [0.916905 2.083095], formula 0.9169, 2.0831

=== Jordan-Wigner, parity and Bravyi-Kitaev mappings (Table 3.mappings)
  M        mapping              weights of a+_p, p = 0..M-1
  4  Jordan-Wigner                             [1, 2, 3, 4]
  4         parity                             [4, 4, 3, 2]
  4  Bravyi-Kitaev                             [3, 3, 3, 3]
  8  Jordan-Wigner                 [1, 2, 3, 4, 5, 6, 7, 8]
  8         parity                 [8, 8, 7, 6, 5, 4, 3, 2]
  8  Bravyi-Kitaev                 [4, 4, 4, 4, 4, 4, 4, 4]
  structured Hamiltonians on eight qubits (strings, largest weight):
   Jordan-Wigner: pairing L=4 (61, 4), Hubbard ring (29, 4)
          parity: pairing L=4 (61, 6), Hubbard ring (29, 5)
   Bravyi-Kitaev: pairing L=4 (61, 6), Hubbard ring (29, 5)

=== A bosonic mode truncated to d levels in binary encoding (Table 3.boson)
  d  qubits  strings in b  strings in n  strings in x
  2       1             2             2             1
  4       2             8             3             4
  8       3            24             4            12
 16       4            64             5            32
  d = 4: position operator x = (b + b^dagger)/sqrt(2) =
+0.9659 IX
+0.5000 XX
+0.5000 YY
-0.2588 ZX

=== Pairing Hamiltonian, g = 1, full encoding: Pauli weights (Fig. 3.pauliweights)
  L = 1 (2 qubits): 4 strings, weights {0: 1, 1: 2, 2: 1}, formula 4L(L-1)+3L+1 = 4
  L = 2 (4 qubits): 15 strings, weights {0: 1, 1: 4, 2: 2, 4: 8}, formula 4L(L-1)+3L+1 = 15
  L = 3 (6 qubits): 34 strings, weights {0: 1, 1: 6, 2: 3, 4: 24}, formula 4L(L-1)+3L+1 = 34
figure written to BookFigures/chapter3/pauliweights.pdf
../_images/6286e62ce700a097c14df532b2b73c1fc19ec86caa95a6a7f958df922bfe5cf2.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/mapped_models.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== Lipkin model, N = Omega = 4, eps = 2, V = -1/3, W = -1/4 (Table 3.lipkinencodings)
              encoding  qubits  strings  max weight         E0
  one per spin-orbital       8       61           4   -4.21288
       one per doublet       4       16           2   -4.21288
       one-hot |J,J_z>       5       12           2   -4.21288
   binary, J = 2 block       3       16           3   -4.21288
level encoding, Pauli form:
-1.0000 IIIZ
-1.0000 IIZI
-1.0000 IZII
-1.0000 ZIII
-0.2917 IIXX
+0.0417 IIYY
-0.2917 IXIX
-0.2917 IXXI
+0.0417 IYIY
+0.0417 IYYI
-0.2917 XIIX
-0.2917 XIXI
-0.2917 XXII
+0.0417 YIIY
+0.0417 YIYI
+0.0417 YYII

=== Pairing model, L = 2, xi = 1, g = 1, one qubit per spin-orbital (Eq. 3.jwpairingfull)
+0.7500 IIII
-0.3750 IIIZ
-0.3750 IIZI
+0.1250 IZII
+0.1250 ZIII
-0.1250 IIZZ
-0.1250 ZZII
-0.0625 XXXX
+0.0625 XXYY
-0.0625 XYXY
-0.0625 XYYX
-0.0625 YXXY
-0.0625 YXYX
+0.0625 YYXX
-0.0625 YYYY

=== Pairing model, one qubit per level (Eq. 3.jwpairingtwolevels)
+0.5000 II
-0.7500 IZ
+0.2500 ZI
-0.2500 XX
-0.2500 YY
  L = 2: compact spectrum = seniority-zero spectrum for every pair number (dimensions [1, 2, 1]), and a subset of the full one
  L = 3: compact spectrum = seniority-zero spectrum for every pair number (dimensions [1, 3, 3, 1]), and a subset of the full one

=== The cost of the pairing model (Table 3.paulicounts)
           Hamiltonian         encoding  qubits  strings  max weight
        pairing, L = 2    one per level       2        5           2
        pairing, L = 2  one per orbital       4       15           4
  pairing + p-h, L = 2  one per orbital       4       27           4
        pairing, L = 3    one per level       3       10           2
        pairing, L = 3  one per orbital       6       34           4
  pairing + p-h, L = 3  one per orbital       6      118           6
  string counts 4L(L-1)+3L+1 (full) and L^2+1 (compact) verified up to L = 6

=== Half-filled Hubbard ring, 4 sites, U = 4t, eight qubits (Table 3.hubbardjw)
                    ordering  strings  max weight  hopping strings by weight
site-major (i up, i down, ...)       29           7              {3: 12, 7: 4}
spin-major (all up, all down)       29           4              {2: 12, 4: 4}
  ground-state energy from the qubit Hamiltonian -2.10274848 (chapter 3: -2.10274848)

=== Heisenberg ring, 4 sites: already a Pauli sum
+0.2500 IIXX
+0.2500 IIYY
+0.2500 IIZZ
+0.2500 IXXI
+0.2500 IYYI
+0.2500 IZZI
+0.2500 XIIX
+0.2500 XXII
+0.2500 YIIY
+0.2500 YYII
+0.2500 ZIIZ
+0.2500 ZZII
fermionic form: the open bonds give the same Pauli strings; the closing bond (3,0) carries a parity string:
{'IZZI': 0.25, 'XZZX': 0.25, 'YZZY': 0.25}
  lowest eigenvalues with two fermions: [-1.61803 -1.61803 -0.     ] -- not the spin ring's -2:
  the parity string twists the boundary condition (Sec. 3.4); the spin form is the one to use
  corrected antiperiodic boundary: the complete two-particle spectrum matches the spin ring

=== Symmetries as vanishing commutators of Pauli sums (Table 3.symmetries)
    Hubbard ring: [H, N] = 0; [H, S^z] = 0; [H, parity] = 0
     pairing L=4: [H, N] = 0; [H, parity] = 0; [H, seniority] = 0
   pairing + p-h: [H, N] = 0; [H, parity] = 0; [H, seniority] = 432 strings, norm bound 18.000

=== Matrix-free Lanczos on the eight-qubit Hubbard Hamiltonian
  30 Lanczos steps with H.apply: E0 = -2.10274848 (exact -2.10274848), 0.02 s, 29 strings x 2^8 amplitudes per product

=== Norms and commutator bounds of the Pauli sums (Table 3.bounds)
                       Hamiltonian   sum|h|    ||H||  commutator bound
           Lipkin, one per doublet    6.000    4.213             8.583
        pairing L=4, one per level   13.500   10.672            19.500
      pairing L=4, one per orbital   14.500   10.672            19.500
          Hubbard ring, spin-major   24.000   16.000            72.000
                   Heisenberg ring    3.000    2.000             3.000

=== Measurement settings: groups of qubit-wise commuting strings (Table 3.settings)
                       Hamiltonian  qubits  strings  settings
           Lipkin, one per doublet       4       16         3
        pairing L=4, one per level       4       17         3
      pairing L=4, one per orbital       8       61        17
          Hubbard ring, spin-major       8       29         5
                   Heisenberg ring       4       12         3
  Heisenberg groups: [['IIXX', 'IXXI', 'XIIX', 'XXII'], ['IIYY', 'IYYI', 'YIIY', 'YYII'], ['IIZZ', 'IZZI', 'ZIIZ', 'ZZII']]

=== Tapering a Z2 symmetry: the two-level pairing model on one qubit (Eq. 3.tapered)
  after CNOT_01: {'II': 0.5, 'XI': -0.25, 'XZ': 0.25, 'ZI': 0.25, 'ZZ': -0.75}
  one-qubit Hamiltonian: {'I': 0.5, 'X': -0.5, 'Z': 1.0}
  eigenvalues [-0.61803  1.61803] = seniority-zero spectrum with one pair
figure written to BookFigures/chapter3/encodings.pdf
../_images/74ee6cf67752a7f6f20166d5439ab5c0065de786d3475ec61aa158b3eeb6c2f4.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/pauli_circuits.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
=== Circuits for exp(-i theta P) (Fig. 3.gadget)
  ZZ: 3 gates, 2 CNOTs, depth 3
  XX: 7 gates, 2 CNOTs, depth 5
  YY: 11 gates, 2 CNOTs, depth 7
  XZZY: 13 gates, 6 CNOTs, depth 9
  XYXY: 19 gates, 6 CNOTs, depth 11
q0: |0>--[S^]-[H]-----------*--------*----------[H]-[S]--
q1: |0>-----------[S^]-[H]-(+)-[Rz]-(+)-[H]-[S]----------

=== One Trotter step as a circuit (Table 3.trottergates)
               Hamiltonian  strings  gates  CNOTs  depth
pairing L=2, one per level        5     20      4     14
  Heisenberg ring, 4 sites       12     84     24     55
pairing model, L = 2, one qubit per level, one first-order step:
q0: |0>--[Rz]-[H]------*--------*------[H]-[S^]-[H]-----------*--------*----------[H]-[S]-------
q1: |0>-----------[H]-(+)-[Rz]-(+)-[H]--------------[S^]-[H]-(+)-[Rz]-(+)-[H]-[S]---------[Rz]--

  splitting error of n steps for the pairing Hamiltonian, t = 1:
   n  first order  second order
   1    2.426e-01     5.587e-02
   2    1.056e-01     1.242e-02
   4    5.089e-02     3.018e-03
   8    2.521e-02     7.491e-04
  16    1.258e-02     1.869e-04

=== Trotter circuit dynamics: pair transfer in the two-level model (Fig. 3.dynamics)
  dt = 0.5, order 1: 16 steps, 64 CNOTs, largest error in P(t) = 2.883e-02
  dt = 0.5, order 2: 16 steps, 128 CNOTs, largest error in P(t) = 1.195e-02
  dt = 0.1, order 1: 80 steps, 320 CNOTs, largest error in P(t) = 1.086e-03
  exact: P(t) oscillates with period 2.8099 = 2 pi / sqrt(5)
  Heisenberg ring, 4 sites, from the Neel state |0101>: staggered magnetisation
  second order, dt = 0.25: 46 CNOTs per step, largest error 1.92e-03

=== Energy from shots, pairing L = 2, one pair (Table 3.shots)
  qubit-wise commuting groups of the 5 strings: [['XX', 'II'], ['YY'], ['ZI', 'IZ']]
 shots/group  one estimate  rms error (20 runs)  rms x sqrt(shots)
         100      -0.63000             6.52e-02              0.652
        1000      -0.61500             1.64e-02              0.520
       10000      -0.60780             5.54e-03              0.554
      100000      -0.61936             1.72e-03              0.543
  exact energy -0.61803399; 3 measurement settings; the error falls as 1/sqrt(shots)

=== Variances of the strings and the shots needed for 1e-3 (Table 3.variances)
  two-pair sector: E0 = 0.63554847
  string        h      <P>    Var P
    IIII   5.0000   1.0000   0.0000
    IIIZ  -2.7500   0.9291   0.1367
    ZIII   0.2500  -0.9291   0.1367
    XXII  -0.2500   0.1142   0.9869
    YYII  -0.2500   0.1142   0.9869
    XIIX  -0.2500   0.2093   0.9562
  17 strings; optimal allocation S_a ~ |h_a| sigma_a: total shots 2.99e+07; naive bound (sum|h|)^2/eps^2 = 7.22e+07
  group ['XXII', 'XIXI', 'XIIX', 'IXXI', 'IXIX', 'IIXX', 'IIII']: mean = 4.61289109, variance = 0.67877752
  group ['YYII', 'YIYI', 'YIIY', 'IYYI', 'IYIY', 'IIYY']: mean = -0.38710891, variance = 0.67877752
  group ['ZIII', 'IZII', 'IIZI', 'IIIZ']: mean = -3.59023371, variance = 1.35219637
  grouped optimal shots: 7.8995e+06; equal shots per group: 8.1293e+06
  L=2 equal shots per group: exact RMS = 0.54772256/sqrt(S); for RMS 1e-3: S = 300000 per group

=== The pair-excitation circuit exp(theta (S+_1 S-_0 - h.c.)) (Fig. 3.pairgadget)
  generator S+_1 S-_0 - h.c. = {'YX': 0.5j, 'XY': -0.5j}
q0: |0>--[S^]-[H]------*--------*------[H]-[S]-[H]-----------*--------*----------[H]--
q1: |0>-----------[H]-(+)-[Rz]-(+)-[H]-------------[S^]-[H]-(+)-[Rz]-(+)-[H]-[S]------
  E(theta) minimal at theta = 0.227: -0.617980; exact -0.618034; E(theta) = -0.500 cos^2 + 1.500 sin^2 + -0.500 sin 2theta

=== The single-excitation gate exp(theta (a+_q a_p - h.c.)) (Fig. 3.singlegadget)
  modes 0,1: generator {'YXII': 0.5j, 'XYII': -0.5j}, 4 CNOTs
  modes 0,3: generator {'YZZX': 0.5j, 'XZZY': -0.5j}, 12 CNOTs
  two-mode Hamiltonian: E(theta) minimal at theta = -0.2702, E = 0.916905 (exact one-particle ground state 0.916905)

=== Lipkin mean field as a product state on four qubits (Table 3.lipkinmf)
  chi    alpha  E(product state)  E_HF (chapter 3)    E_exact
 0.50   0.0000         -2.000000         -2.000000  -2.081666
 1.00   0.0000         -2.000000         -2.000000  -2.309401
 1.50   0.8411         -2.166667         -2.166667  -2.645751
 2.00   1.0472         -2.500000         -2.500000  -3.055050
 2.50   1.1593         -2.900000         -2.900000  -3.511885

=== Trotterised UCC circuit for the pairing model, L = 4, two pairs (Table 3.uccd)
    g     E_ref  circuit UCCD   chapter 3          FCI  CNOTs
 0.25    1.7500    1.73046012  1.73046012   1.73045985     16
 0.50    1.5000    1.41679562  1.41679562   1.41677428     16
 1.00    1.0000    0.63698698  0.63698698   0.63554847     16
 1.50    0.5000   -0.33675149 -0.33675149  -0.34819051     16
 2.00    0.0000   -1.45347633 -1.45347633  -1.48965216     16
  ordered four-gate ansatz: the tabulated energies agree after reoptimization; this is not a general UCC equivalence;
  74 gates, 16 CNOTs, depth 38, four parameters
figure written to BookFigures/chapter3/dynamics.pdf
figure written to BookFigures/chapter3/circuits.pdf
../_images/622acf037876945ff0872042ce56b1ed8607465afae79ee3e1ba2e2299e0f7eb.png ../_images/e7cb87e3c84eb2c3c55447807f4d200963a42a3deed21ddfb64ced5014112c44.png
import runpy, time
from IPython.display import Image, display
t0 = time.time()
runpy.run_path(str(root / 'BookPrograms' / 'chapter3/validation_mapping.py'), run_name='__main__')
for png in sorted((root / 'BookFigures' / 'chapter3').glob('*.png')):
    if png.stat().st_mtime >= t0:
        display(Image(str(png)))
Complex Pauli algebra, matrix-free expectations and dimension guards passed.
JW, parity and BK transformations, complex integrals and nonlocal quartic weights passed.
Complex one-hot/binary isometries, pairing sectors and truncated-boson algebra passed.
Tapered basis, ground-state angle branch and parity-versus-number distinction passed.
Spin/fermion ring boundary identity passed in every number sector for 3-5 sites.
Pauli gadgets, Y measurement, omitted identity phase and input guards passed.
Exact bit-string covariance sums and the 0.30/S two-level energy variance passed.
UCC circuit equals the stated ordered product; reversing the order changes its state.
All Chapter 3 independent validation checks passed.