The Variational Quantum Eigensolver (VQE) is a hybrid algorithm that finds the lowest
eigenvalue of a Hamiltonian H — its ground-state energyE0 — using a classical
optimization loop wrapped around a parameterized quantum circuit.
The variational principle
The foundation of VQE is the quantum mechanical variational principle: for any normalized
state ∣ψ⟩,
E0≤⟨ψ∣H∣ψ⟩,
with equality only when ∣ψ⟩ is the true ground state. This means that if we can
minimize ⟨ψ(θ)∣H∣ψ(θ)⟩ over the
parameter vector θ, the lowest value we reach is an upper bound on
E0 — and, with a rich enough ansatz, it equals E0 exactly.
The VQE loop
Choose a HamiltonianH and a parameterized ansatz circuit U(θ).
Prepare∣ψ(θ)⟩=U(θ)∣0⟩⊗n.
Measure the energy E(θ)=⟨ψ∣H∣ψ⟩ by decomposing
H into a sum of Pauli strings and measuring each term.
Updateθ using a classical optimizer (gradient descent,
parameter-shift gradients, COBYLA, etc.).
Repeat steps 2–4 until convergence.
Hamiltonian: Z⊗Z
For this project we work with the two-qubit Hamiltonian
H=Z0⊗Z1.
Its eigenvalues come from the product of the Z eigenvalues ±1. Explicitly:
The ground-state energy is E0=−1, achieved by ∣01⟩ or ∣10⟩.
Ansatz and optimal angles
We use the hardware-efficient ansatz with independent Ry rotations on each qubit:
∣ψ(θ0,θ1)⟩=Ry(θ0)∣0⟩⊗Ry(θ1)∣0⟩
where Ry(θ)=e−iθY/2. Since the two qubits are unentangled, the expectation
value factorizes:
⟨Z0Z1⟩=⟨Z0⟩⋅⟨Z1⟩=cosθ0⋅cosθ1.
To minimize cosθ0cosθ1 we want one factor to be +1 and the other −1. The
choice θ0=0,θ1=π gives
cos(0)⋅cos(π)=1⋅(−1)=−1=E0.
Try it
The starter code provides the optimal angles from a completed VQE run (θ0=0,
θ1=π). Apply the ansatz Ry(θ0) on qubit 0 and Ry(θ1) on qubit 1.
The grader checks the resulting statevector, which should be exactly ∣01⟩ — the
ground state of Z⊗Z.
Run your code to see the quantum state.
Sign in on the full site to ask questions and join the discussion.