A function-encoding circuit prepares two quantum registers so each encoded input k is paired with its corresponding encoded output f(k). The key register represents candidate inputs; the value register stores signed outputs, enabling Grover search to evaluate and optimize the function. section 11.2
A practical construction uses:
- Three key qubits to represent integers 0 through 7 and six value qubits to encode outputs in two’s complement. section 11.2
- A polynomial over binary variables, converted into circuit terms and passed to build_polynomial_circuit. section 11.2
- Measurement and outcome processing that decodes k and f(k), checks progress, and updates the circuit’s free term. section 11.2
Encoding a parabola
For f(k) = -(k - 3)^2 + 3, the circuit encodes values from -13 through 3. Integrated with Grover iterations, repeated measurements and parameter updates eventually return (3, 3), the maximum found by the optimizer. section 11.2
Figure 11.6 A flow chart of the Grover optimizer
Trace the preparation, Grover-search, evaluation, and circuit-update loop visually. section 11.2
