“Know how to solve every problem that has been solved.” “What I cannot create, I do not understand.” — Richard Feynman

The Variational Quantum Eigensolver

Quantum Computing

What you need to know first 12 concepts, 6 layers

The requisite-knowledge inventory for this page, bottom-up: the primitives at the base, combined upward until you reach what this page assumes. Skim the layers you already own; start wherever the ground gets unfamiliar.

  1. base
  2. L1
  3. L2
  4. L3
  5. L4
  6. L5
  7. you are here

4 of these are concepts without a dedicated page yet — the grey chips. Following the linked ones first makes the rest land.

The variational quantum eigensolver finds a molecule's ground-state energy by running the variational principle on a quantum computer: prepare a trial state with a tunable circuit, measure its energy, and let a classical optimizer turn the knobs down. It solves the same H₂ you build from scratch — same integrals, same binding curve — by a completely different machine. Five ways in.

read it as

The whole thing rests on one inequality you already know: for any normalized trial state, , the true ground-state energy. So parametrize the trial state by some knobs , evaluate the energy, and minimize:

VQE changes exactly one thing about this familiar recipe: the state is prepared by a quantum circuit, and the energy is read off by measuring qubits. The minimization is still done by an ordinary classical optimizer. Watch it in the demo: the landscape never dips below the green floor , and the minimum sits exactly on it.

Be the optimizer

Left: the variational landscape at the bond length you choose. Drag — you are the classical optimizer — and try to reach the green floor ; the orange dot is where Hartree–Fock sits (), and the gap between it and the floor is the correlation energy. Right: the H₂ binding curve, VQE versus Hartree–Fock, with your bond length marked. Everything is the validated STO-3G H₂ — the same molecule, three ways across this site.

VQE / FCIHartree-FockE₀ (exact ground)your θ

At R = 1.38 bohr, your ansatz gives E(θ) = -1.1172 ≥ E₀ = -1.1373 Ha. Drag θ down to the floor, or press Minimize — the variational principle guarantees you can never go below E₀.

The whole optimizer, in code

With H₂ reduced to one angle, the entire VQE is a one-line energy function and a gradient walk. On real hardware the energy comes from measuring qubits and the optimizer is fancier, but the skeleton — evaluate , step downhill, repeat — is exactly this.

import numpy as np
# H2 / STO-3G reduced to its 2-configuration model (validated: HF -1.1167,
# FCI -1.1373 at R=1.4 bohr). The singlet ground state lives in span{|g^2>,|u^2>},
# so the whole VQE is one rotation angle θ:  |ψ(θ)> = cos θ |g^2> - sin θ |u^2>.

def energy(theta, H00, H11, H01):          # <ψ(θ)| H |ψ(θ)>
    c, s = np.cos(theta), np.sin(theta)
    return c*c*H00 + s*s*H11 + 2*c*s*H01

# The quantum-classical loop: the "quantum computer" returns energy(θ);
# a classical optimizer walks θ downhill. The variational principle guarantees
# energy(θ) >= E0 for every θ, so the minimum is an upper bound on the truth.
theta = 0.0                                 # start at the Hartree-Fock state
for _ in range(40):
    g = (energy(theta+1e-5, *H) - energy(theta-1e-5, *H)) / 2e-5
    theta -= 0.5 * g                        # gradient step
E_vqe = energy(theta, *H)                   # == lowest eigenvalue of the 2x2 H
# Validated against the textbook H2/STO-3G numbers
  R = 1.4 bohr:  E_HF = -1.11671   E_VQE = -1.13728   (exact FCI -1.1373)
  correlation recovered by VQE that Hartree-Fock misses:  0.0206 hartree
# dissociation (R = 4.5 bohr):  HF = -0.7185 (wrong)   VQE = -0.9375 (correct shape)
# the qubit Hamiltonian (parity-mapped) is  H = c0 I + c1 Z0 + c2 Z1 + c3 Z0Z1 + c4 X0X1

Where this fits

VQE is the fourth way this site solves the same H₂: Hartree–Fock gives the mean-field answer, FCI diagonalizes exactly, DMRG compresses the wavefunction, and VQE hands the state to a quantum circuit and varies it — all four lower-bounded by the one variational principle, all four built from the same molecular integrals. The natural continuations: the UCC ansatz and why it is hard to run, measuring the Pauli terms with finite shots (where the noise lives), and the barren-plateau problem that makes deeper circuits hard to optimize.