Playing Pool with $|\psi \rangle$: from Bouncing Billiards to Quantum Search

In"Playing Pool with $\pi$'', Galperin invented an extraordinary method to learn the digits of $\pi$ by counting the collisions of billiard balls. Here I demonstrate an exact isomorphism between Galperin's bouncing billiards and Grover's algorithm for quantum search. This provides an illuminating way to visualize what Grover's algorithm is actually doing.


Overview
An impractical but picturesque way to determine the digits of π is to hurl a heavy ball towards a light ball that has its back to a wall, as in Fig. 1, and then count the ensuing elastic collisions. Let's start with equal masses, M =1. At the first collision, the left ball transfers all its momentum to the right ball. At the second collision, the right ball's momentum is reversed by the wall. At the third and final collision, the right ball transfers all its momentum back to the left ball. In total, M = 1 → # collisions = 3 . These digits look familiar! In "Playing Pool with π" [1], G. Galperin proved that this algorithm really is spitting out the digits of π, since for M = 100 N # collisions = π √ M .
Let us make a seemingly abrupt shift and now turn our attention to the field of quantum query complexity. One of the most famous algorithms in all of quantum mechanics is that of L. Grover [3]. Grover's algorithm provides a way to "find a needle in a quantum haystack"or more precisely to determine which out of d mystery functions are being implemented by a black-box quantum oracle. For d − 1 = 100 N the runtime is In this paper I will argue that the similarity between Eq. 1.5 and Eq. 1.6 is not a coincidence. It's the same squareroot, and the same π, and for the same reason. The factor of 1 4 is merely a book-keeping anomaly arising from different accounting practices. Indeed, I will argue that there is a precise isomorphism between bouncing billiard balls and quantum search.

Quantum Search
The wavefunction of a d-state system-a 'qudit'-may in general be written as and conservation of probability means that throughout its evolution the state will always have conservation of probability: The Grover task [3] imagines we are given a black box that implements the transformation This unitary acts on the qudit by flipping the sign of the w th amplitude while leaving all the others unchanged. For example, for w = 7 we'd havê Our job is to figure out whichÛ w we have been given, i.e. to determine the value of w. Making our task harder is the fact that the value of w is not written on the box, and we are not allowed to take a screwdriver to open the box: the rules state that the only way we are allowed to interact with the black box is to feed states in and see what comes out.
A simple strategy to determine w is to feed states in one-by-one, first |1 , then |2 , then |3 , etc., until we come to a state whose sign is flipped. While this strategy succeeds, it succeeds only slowly-on average we will need to use the box 1 2 d times. That is how long it takes to find a classical needle in a classical haystack. The surprising fact that Grover discovered is that we can do better-much better. Grover's algorithm allows us to find w using only O( √ d ) calls. Given that we do not know the value of w, the most democratic option is to start with an even superposition, and indeed that is where Grover's algorithm begins, We feed this into the black box, yieldingÛ w |s , which has −v w = v i =w = 1/ √ d . Already this wavefunction 'knows' the value of w, sinceÛ w |s =Û w |s for w = w , and so if we could determine the wavefunction directly we could solve the Grover problem in one step. But quantum mechanics doesn't work that way. The dramatic tension at the heart of quantum information theory is the interplay between the quantum superpower-the ability to try all possibilities at once-and the quantum superweakness-the limitation to always acting linearly. One consequence of linearity is that only orthogonal states can be reliably distinguished. Since for large d the statesÛ w |s andÛ w |s are far from orthogonal, in order to determine the value of w we must amplify the difference. But how? The most obvious move is just to plug the output back into the black box again, but this is counterproductive since it takes us back to square one,Û 2 w = 1. Instead, Grover showed that our next step should be to act witĥ We can constructÛ s without using the black box, since it makes no reference to w and indeed treats all basis states the same. Grover's algorithm is then just to repeatedly iterateÛ s andÛ w .  In order to analyze the effect of this iteration, it will be helpful to use an orthonormal coordinate system. The state |s is not exactly orthogonal to |w , but we can find a state |s such that w|s = 0 by defining (2.14) BothÛ s andÛ w keep us on the circle defined by |θ ≡ cos θ|s + sin θ|w .
On this circle,Û s reflects about the |s -axis andÛ w reflects about the |s -axis, The two consecutive non-parallel reflections combine to give a rotation by 2θ, We will use repeated applications ofÛ sÛw to rotate the state from |s (i.e. θ =θ) to |w (i.e. θ = π 2 ) in steps of size 2θ. For almost all d, and in particular for all d − 1 = 100 N , the integer closest to ( π 2 −θ)/2θ is π 4 √ d − 1 , and so Grover's algorithm calls for that many steps Since w|w = 0 for w = w , with high probability we can now just measure the qudit to learn the value of w and successfully complete the Grover task.

