|q⟩ Bad Qubits

advanced · Programming · Quantum Chemistry on Quantum Computers

The Jordan–Wigner Transform

Second quantization gave us a Hamiltonian written in creation and annihilation operators. To run it on a quantum computer we need those fermionic operators expressed as Pauli operators on qubits. The Jordan–Wigner (JW) transform is the original and most direct fermion-to-qubit mapping.

The occupation-to-qubit dictionary

JW makes the simplest possible identification: spin-orbital pp is represented by qubit pp, and the occupation number becomes the qubit's computational-basis label,

∣n0 n1 ⋯nn−1⟩fermion  ⟷  ∣n0⟩⊗∣n1⟩⊗⋯⊗∣nn−1⟩qubit.|n_0\, n_1\, \cdots n_{n-1}\rangle_{\text{fermion}} \;\longleftrightarrow\; |n_0\rangle \otimes |n_1\rangle \otimes \cdots \otimes |n_{n-1}\rangle_{\text{qubit}}.

An empty orbital is ∣0⟩|0\rangle, an occupied orbital is ∣1⟩|1\rangle. The number operator becomes n^p=ap†ap↦12(I−Zp)\hat{n}_p = a_p^\dagger a_p \mapsto \tfrac{1}{2}(I - Z_p), which reads off the qubit: it returns 00 for ∣0⟩|0\rangle and 11 for ∣1⟩|1\rangle.

Encoding the fermionic phase

The hard part is the antisymmetry sign (−1)σp(-1)^{\sigma_p}, where σp\sigma_p counts occupied orbitals before pp. A bare qubit flip on site pp cannot know about the occupation of qubits 0,…,p−10,\dots,p-1. JW supplies that knowledge with a parity string of ZZ operators:

ap=(∏q<pZq)Xp+iYp2,ap†=(∏q<pZq)Xp−iYp2.a_p = \left(\prod_{q<p} Z_q\right) \frac{X_p + i Y_p}{2}, \qquad a_p^\dagger = \left(\prod_{q<p} Z_q\right) \frac{X_p - i Y_p}{2}.

The local operator 12(Xp∓iYp)\tfrac{1}{2}(X_p \mp i Y_p) raises or lowers qubit pp, while the leading Z0Z1⋯Zp−1Z_0 Z_1 \cdots Z_{p-1} multiplies in exactly the ±1\pm 1 phase demanded by the anticommutation relations. You can verify that with these definitions {ap,aq†}=δpq\{a_p, a_q^\dagger\} = \delta_{pq} holds.

A worked single term

Consider the one-body hopping term a1†a0+a0†a1a_1^\dagger a_0 + a_0^\dagger a_1 on two qubits. Substituting the JW definitions and simplifying (the Z0Z_0 strings on the two adjacent sites combine) gives the clean two-qubit Pauli form

a1†a0+a0†a1=12(X0X1+Y0Y1).a_1^\dagger a_0 + a_0^\dagger a_1 = \tfrac{1}{2}\left(X_0 X_1 + Y_0 Y_1\right).

This is the standard "XY" hopping interaction. Every term of a molecular Hamiltonian reduces, after JW, to a weighted sum of Pauli strings like this one — which is precisely the input VQE needs.

Preparing occupation states is easy

Because occupation maps directly to qubit values, preparing a specific occupation string costs only XX gates: flip qubit pp to ∣1⟩|1\rangle for each occupied orbital pp. The parity-string signs do not change which basis state results when you build it from the vacuum in increasing-index order; they only matter when operators act within the Hamiltonian. This is exactly how the Hartree–Fock reference state (lesson 6) is prepared.

Try it

On 4 spin-orbitals (qubits 0–3), prepare the occupation state with orbitals 0 and 2 filled, i.e. apply a2†a0†a_2^\dagger a_0^\dagger to the vacuum. Under Jordan–Wigner this is just the computational basis state with qubits 0 and 2 set to ∣1⟩|1\rangle. The grader checks the full statevector.

Run your code to see the quantum state.

After running, the statevector panel should show a single non-zero amplitude at the basis state 1010-pattern (qubits 0 and 2 high), confirming the JW occupation encoding.

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