VQE Suite / Physics
Hamiltonian & Ansatz
The H2 Hamiltonian used by the live VQE Suite playground, and a from-scratch derivation of why its single-parameter ansatz circuit is exact — not just a convenient guess.
The H2 electronic Hamiltonian
In second quantization, a molecule's electronic Hamiltonian in a finite orbital basis is
where the one- and two-electron integrals and come from the molecular orbitals, and the Jordan-Wigner transform maps each fermionic operator to a string of Pauli operators (each becomes a weighted Pauli string acting on qubit and a -string over all lower-indexed qubits, so that the fermionic anticommutation relations survive the mapping onto qubits).
For H2 in a minimal (STO-3G) basis, applying Jordan-Wigner to the 4 spin-orbitals and then a symmetry (parity) reduction — using that the ground state has fixed particle number and — collapses the problem onto 2 qubits. This site uses the reduced 2-qubit Hamiltonian exactly as published, rather than re-deriving the parity-tapering step:
1 export const H2_COEFFICIENTS = { 2 g0: -0.4804, g1: 0.3435, g2: -0.4347, 3 g3: 0.5716, g4: 0.091, g5: 0.091, 4 }; 5 6 export function h2PauliSum(): PauliSum { 7 const { g0, g1, g2, g3, g4, g5 } = H2_COEFFICIENTS; 8 return [ 9 { coefficient: g0, paulis: ["I", "I"] }, 10 { coefficient: g1, paulis: ["I", "Z"] }, 11 { coefficient: g2, paulis: ["Z", "I"] }, 12 { coefficient: g3, paulis: ["Z", "Z"] }, 13 { coefficient: g4, paulis: ["Y", "Y"] }, 14 { coefficient: g5, paulis: ["X", "X"] }, 15 ]; 16 }
Nuclear repulsion is added as a classical constant, computed live rather than folded into a lookup table:
with and Å (CODATA Bohr radius). At Å this gives Hartree — see nuclearRepulsion() in src/lib/physics/h2Hamiltonian.ts.
Why the ground state lives in a 2-dimensional subspace
Write basis states as . , , , and are all diagonal in this basis, so they never mix different computational-basis states. and each flip both qubits at once, so they only connect and — the Hamiltonian splits into two independent 2×2 blocks and never mixes them.
Evaluating both diagonals: and — both non-negative, so that block cannot contain the ground state. The other block, in the basis, is
with closed-form eigenvalues (see eigen2x2Symmetric() in src/lib/physics/linalg.ts, used directly — not a general iterative solver, since a 2×2 symmetric matrix has an exact quadratic-formula solution):
which gives a minimum electronic eigenvalue Hartree. Adding nuclear repulsion, Hartree — matching the well-known H2/STO-3G full-CI benchmark of Hartree to within the expected residual from the R = 0.75 Å vs. 0.735 Å bond-length difference between the source data and the textbook value.
The ansatz circuit
Since only the subspace matters, a single real parameter is enough to reach the exact ground state — no expressibility is wasted on states the Hamiltonian can never select. The ansatz is Hartree-Fock state preparation followed by a controlled rotation:
1 export function h2AnsatzGates(): AnsatzGate[] { 2 return [ 3 { kind: "X", qubit: 0 }, 4 { kind: "CNOT", control: 1, target: 0 }, 5 { kind: "RY", qubit: 1, parameterized: true }, 6 { kind: "CNOT", control: 1, target: 0 }, 7 ]; 8 }
Tracing the circuit by hand: takes to . The first is a no-op (control qubit is ). on gives . The second CNOT now fires on the second term (control ), flipping there and landing exactly on the coupled subspace:
Optimization uses the exact parameter-shift rule for this single generator (no finite-difference approximation):
Running this in the browser (runVqe() in src/lib/physics/vqe.ts) converges to , Hartree — matching the exact diagonalization above to machine precision, confirmed against exactGroundStateEnergy() at build-verification time. See it run live on the VQE Suite playground.
Source: src/lib/physics/h2Hamiltonian.ts, h2Ansatz.ts, vqe.ts, linalg.ts