- quantum_counting(qv, oracle, precision)#
This algorithm estimates the amount of solutions for a given Grover oracle.
The QuantumVariable on which to evaluate.
The oracle function.
The precision to perform the quantum phase estimation with.
An estimate of the amount of solutions.
We create an oracle, which performs a simple phase flip on the last qubit.
from qrisp import quantum_counting, z, QuantumVariable def oracle(qv): z(qv[-1])
We expect half of the state-space of the input to be a solution.
For 3 qubits, the state space is \(2^3 = 8\) dimensional.
>>> quantum_counting(QuantumVariable(3), oracle, 3) 3.999999999999999
For 4 qubits, the state space is \(2^4 = 16\) dimensional.
>>> quantum_counting(QuantumVariable(4), oracle, 3) 7.999999999999998