Quantum amplitude estimation estimates the combined probability, or under equal probabilities the count, of marked outcomes. Instead of relying only on repeated measurements, it estimates the rotation angle induced by a Grover operator, using additional qubits and a more complex computation. section 9.6.1 section 9.7
Build the procedure around a state-preparation circuit A and an oracle O:
- Prepare an n-qubit estimation register with Hadamard gates and an m-qubit target register with A. section 9.6.1
- Construct the Grover iterate G = A M₀ A⁻¹ O and apply controlled powers G²ᵏ for each estimation qubit. section 9.6.1
- Apply the inverse quantum Fourier transform to the estimation register, measure repeatedly, and select the most frequent estimation value v. section 9.6.1
- Convert v into a probability estimate with sin²(vπ/2ⁿ), or use the corresponding count formula when outcomes are equally likely. section 9.6.1
Estimating two marked outcomes
Prepare a three-qubit state with a randomly generated circuit, mark outcomes 0 and 1, and run amplitude estimation with n = 8 estimation qubits. The measured dominant value v = 37 produces an estimated probability of 0.1924, compared with the directly computed probability 0.1897666121194554. section 9.6.3
Figure 9.27 The amplitude estimation diagram where A is an m-qubit circuit and G is a Grover operator constructed using an m-qubit oracle circuit
Use the circuit diagram to trace the estimation register, target register, state-preparation circuit A, controlled Grover iterates, and inverse quantum Fourier transform. section 9.6.1
Listing 9.5 Function to create the amplitude estimation circuit
from algo import grover_iterate_circuit
def amplitude_estimation_circuit(n, A, O, swap=True):
c = QuantumRegister(n)
q = QuantumRegister(sum(A.regs))
qc = QuantumCircuit(c, q)
for i in range(n):
qc.h(c[i])
qc.append(A, q)
for i in range(n):
for _ in range(2**i):
if swap:
qc.c_append(grover_iterate_circuit(A, O), c[i], q) #1
else:
qc.c_append(grover_iterate_circuit(A, O), c[n-1-i], q)
qc.iqft(c if swap else c[::-1], swap)
return qc
Use the circuit-building function to implement register creation, controlled Grover-iterate repetitions, optional register-order swaps, and the inverse quantum Fourier transform. section 9.6.1
