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_prep Circuit replaces the default H^{⊗n} state preparation on the search register.

Parameters:
uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_example()[source]

Return a small QAE circuit for tests/docs.

Return type:

Circuit

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 is 2 theta rather than theta.

Parameters:
  • counts (dict) – Dictionary mapping measurement outcomes (bit-strings or integers) to frequencies/counts.

  • n_eval_qubits (int) – Number of evaluation qubits used in QAE.

Returns:

Estimated probability a ∈ [0, 1].

Return type:

float

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
Parameters: