|q⟩ Bad Qubits

advanced · Programming · Quantum Chemistry on Quantum Computers

Molecular Hamiltonians as Paulis

We can finally assemble the object a quantum computer actually consumes: a qubit Hamiltonian, a weighted sum of Pauli strings. We build it for the simplest interesting molecule, molecular hydrogen H2\text{H}_2, in the minimal STO-3G basis.

From integrals to Pauli strings

The recipe chains together everything from this module:

  1. Pick a geometry and basis set; a classical package computes the molecular integrals hpqh_{pq} and hpqrsh_{pqrs}.
  2. Assemble the second-quantized Hamiltonian pqhpqapaq+12pqrshpqrsapaqaras\sum_{pq} h_{pq} a_p^\dagger a_q + \tfrac12 \sum_{pqrs} h_{pqrs} a_p^\dagger a_q^\dagger a_r a_s.
  3. Apply Jordan–Wigner (or Bravyi–Kitaev): each apa_p^\dagger, apa_p becomes a Pauli operator, and products of them expand into Pauli strings.
  4. Collect like terms. The result is
H^=kckPk,Pk{I,X,Y,Z}n.\hat{H} = \sum_k c_k\, P_k, \qquad P_k \in \{I, X, Y, Z\}^{\otimes n}.

For H2\text{H}_2 in STO-3G there are 4 spin-orbitals, so the raw Jordan–Wigner Hamiltonian acts on 4 qubits and has 15 Pauli terms.

Reducing to two qubits

The 4-qubit Hamiltonian has symmetries — conservation of total electron number and of spin — that let us taper away two qubits. After this reduction the equilibrium H2\text{H}_2 Hamiltonian collapses to a compact two-qubit operator (coefficients in Hartree, after O'Malley et al. 2016):

H^=g0I+g1Z0+g2Z1+g3Z0Z1+g4Y0Y1+g5X0X1.\hat{H} = g_0\, I + g_1\, Z_0 + g_2\, Z_1 + g_3\, Z_0 Z_1 + g_4\, Y_0 Y_1 + g_5\, X_0 X_1.

The diagonal ZZ terms set the energies of the basis states; the off-diagonal X0X1X_0 X_1 and Y0Y1Y_0 Y_1 terms mix 01|01\rangle and 10|10\rangle, which is what lets the true ground state be a superposition rather than a single Hartree–Fock configuration.

Reading off basis-state energies

For any computational basis state the off-diagonal terms vanish, and each ZZ contributes its eigenvalue: +1+1 when the qubit is 0|0\rangle, 1-1 when it is 1|1\rangle. So the diagonal energy of a basis state q0q1|q_0 q_1\rangle is

Ediag=g0+g1(1)q0+g2(1)q1+g3(1)q0+q1.E_{\text{diag}} = g_0 + g_1 (-1)^{q_0} + g_2 (-1)^{q_1} + g_3 (-1)^{q_0 + q_1}.

The Hartree–Fock state for H2\text{H}_2 in this encoding is 01|01\rangle (one electron pair in the bonding orbital). Its diagonal energy is the Hartree–Fock energy — a good starting estimate, but above the true ground state because it ignores the mixing from X0X1X_0 X_1 and Y0Y1Y_0 Y_1.

Try it

Using the two-qubit H2\text{H}_2 Hamiltonian above, compute the energy of the Hartree–Fock state 01|01\rangle. Only the diagonal II, Z0Z_0, Z1Z_1, Z0Z1Z_0 Z_1 terms contribute; the X0X1X_0 X_1 and Y0Y1Y_0 Y_1 terms have zero diagonal matrix element. Return the energy as a number.

Run your code to see the quantum state.

This Hartree–Fock energy is the baseline that VQE will lower toward the true ground state.

Sign in on the full site to ask questions and join the discussion.