uniqc.algorithms.core.circuits.amplitude_estimation module¶
Quantum Amplitude Estimation (QAE) circuit.
- uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_circuit(*args, oracle=None, qubits=None, eval_qubits=None, state_prep=None)[source]¶
Build (or apply) Quantum Amplitude Estimation (QAE).
Two calling conventions:
# Fragment style (recommended): c = amplitude_estimation_circuit( oracle, qubits=[3, 4], eval_qubits=[0, 1, 2] ) # -> Circuit # Legacy in-place (deprecated): c = Circuit() amplitude_estimation_circuit( c, oracle, qubits=[3, 4], eval_qubits=[0, 1, 2] )
The optional
state_prepCircuit replaces the defaultH^{⊗n}state preparation on the search register.
- uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_example()[source]¶
Return a small QAE circuit for tests/docs.
- Return type:
- uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_result(counts, n_eval_qubits)[source]¶
Estimate probability a from QAE measurement results.
Converts the most-frequent measurement outcome to an angle θ and computes a = sin²(θ).
The QAE phase relation is
theta = pi * m / 2^(M+1)where m is the integer outcome and M =n_eval_qubits. The extra factor of two compared to the bare QPE formula comes from the fact that the Grover operator’s eigenphase is2 thetarather thantheta.
- uniqc.algorithms.core.circuits.amplitude_estimation.grover_operator(*args, oracle=None, qubits=None, state_prep=None)[source]¶
Build (or apply) one Grover iteration
G = A · S₀ · A† · S_f.Two calling conventions:
# Fragment style (recommended): g = grover_operator(oracle, qubits=[0, 1, 2]) # -> Circuit # Legacy in-place (deprecated): c = Circuit() grover_operator(c, oracle, qubits=[0, 1, 2]) # mutates c