Variational Quantum Eigensolver
A hardware-efficient ansatz prepares a trial state ψ(θ); a classical optimiser tunes the rotation angles by gradient descent to minimise the molecular energy ⟨ψ(θ)|Ĥ|ψ(θ)⟩. The circuit, the angles, and the descent are all live — a genuine state-vector simulation of H₂ in a minimal basis, converging to its exact ground-state energy.
Ansatz: Ry(θ₀)⊗Ry(θ₁) → CNOT → Ry(θ₂)⊗Ry(θ₃). Gradients by the parameter-shift rule; angles updated by gradient descent. The 4×4 Hamiltonian (Z, ZZ, XX, YY terms) is diagonalised exactly for the reference line. Pure JavaScript, no libraries.