Abstract
We present a quantum circuit that prepares an arbitrary $U(1)$-invariant
state on a quantum computer, including the exact eigenstates of the spin-1/2
XXZ quantum spin chain with either open or closed boundary conditions. The
algorithm is deterministic, does not require ancillary qubits, and does not
require QR decompositions. The circuit prepares such an $L$-qubit state with
$M$ down-spins using $\binom{L}{M}-1$ multi-controlled rotation gates and
$2M(L-M)$ CNOT-gates.