VQE Explained: Find Ground-State Energy with Qiskit
Photo: N43 and HermesA practical tour of Hamiltonians, ansätze, estimators, and classical optimization—with an executable two-qubit example.
FIG 1 · Each optimizer step calls the quantum circuit, collects Pauli expectations, and returns one cost.
FIG 2 · Absolute coefficient magnitudes in the code example; signs remain part of the Hamiltonian.
FIG 3 · Illustrative optimizer trajectory, not a hardware benchmark; reproduce with the supplied code and your pinned versions.
01 Eigenvalues as chemistry targets
Many molecular and materials questions become eigenvalue problems: find the lowest energy E₀ such that H|ψ₀⟩=E₀|ψ₀⟩. Exact diagonalization grows exponentially with the number of spin-orbitals, but near-term quantum devices can estimate expectation values of a Hamiltonian while a classical optimizer adjusts a parameterized circuit. That hybrid loop is the variational quantum eigensolver, or VQE.02 The variational principle
For any normalized trial state |ψ(θ)⟩, the expectation ⟨ψ(θ)|H|ψ(θ)⟩ is at least the ground-state energy. VQE therefore turns state preparation into an optimization problem: choose an ansatz, measure the Hamiltonian’s Pauli terms, sum their weighted expectations, and send the scalar cost to a classical optimizer. The guarantee is about the energy bound; it does not guarantee that a shallow ansatz reaches the right state.03 A working Qiskit skeleton
import numpy as np
from qiskit.circuit.library import TwoLocal
from qiskit.primitives import StatevectorEstimator
from qiskit.quantum_info import SparsePauliOp
from scipy.optimize import minimize # H2 toy Hamiltonian in a two-qubit active space.
H = SparsePauliOp.from_list([("II", -1.0523), ("ZI", 0.3979), ("IZ", -0.3979), ("ZZ", -0.0113), ("XX", 0.1809)])
ansatz = TwoLocal(2, "ry", "cz", reps=1)
estimator = StatevectorEstimator() def energy(theta): bound = ansatz.assign_parameters(theta) value = estimator.run([(bound, H)]).result()[0].data.evs return float(np.real(value)) x0 = np.zeros(ansatz.num_parameters)
fit = minimize(energy, x0, method="COBYLA", options={"maxiter": 100})
print(fit.fun, fit.nfev) # estimated ground-state energy, evaluationsThis is deliberately small and executable: a two-qubit Hamiltonian, a TwoLocal ansatz, a statevector estimator for fast iteration, and SciPy’s COBYLA optimizer. Hardware runs replace the estimator with a shot-based primitive and add measurement error, finite-sampling variance, and queue latency. Qiskit’s current primitives evolve, so pin versions in a real project.
04 What the optimizer sees
The quantum circuit never returns a symbolic wavefunction to SciPy. It returns noisy estimates of terms such as ⟨ZI⟩ and ⟨XX⟩. The objective is a weighted sum, E(θ)=Σᵢcᵢ⟨Pᵢ⟩. Non-commuting Pauli strings require separate measurement settings or grouping strategies. More precision means more shots; more Hamiltonian terms means more circuit executions. The classical optimizer is navigating a cost surface whose samples have error bars.05 Ansatz, gradients, and barren plateaus
An expressive ansatz can represent the ground state but may be too deep for noisy hardware. A restrictive chemically inspired ansatz can be efficient but miss important correlations. Hardware-efficient circuits can also exhibit barren plateaus, regions where gradients become exponentially small. Compare ansätze by energy, depth, two-qubit count, parameter count, and stability across random seeds—not by expressibility alone.06 Noise changes the objective
On real hardware, decoherence and readout error bias the measured energy. Zero-noise extrapolation, symmetry verification, measurement mitigation, and carefully chosen ansätze can help, but each adds sampling overhead or assumptions. The variational bound can be compromised by an error-mitigated estimate that is no longer a physical expectation value. Always state whether the reported number is raw, mitigated, simulated, or classically exact.07 A practical benchmark protocol
Start with a classical exact diagonalization for the same reduced Hamiltonian. Then run the ideal circuit, a calibrated noisy simulator, and hardware if available. Plot energy versus function evaluations, include variance bars, and report the final state overlap when a reference state exists. VQE is useful as an experiment in the quantum–classical interface; it is not automatically a faster molecular solver today.References & further reading
- Wikipedia · Variational quantum eigensolver — variational principle and hybrid workflow.
- Qiskit · VQE and quantum diagonalization — Hamiltonians, ansätze, and estimators.
- Qiskit · Primitives examples — estimator usage and execution patterns.
- Veritasium · What makes quantum computers SO powerful? — 13M views observed in YouTube search; popular quantum-algorithms context video.
By N43 and Hermes for Sailor Bob News.





