approximated up to error ε using only polylog(1/ε) gates from the set {H, Rπ/4}.
In the subsequent chapters, when we talk about gate complexity, we count the number of 1-qubit and 2-qubit quantum gates in a circuit.
The query model. Besides applications of these simple 2-qubit gates, it is often convenient to separately count the applications of certain “black-box” unitaries. We call an application of such a unitary a query and we refer to such a unitary as an oracle.
For example, for a bitstring x ∈ {0, 1}n we can think of allowing access to the quantum analogue of the classical oracle that allows you to query a bit of x. That is, we may consider the standard bit oracle: the unitary Ox acting on Cn⊗ C2 that is defined by
Ox: |i, bi 7→ |i, b ⊕ xii for i ∈ [n], and b ∈ {0, 1}.
Such an oracle can be used to test certain properties of the string x more efficiently than on a classical computer. For example, below we show how to find an index i ∈ [n] such that xi = 1 (if such an i exists) using only O(√
n) applications of Ox. Classically, Ω(n) queries of the form “what is xi?” are needed to succeed with high probability. In other words, we can more efficiently compute the OR function OR(x) = x1 ∨ x2 ∨ · · · ∨ xn on a quantum computer using queries to Ox. In Section 10.4 we study the quantum query complexity of Boolean functions f : {0, 1}n→ {0, 1}. We show there how to express the minimum number of queries to Oxthat are needed to compute f (x) as a semidefinite program.
9.2 The fundamental building blocks
In this section we provide an overview of the (quantum) complexity of some useful subroutines: unstructured search, amplitude amplification, amplitude estimation, minimum finding, and singular value transformation. This is by no means a com-plete list, it is merely a collection of tools that will be used in the subsequent chapters.
9.2.1 Grover search
The problem: suppose we are given an x ∈ {0, 1}n. Our goal is to find an index i ∈ [n] such that xi= 1 (and output that no solution exists if |x| = kxk1= 0).
Theorem 9.1 ([Gro96, BBHT98]). There exists a quantum algorithm that uses O(√
n) queries to Ox and O(√
n log(n)) other gates, and, with probability at least 2/3, outputs an i ∈ [n] such that xi= 1 if such an i exists.
The algorithm roughly works as follows. It first constructs a uniform super-position over all indices i: the state √1nP
i∈[n]|ii. This state can be written as
160 Chapter 9. Quantum algorithms α|φi + β|ψi where
|φi = X
i∈[n]:xi=1
1 p|x||ii
|ψi = X
i∈[n]:xi=0
1 pn − |x||ii,
and α = q|x|
n, β =
qn−|x|
n . That is, |φi corresponds to the ‘good’ indices and |ψi to the remaining ‘bad’ indices. Then it uses successive applications of the oracle Ox (to mark ‘good’ indices with a phase of −1) and a reflection through the subspace spanned by the uniform superposition, together called the Grover iterate, to boost the amplitude α on |φi to some α0 which is close to 1 in modulus.2 The latter ensures that upon measuring in the computational basis, we end up with a ‘good’
index.
We point out that a success probability of at least 2/3 does not seem much, especially if it used as a subroutine in a larger quantum algorithm. But a con-stant success probability of at least 2/3 can be boosted to at least 1 − δ with only O(log(1/δ)) repetitions (here 0 < δ < 1/2). The same will be true for the other quantum algorithms in this section, hence we usually only state the number of queries and gates needed to achieve a constant success probability > 1/2.
9.2.2 Amplitude amplification
The above procedure works since we have an oracle Ox to mark ‘good’ indices.
Therefore it can be generalized to arbitrary quantum algorithms for which we can mark ‘good’ solutions. This procedure is called amplitude amplification.
Theorem 9.2 ([BHMT02]). Suppose that U is a quantum algorithm acting on q qubits such that U |0i⊗q= α|φi + β|ψi, where α, β ∈ C and hψ|φi = 0, and that we have access to the unitary R = 2|φihφ| − I. Then, using O(1/|α|) applications of U , U∗ and R, and O(q/|α|) other gates, we can create a state α0|φi + β0|ψi such that |α0| > 2/3.
Grover search can be seen as a special case where U creates a uniform superpo-sition over all indices, which has amplitude 1/√
n on each of the ‘good’ indices, and where R is Ox. When n is a power of 2, we can use U = H⊗ log(n). Note that upon measuring the uniform superposition you would expect to see each good index with probability (1/√
n)2 = 1/n. If there is only one ‘good’ index you would therefore expect to need to repeat the procedure n times to see a good solution. Classically this is indeed the case. The above two algorithms show that √
n repetitions suffice on a quantum computer.
2The number of successive applications depends on |α|. This suggests that we need to know
|α| up front. It turns out that this is not needed [BBHT98].
9.2. The fundamental building blocks 161
9.2.3 Amplitude estimation
The number of applications of U and U∗ in the above procedure depends on the initial amplitude α on the ‘good’ indices. This suggests that we need to know |α|, or a good approximation of it, up front. Fortunately |α| can be estimated very well using a procedure called amplitude estimation [BHMT02]. We state here an easy corollary of amplitude estimation that we will use.
Lemma 9.3 ([vAGGdW17, Lem. 9]). Suppose we have a unitary U acting on q qubits such that U |0i⊗q = |0i|ψi + |1i|φi with kψk2 = p ≥ pmin for some known bound pmin, and kφk2= 1 − p. Let µ ∈ (0, 1] be the allowed multiplicative error in our estimation of p. Then, with O
1
D¨urr and Høyer [DH96] showed how to find the minimal value of a function f from [n] to R using only O(√
n) queries to f . They did so by repeatedly using Grover search to find smaller and smaller elements of the range of f . Just as amplitude amplification generalizes Grover search, we can also generalize the minimum finding procedure. Here we describe the more general minimum-finding procedure given in [vAGGdW17, App. C].
Suppose we have a unitary U which acts on the all-zero state as U |0i⊗q= X
k∈[n]
|ψki|xki,
where the |ψki are unnormalized states in (C2)⊗a. Assume that the states |xki ∈ (C2)⊗b are standard basis vectors so that we can interpret xk as a real number written down with b bits of precision. (Notice that a + b = q.) Let X be the random variable on {xk : k ∈ [n]} such that Pr(X = xk) = hψk|ψki. Our goal is to find the minimum value among the xk’s, using queries to U and U∗. We have the following result.
Theorem 9.4 (Generalized Minimum-Finding [vAGGdW17]). Let U be a unitary, acting on q qubits, such that U |0i⊗q=Pn
k=1|ψki|xki. Let X be the random variable on {xk : k ∈ [n]} such that Pr(X = xk) = k|ψkik2. Let x ≥ minkxk. Using M = O(1/pPr(X ≤ x)) applications of U and U∗ (and O(qM ) other gates) we can obtain an xi from the range of X that satisfies xi ≤ x with probability at least 34.
Our procedure can find the minimum value xk∗among the xk’s that have support in the second register, using roughly O(1/kψk∗k) applications of U and U∗. Also, upon finding the minimal value xk∗ the procedure actually outputs the normalized state proportional to |ψk∗i|xk∗i. This immediately gives the D¨urr-Høyer result as a special case, if we take U to produce U |0i = √1nPn
k=1|ki|f (k)i using one query
162 Chapter 9. Quantum algorithms to f . Unlike D¨urr-Høyer, we need not assume direct query access to the individual values f (k).
We finish this section with an example application of the above generalized minimum-finding procedure: we show how to estimate the minimum eigenvalue of a Hermitian matrix A.
Finding the minimal eigenvalue of a Hermitian matrix. Let A be an n × n Hermitian matrix whose rows (and hence columns) each have at most s non-zero entries. Such a matrix is called s-sparse. We assume sparse oracle access to A as described in Section 9.3.2 below, and will count queries to these oracles.
Lemma 9.5 ([vAGGdW17, App. C]). Suppose A ∈ Hn is given in s-sparse form.
Let A = Pn
Proof idea. Here we only provide the general idea of the proof, for the details we refer to [vAGGdW17, App. C]. The general idea is as follows. We construct a unitary U which maps the all-zero state toPn
k=1|ψki|λki where the |ψki are unnormalized states and |λki is a binary encoding of λk, and then we apply the generalized minimum-finding procedure of Theorem 9.4.
The quantum algorithm acts on several registers, the first three of which are relevant to explain the main ideas and for the sake of exposition we ignore the other registers. The first two are log(n)-qubit registers each. The last register will eventually correspond to the states |λki; it will contain sufficiently precise binary encodings of the eigenvalues λk, say using b bits (the precise value of b depends on the required precision ε). The algorithm works as follows. We first prepare the maximally entangled state on the first two registers, that is, we perform a unitary that acts as
We then use the invariance of maximally entangled states under transformations of the form W ⊗ W for any n × n unitary W :3
3To see this invariance, note that Pn−1
j=0|ji|ji = vec(I) = vec(W W∗) =Pn
j=1vec(wjw∗j) = Pn
j=1|wji|wji, where wjis the jth column of W .
9.3. Matrix arithmetics using block-encodings 163