# How many functions can be distinguished with 𝒌 quantum queries?[1]

## I Introduction

Quantum computers can solve certain oracular problems with fewer queries of the oracle than are required classically. For example, Grover’s algorithm for unstructured search can be viewed as distinguishing between the $`N`$ functions

$$G_j(x)=\{\begin{array}{cc}\hfill 1& \text{ for }x=j\hfill \\ \hfill 1& \text{ for }xj\hfill \end{array}$$
(1)   
where both $`x`$ and $`j`$ run from 1 to $`N`$. Identifying which of these $`N`$ functions the oracle holds requires of order $`N`$ queries classically, whereas quantum mechanically this can be done with of order $`\sqrt{N}`$ quantum queries.

The $`N`$ functions in (1) are a subset of the $`2^N`$ functions

$$F:\{1,2,\mathrm{},N\}\{1,1\}.$$
(2)   
*All* $`2^N`$ functions of this form can be distinguished with $`N`$ queries so the $`N`$ functions in (1) are particularly hard to distinguish classically. No more than $`2^k`$ functions can be distinguished with only $`k`$ classical queries, since each query has only two possible results. Note that this classical “information” bound of $`2^k`$ does not depend on $`N`$, the size of the domain of the functions.

Quantum mechanically the $`2^k`$ information bound does not hold. In this paper we derive an upper bound for the number of functions that can be distinguished with $`k`$ quantum queries. If there is a set of $`D`$ functions of the form (2) that can be distinguished with $`k`$ quantum queries, we show that

$$D1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\left(\genfrac{}{}{0pt}{}{N}{2}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right).$$
(3)   
If the probability of successfully identifying which function the oracle holds is only required to be $`p`$ for each of the $`D`$ functions, then

$$D\frac{1}{p}\left[1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\left(\genfrac{}{}{0pt}{}{N}{2}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)\right].$$
(4)   
We also give two examples of sets of $`D`$ functions (and values of $`k`$ and $`p`$) where (3) and (4) are equalities. In these cases the quantum algorithms succeed with fewer queries than the best corresponding classical algorithms. One of these examples shows that van Dam’s algorithm distinguishing all $`2^N`$ functions with high probability after $`N/2+O(\sqrt{N})`$ queries is best possible, answering a question posed in his paper. We also give an example showing that the bound (3) is not always tight.

An interesting consequence of (3) is a lower bound on the number of quantum queries needed to sort $`n`$ items in the comparison model. Here, we have $`D=n!`$ functions, corresponding to the $`n!`$ possible orderings, to be distinguished. The domain of these functions is the set of $`N=\left(\genfrac{}{}{0pt}{}{n}{2}\right)`$ pairs of items. If $`k=(1ϵ)n`$, the bound (3) is violated for $`ϵ>0`$ and $`n`$ large, as is easily checked. Hence, for any $`ϵ>0`$ and $`n`$ sufficiently large, $`n`$ items cannot be sorted with $`(1ϵ)n`$ quantum queries.

## II Main result

Given an oracle associated with any function $`F`$ of the form (2), a quantum query is an application of the unitary operator, $`\widehat{F}`$, defined by

$$\widehat{F}|x,q,w=|x,qF(x),w$$
(5)   
where $`x`$ runs from 1 to $`N`$, $`q=\pm 1`$, and $`w`$ indexes the work space. A quantum algorithm that makes $`k`$ queries starts with an initial state $`|s`$ and alternately applies $`\widehat{F}`$ and $`F`$-independent unitary operators, $`V_i`$, producing

$$|\psi _F=V_k\widehat{F}V_{k1}\mathrm{}V_1\widehat{F}|s.$$
(6)   
Suppose that the oracle holds one of the $`D`$ functions $`F_1,F_2,\mathrm{},F_D`$, all of the form (2). If the oracle holds $`F_j`$, then the final state of the algorithm is $`|\psi _{F_j}`$, but we do not (yet) know what $`j`$ is. To identify $`j`$ we divide the Hilbert space into $`D`$ orthogonal subspaces with corresponding projectors $`P_1,P_2,\mathrm{},P_D`$. We then make simultaneous measurements corresponding to this commuting set of projectors. One and only one of these measurements yields a $`1`$. If the $`1`$ is associated with $`P_{\mathrm{}}`$ we announce that the oracle holds $`F_{\mathrm{}}`$.

Following, if the oracle holds $`F`$, so that the state before the measurement was $`|\psi _F`$ given by (6), we know that for each $`\mathrm{}`$, $`P_{\mathrm{}}|\psi _F^2`$ is a $`2k`$-degree polynomial in the values $`F(1),F(2),\mathrm{},F(N)`$. More precisely,

$$P_{\mathrm{}}|\psi _F^2=\underset{r=1}{\overset{m_{\mathrm{}}}{}}\left|Q_\mathrm{}r(F(1),\mathrm{},F(N))\right|^2$$
(7)   
where each $`Q_\mathrm{}r`$ is a $`k`$-th degree multilinear polynomial and $`m_{\mathrm{}}`$ is the dimension of the $`\mathrm{}`$-th subspace. Note that formula (7) holds for *any* $`F`$ whether or not $`F=F_j`$ for some $`j`$. The algorithm succeeds, with probability at least $`p`$, if for each $`j=1,\mathrm{},D`$, we have

$$P_j|\psi _{F_j}^2=\underset{r=1}{\overset{m_j}{}}\left|Q_{jr}(F_j(1),\mathrm{},F_j(N))\right|^2p.$$
(8)   
We now prove the following lemma: Let $`F_0`$ be any one of the functions of form (2). If $`Q`$ is a polynomial of degree at most $`k`$ such that

$$\left|Q(F_0(1),\mathrm{},F_0(N))\right|^2=1$$
(9)   
then

$$\underset{F}{}\left|Q(F(1),\mathrm{},F(N))\right|^2\frac{2^N}{1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)}$$
(10)   
where the sum is over all $`2^N`$ functions of the form (2). Proof: Without loss of generality we can take $`F_0(1)=F_0(2)=\mathrm{}=F_0(N)=1`$. Now

