Jordan-Wigner Mapping: Why Fermions Need a String of Z Gates

Jordan-Wigner Mapping: Why Fermions Need a String of Z Gates

The Jordan-Wigner transform encodes fermionic modes as qubits. A short two-mode NumPy example shows how the Z parity string enforces anticommutation.

Quantum chemistry and many materials models are written using fermionic creation and annihilation operators. To run those models on a qubit computer, we need to represent the fermionic operators with matrices built from qubit gates. The Jordan-Wigner mapping does this by assigning one qubit to each fermionic mode and adding a string of Z operators to keep track of parity.

Why the Z string matters

Fermionic operators on different modes anticommute. Ordinary qubit operators acting on separate wires commute, so a direct one-mode-per-qubit replacement would lose an important minus sign.

For mode j, the Jordan-Wigner annihilation operator is:

a_j = (Z_0 Z_1 ... Z_{j-1})(X_j + iY_j)/2

The creation operator uses the minus sign instead of the plus sign. If j = 0, the Z product is empty. For any later mode, the earlier Z operators contribute a factor of -1 whenever an odd number of earlier modes are occupied. That parity sign is what reproduces fermionic anticommutation. OpenFermion's Jordan-Wigner tutorial derives this action on occupation states.

Check two modes in NumPy

With two modes, the first mode needs no parity string and the second needs Z on mode 0. The snippet below builds those 4 by 4 matrices and checks the anticommutation relations. It also compares the second operator with a naive mapping that omits Z:

import numpy as np

I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
lower = (X + 1j * Y) / 2

# Basis order is |n0 n1>; mode 0 is the left Kronecker factor.
a0 = np.kron(lower, I)
a1 = np.kron(Z, lower)
naive_a1 = np.kron(I, lower)
zero = np.zeros((4, 4), dtype=complex)
eye4 = np.eye(4, dtype=complex)

print(np.allclose(a0 @ a1 + a1 @ a0, zero))
print(np.allclose(a0 @ a1.conj().T + a1.conj().T @ a0, zero))
print(np.allclose(a0 @ a0.conj().T + a0.conj().T @ a0, eye4))
print(np.allclose(a0 @ naive_a1 + naive_a1 @ a0, zero))

The output is True, True, True, False. The last line shows why the parity string is not decoration: without it, the two mode operators fail the fermionic relation.

A useful trade-off

For a later mode, the Jordan-Wigner operator includes Z factors on every earlier mode. This gives a clear occupation-number encoding, but an operator near the end of a long register can become a long Pauli string. Other mappings, including Bravyi-Kitaev, store parity information differently and can shorten some of these strings. The right choice depends on the model and hardware. The Qiskit Nature mapper guide compares Jordan-Wigner with other fermion-to-qubit mappings.