Balls to the wall
The velocity of d billiards moving on a line may be described by a d-dimensional vector, v i . To make the analogy with quantum mechanics more visceral, we could write this vector in |ket notation as Elastic collisions conserve kinetic energy. If all the billiards have mass 1, and if they start with total kinetic energy 1 2 , then throughout their evolution they will preserve conservation of kinetic energy: To replicate the π-calculating set-up from Sec. 1, we should separate off one billiard (let us say the wth) to be the light ball, and glue together all the other billiards to form one big heavy ball of mass The glue constrains all the v i =w to be the same, and then conservation of energy confines the velocity vector to lie on the circle given by sin θ = v w and cos θ = |θ ≡ cos θ|s + sin θ|w .  The effect of a collision will be to map this circle into itself. The exact form of the map can be determined by considering which momentum each collision conserves. Let's argue by symmetry. The linear maps from a circle to itself are described by the group O(2), which has two components: the rotations (det = +1); and the reflections (det = −1). Rotations leave no vectors invariant, whereas reflections leave invariant the vector that points down the axis being reflected about. Thus any O(2) map that conserves the inner product with |φ is either 1 or the reflectionÔ |φ ≡ 2|φ φ| − 1. The conserved quantities thus exactly fix the forms of the orthogonal matrices that describe the collisions.
• Collisions between the light ball and the wall,Ô wall .
These collisions reverse the velocity of the light ball while leaving all other velocities unchanged v i → (−1) δ iw v i ; alternatively we can say that they conserve the momentum of the large ball, Since the collision conserves s|θ , symmetry tells us it must enact • Collisions between the heavy ball and the light ball,Ô ball .
In the center-of-mass rest frame both velocities get reversed; alternatively we can say these collisions conserve the total momentum of the balls, Since the collision conserves s|θ , symmetry tells us it must enact The small ball bounces back and forth between the wall (Ô wall ) and the large ball (Ô ball ). Each lap, the two reflections combine to make a rotation by 2θ, exactly as in Eq. 2.17 All that remains is to specify the initial state. Galperin's original π-counting plan [1] starts in |s : the light ball begins at rest. To make the analogy with Grover's algorithm perfect, we should instead start in |s : the two balls begin with the same velocity. With this minor tweak, the isomorphism between billiards and quantum search becomes exact.

Discussion
The isomorphism between Grover search and the bouncing of billiards is a duality between a discrete quantum system and a continuous classical system. Let's examine some aspects of the duality in more detail.
• Factor of Four.
There is a factor of 4 discrepancy between the collision-counting Eq. 1.5 and the querycounting Eq. 1.6. The factor of four is really two factors of two.
One factor of 2 comes from how we count. The billiard problem counts every collision; by contrast Grover's problem treatsÛ s as free and only charges for applications ofÛ w .
The other factor of 2 comes from when we stop. Grover's algorithm stops when the heavy ball has transferred all its energy to the small ball to reach |w = |θ = π 2 ; by contrast the billiard algorithm keeps going twice as long, until the small ball has retransferred all its energy back to the heavy ball again to reach −|s = |θ = π .
The crowd-pleaser in the collision-counting Eq. 1.5 is the "π", but even the square root is at first blush somewhat surprising. After all, the first collision transfers only a single unit of kinetic energy, and there are M units to be transferred in total, so you might think it is going to take O(M ) collisions. The bouncing algorithm nevertheless gets the job done • One Hit Wonder.
Grover search for one out of four items is unusually easy. With precisely one iteration of the algorithm, the search suceeds with 100% probability. This is dual to the fact that when M = 3, after a single pair of collisions the light ball is left exactly stationary. • Keeping it Real.
Throughout the Grover process, the wavefunction stays real. The v i are always real, and operatorsÛ w andÛ s are not just unitary but orthogonal. Grover's algorithm thus shows you do not need complex numbers to get a quantum speed up. In the billiard problem, the reality of the wavefunction corresponds to the billiards moving only horizontally.

• Numerous Needles.
It is clear that if you double the mass of both balls, the number of collisions does not change. Only the ratio matters. This is dual to the slightly less obvious fact that if you repeat the Grover task with more than one correct answer (more than one needle in the haystack), the number of required queries only depends on the ratio of the number of needles, n, to the number of non-needles, d − n, so that # queries = π 4 (d − n)/n .
Galperin's π-calculating plan displays a wanton disregard for engineering practicalities. It requires that we overcome friction, overcome inelasticities, overcome the blurring effects of quantum mechanics, and then having overcome all these things it requires exceptional patience, because even pedestrian initial velocities provoke catastrophic corrections from special relativity. Nevertheless, whatever the shortcomings of billiard balls as tools for calculating π, the results of this paper suggest a tool that is even worse. We might start with a qu(100 N + 1)it, and then step-by-step enact the quantum mirror of Galperin's method, mirroring each velocity with an amplitude, mirroring each billiard collision with a unitary, before ending with a painstaking tomographic reconstruction of the final state and ushering in a new-if-pointless era of quantum arithmetic. It would not be easy, it would not be useful, but it would be a picturesquely quixotic way to seek π in the |ψ .