Drag to orbit.

Variational Quantum Eigensolver: Energy of the H2 Molecule on 2 Qubits

A real quantum-chemistry algorithm on a toy molecule: tune one circuit angle, measure, descend to the ground state.
Energy estimate (shots)-
Exact energy of this state-
Exact ground state (diagonalisation)-
Hartree-Fock reference (theta = 0)-
Correlation energy recovered-
Error vs exact ground state-
Optimizer iteration-
Circuit runs used-
VQE energy estimate (orange) per iteration vs exact ground state (green) and Hartree-Fock (grey), Hartree
Exact energy landscape E(theta): the minimum is the variational ground state
The science
Honest scope: this sim shows what a quantum computer is actually used for in chemistry research: estimating the energy of a small molecule with the variational quantum eigensolver (VQE). It does not model, and there is no evidence for, any "quantum healing" of the body. H2 is a textbook toy; it is easily solved on a laptop. The interest in VQE is for larger molecules in drug and materials research, and it is still experimental.

The molecule. H2 at a bond length of 0.735 angstrom in the minimal STO-3G basis has four spin-orbitals. With the parity mapping and two-qubit reduction, the electronic Hamiltonian becomes a sum of Pauli strings (coefficients in Hartree, as published in the Qiskit chemistry tutorials; spot-check them against your own integrals):

H = -1.05237 II - 0.39794 ZI + 0.39794 IZ - 0.01128 ZZ + 0.18093 XX E_total = E_electronic + E_nuclear , E_nuclear = 0.71997 Ha

The ansatz. |psi(theta)> = cos(theta)|01> + sin(theta)|10>. theta = 0 is the Hartree-Fock state, other angles mix in the second configuration (electron correlation). It conserves the electron number, so it contains the exact ground state.

Measuring energy. A quantum computer cannot read H directly. Z-type terms come from measuring both qubits in Z; XX needs a Hadamard on each qubit first. With N shots per setting, the estimate has statistical error ~ 1/sqrt(N). The energy is the weighted sum of the measured Pauli averages.

Optimizer. E(theta) = a + R cos(2 theta - phi), so the exact gradient follows from the parameter-shift rule: dE/dtheta = E(theta + pi/4) - E(theta - pi/4). Each step uses four circuit settings' worth of shots; gradient descent with step 0.3.

Noise. A depolarizing channel rho -> (1-p) rho + p I/4 scales every non-identity Pauli average by (1-p): E_noisy = c_II + (1-p)(E - c_II). Gate noise therefore shifts the answer; the optimizer then finds the minimum of the noisy landscape (which is still at the same theta here, but with a higher energy).

Simplifications: the electron-density cloud is schematic, no molecular geometry optimization, no readout error, no mitigation, a classical statevector simulation of the circuit.

Independent numerical checks
Made with 🟠 Blender · Three.js