∑ | Quantum Computing
Chapter 19 / 20

Variational quantum algorithms

Combine parameterized circuits with classical optimization.

1. Core idea

A parameterized circuit prepares a family of trial states. Measurements estimate an objective, and a classical optimizer updates the angles. VQE targets energy minimization; QAOA targets structured combinatorial objectives. Optimization landscapes, sampling cost, and noise limit practical performance.

2. Mathematical foundation

The notation describes a precise relationship among states, transformations or probabilities. Identify each symbol, check the dimensions of the objects, and distinguish amplitudes from the probabilities produced by a measurement.

3. Worked example

For H=Z and ansatz R_y(θ)|0⟩, the expected energy is cos θ and is minimized at θ=π.

4. Reasoning flow

  1. Define the initial register and its basis states.
  2. Apply the transformations in their intended order.
  3. Track amplitude magnitudes and relative phases.
  4. Measure in the basis that reveals the desired property.
  5. Interpret the result and check the resource assumptions.

Qiskit implementation

Run this standalone Python script with Qiskit installed. It uses exact statevector simulation rather than noisy hardware shots.

import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector, SparsePauliOp
H = SparsePauliOp.from_list([('Z', 1.0)])
for theta in np.linspace(0, 2*np.pi, 9):
    qc = QuantumCircuit(1)
    qc.ry(float(theta), 0)
    energy = Statevector.from_instruction(qc).expectation_value(H).real
    print(f'theta={theta:.3f}, energy={energy:.3f}')
# Minimum at theta=pi, energy=-1. A full VQE also optimizes parameters.
Download runnable Python

5. Check your understanding

Practice question

Differentiate cos θ and identify its minimum over [0,2π].

6. What to watch out for

Ideal-state calculations assume perfect gates and measurements. When assessing an algorithm, separate its mathematical guarantee from the cost of building oracles, preparing inputs, repeating experiments and correcting physical noise.

◈ QubitSemantics Hub