$$Q(F(1),\mathrm{},F(N))=a_0+\underset{x}{}a_xF(x)+\underset{x<y}{}a_{xy}F(x)F(y)+\mathrm{}$$
(11)   
where the last term has $`k`$ factors of $`F`$ and the coefficients are complex numbers. Note that

$$\underset{F}{}F(x_1)F(x_2)\mathrm{}F(x_g)F(y_1)\mathrm{}F(y_h)=0$$
(12)   
as long as the sets $`\{x_1,\mathrm{},x_g\}`$ and $`\{y_1,\mathrm{},y_h\}`$ are not equal and $`x_1,\mathrm{},x_g`$ are distinct, as are $`y_1,\mathrm{},y_h`$. This means that

$$\underset{F}{}\left|Q(F(1),\mathrm{},F(N))\right|^2=2^N\left(|a_0|^2+\underset{x}{}|a_x|^2+\underset{x<y}{}|a_{xy}|^2+\mathrm{}\right).$$
(13)   
Now (9) with $`F_0(x)1`$ means

$$\left|a_0+\underset{x}{}a_x+\underset{x<y}{}a_{xy}+\mathrm{}\right|^2=1.$$
(14)   
Because of the constraint (14), the minimum value of (13) is achieved when all the coefficients are equal. Since there are $`1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)`$ coefficients, the inequality (10) is established.

Suppose we are given an algorithm that meets condition (8) for $`j=1,\mathrm{},D`$. Then by the above lemma,

$$\underset{r=1}{\overset{m_j}{}}\underset{F}{}\left|Q_{jr}(F(1),\mathrm{},F(N))\right|^2\frac{2^Np}{1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)}.$$
(15)   
Summing over $`j`$ using (7) yields

$$\underset{j}{}\underset{F}{}P_j|\psi _F^2\frac{D2^Np}{1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)}.$$
(16)   
For each $`F`$, the sum on $`j`$ gives 1 since $`|\psi _F=1`$. Therefore the lefthand side of (16) is $`2^N`$ and (4) follows.

## III Examples

0.  If $`k=N`$, all $`2^N`$ functions can be distinguished classically and therefore quantum mechanically. In this case (3) becomes

$$2^N=D1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\left(\genfrac{}{}{0pt}{}{N}{2}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{N}\right)=2^N.$$
(17)   
1.  For $`k=1`$, if $`N=2^n1`$ there are $`N+1`$ functions that can be distinguished so the bound (3) is best possible. The functions can be written as

$$f_a(x)=(1)^{ax}$$
(18)   
with $`x\{1,\mathrm{},N\}`$ and $`a\{0,1,\mathrm{},N\}`$ and $`ax=_ia_ix_i`$ where $`a_1\mathrm{}a_n`$ and $`x_1\mathrm{}x_n`$ are the binary representations of $`a`$ and $`x`$. To see how these can be distinguished we work in a Hilbert space with basis $`\{|x,q\}`$, $`x=1,\mathrm{},N`$ and $`q=\pm 1`$, where a quantum query is defined as in (5) and the work bits have been suppressed. We define

$$|x=\frac{1}{\sqrt{2}}\{|x,+1|x,1\}x=1,\mathrm{},N$$
(19)   
and

$$|0=\frac{1}{\sqrt{2}}\{|1,+1+|1,1\},$$
(20)   
so $`\{|x\}`$, $`x=0,1,\mathrm{},N`$, is an orthonormal set. Now by (5), if we define $`F(0)`$ to be $`+1`$, we have

$$\widehat{F}|x=F(x)|xx=0,1,\mathrm{},N$$
(21)   
and in particular,

$$\widehat{f}_a|x=(1)^{ax}|xx=0,1,\mathrm{},N$$
(22)   
Now let

$$|s=\frac{1}{\sqrt{N+1}}\underset{x=0}{\overset{N}{}}|x$$
(23)   
and observe that the $`N+1`$ states $`\widehat{f}_a|s`$ are orthogonal for $`a=0,1,\mathrm{},N`$.

2.  In an algorithm is presented that distinguishes all $`2^N`$ functions in $`k`$ calls with probability $`\left(1+\left(\genfrac{}{}{0pt}{}{N}{1}\right)+\mathrm{}+\left(\genfrac{}{}{0pt}{}{N}{k}\right)\right)/2^N`$. With this value of $`p`$, and $`D=2^N`$, the bound (4) becomes an equality. Furthermore, (4) shows that this algorithm is best possible.

3.  Nowhere in this paper have we exploited the fact that for an algorithm that succeeds with probability 1, it must be the case that $`P_{\mathrm{}}|\psi _{F_j}=0`$ for $`\mathrm{}j`$. With this additional constraint it can be shown that for $`N=3`$, no set of $`7=1+\left(\genfrac{}{}{0pt}{}{3}{1}\right)+\left(\genfrac{}{}{0pt}{}{3}{2}\right)`$ functions can be distinguished with $`2`$ quantum queries. Thus for $`N=3`$ and $`k=2`$ the bound (3) is not tight.