MarketQuantum counting algorithm
Company Profile

Quantum counting algorithm

The Quantum counting algorithm is a quantum algorithm for efficiently counting the number of solutions for a given search problem. The algorithm is based on the quantum phase estimation algorithm and on Grover's search algorithm.

The problem
Consider a finite set \{0,1\}^n of size N=2^n and a set B of "solutions" (that is a subset of \{0,1\}^n ). Define: : \begin{cases} f : \left\{0,1\right\}^n \to \{0,1\} \\ f(x) = \begin{cases} 1 & x \in B \\ 0 & x \notin B \end{cases} \end{cases} In other words, f is the indicator function of B. Calculate the number of solutions M = \left\vert f^{-1}(1) \right\vert = \vert B \vert. Classical solution Without any prior knowledge on the set of solutions B (or the structure of the function f), a classical deterministic solution cannot perform better than \Omega(N), because all the N elements of \{0,1\}^n must be inspected (consider a case where the last element to be inspected is a solution). == The algorithm ==
The algorithm
|\psi\rangle = |0\rangle. • Haddamard gate operations is applied on both lower and upper registers. --> Setup The input consists of two registers (namely, two parts): the upper p qubits comprise the first register, and the lower n qubits are the second register. Create superposition The initial state of the system is |0\rangle^{\otimes p}|0\rangle^{\otimes n}. After applying multiple bit Hadamard gate operation on each of the registers separately, the state of the first register is :\frac{1}{2^{p/2}}(|0\rangle + |1\rangle)^{\otimes p} and the state of the second register is :\frac{1}{2^{n/2}}(|0\rangle + |1\rangle)^{\otimes n} = \frac{1}{\sqrt{N}}\sum_{x=0}^{N-1}|x\rangle an equal superposition state in the computational basis. Grover operator Because the size of the space is \left\vert \{0,1\}^n \right\vert = 2^n = N and the number of solutions is \left\vert B \right\vert = M , we can define the normalized states: From the properties of rotation matrices we know that G is a unitary matrix with the two eigenvalues e^{\pm i \theta}. Note that the second register is actually in a superposition of the eigenvectors of the Grover operator (while in the original quantum phase estimation algorithm, the second register is the required eigenvector). This means that with some probability, we approximate \theta, and with some probability, we approximate 2\pi - \theta; those two approximations are equivalent. Analysis Assuming that the size N of the space is at least twice the number of solutions (namely, assuming that M \leq \tfrac{N}{2} ), a result of the analysis of Grover's algorithm is: : \sin {\frac{\theta}{2}} = \sqrt{\frac{M}{N}}. Thus, if we find \theta, we can also find the value of M (because N is known). The error : \frac{\vert \Delta M \vert}{N} = \left \vert \sin^2 \left( \frac{\theta + \Delta \theta}{2} \right) - \sin^2 \left( \frac{\theta}{2} \right) \right \vert is determined by the error within estimation of the value of \theta. The quantum phase estimation algorithm finds, with high probability, the best p-bit approximation of \theta; this means that if p is large enough, we will have \Delta \theta \approx 0, hence \vert \Delta M \vert \approx 0 . \Bigg\vert \sin {\frac{\theta + \Delta \theta}{2}} - \sin {\frac{\theta}{2}}\Bigg\vert \leq \frac{\Delta \theta}{2} and \Bigg\vert \sin {\frac{\theta + \Delta \theta}{2}}\Bigg\vert we see that \vert \Delta M \vert . --> == Uses ==
Uses
Grover's search algorithm for an initially-unknown number of solutions In Grover's search algorithm, the number of iterations that should be done is \frac{\pi}{4}\sqrt{\frac{N}{M}}. A trivial solution to this problem is directly using the quantum counting algorithm: the algorithm yields M, so by checking whether M \neq 0 we get the answer to the existence problem. This approach involves some overhead information because we are not interested in the value of M. Quantum phase estimation can be optimized to eliminate this overhead. E.g. QRT(5,>) gives back YES if the data base contains any value larger than 5 else it returns NO. Quantum relation testing combined with classical logarithmic search forms an efficient quantum min/max searching algorithm. == See also ==
tickerdossier.comtickerdossier.substack.com