Education / Quantum Algorithms

Quantum Algorithms · Chapter 06

Quantum Walks

Amplitude amplification composed two reflections into a rotation. The rotation moved a prepared state toward the good answers in about \(1/\sqrt p\) steps, where classical repetition needs \(1/p\), and a lower bound showed that unstructured search can do no better.

Most search problems have structure. A classical algorithm often exploits it by a random walk: wander on a graph, step to random neighbours, and look at where you end up. Its cost is set by how quickly the walk spreads and mixes. What happens if the walker moves in superposition, so that routes to the same vertex carry amplitudes that can cancel or reinforce? Can such a walk find things faster than its classical counterpart?

We first try to make a random walk coherent and find that the walker must carry a coin, and the resulting walk spreads quadratically faster than a random one. To explain that speed we need a walk that flows continuously in time, which requires the exponential of a matrix, and its eigenvectors on a cycle are Fourier modes whose phases advance at fixed speeds. For a general graph the eigenvectors are unknown, so we build a walk from two reflections chosen by a classical Markov chain, as in amplification. Its rotation angles turn a classical spectral gap \(\delta\) into a quantum gap of order \(\sqrt\delta\), and that gives quadratic speedups for search on graphs and an optimal algorithm for element distinctness.

The walk’s rotations come from a matrix of overlaps, and the same mechanism will act on any matrix once we can place it inside a unitary.

How can graph structure organize useful interference?

A quantum walk is amplitude amplification with reflections chosen by a graph: a gap δ becomes √δ.

In this chapter · 4 sections · 11 topics
  1. 6.1 Discrete Walks
    Topics in this section
    1. 6.1.1 Classical random walks
    2. 6.1.2 Coin and shift registers
    3. 6.1.3 Ballistic spreading
  2. 6.2 Continuous Walks
    Topics in this section
    1. 6.2.1 Evolution generated by a graph
    2. 6.2.2 Matrix exponentials through eigenvalues
    3. 6.2.3 Walks on a cycle and Fourier modes
  3. 6.3 Walks from Reflections
    Topics in this section
    1. 6.3.1 Szegedy’s walk
    2. 6.3.2 Phase gap and spectral gap
  4. 6.4 Walk Algorithms
    Topics in this section
    1. 6.4.1 Searching with a walk
    2. 6.4.2 Element distinctness
    3. 6.4.3 Exponential speedups and limits
Reading guide · preparation, aims, and assumptions

Replace random walks by coherent walks, analyze them through their spectra, and use the square-root relation between classical spectral gaps and quantum phase gaps to build search algorithms.

Before you begin

Use reversible arithmetic (Coherent Computation), Fourier states (the chapters from Phase Encoding to Fourier Methods), reflections and amplitude amplification (Amplitude Manipulation), and phase estimation (Fourier Methods).

What you should be able to do

The example to follow

A coined walk on the four-cycle, where three steps send the walker to vertex 3 with certainty, and element distinctness, where storing N^{2/3} values on a Johnson-graph walk gives an optimal O(N^{2/3}) query algorithm.

Scope and assumptions

Walks are ideal and coherent; neighbour access is assumed as an oracle. Query bounds do not include the cost of coherent memory. The glued-trees speedup is an oracle separation for a contrived problem.

6.1

Discrete Walks

What is the simplest coherent version of a random walk? We first recall how a classical walker spreads, and find that replacing its coin flip by a superposition is not unitary. A coin register removes the obstacle and gives a walk on a line or a cycle that we can follow by hand. Run for many steps, that walk spreads quadratically faster than the classical one.

6.1.1 Classical random walks§

random walkdiffusive spreading

How far does a random walker get in \(T\) steps? Start a walker at position \(0\) on the integers. At each step flip a fair coin and move one step left or right. After \(T\) steps the position is a sum of \(T\) independent \(\pm1\) steps, with mean \(0\) and variance \(T\). The typical distance from the start is \(\sqrt T\). This \(\sqrt T\) growth is diffusive spreading, the signature of a classical random walk: to travel distance \(d\) takes about \(d^2\) steps.

On a graph, a random walk moves from a vertex to a uniformly random neighbour. It is described by a transition matrix \(P\), with \(P_{xy}\) the probability of moving from \(x\) to \(y\). If the walker’s distribution is a row vector \(q\), one step gives \(qP\), so \(t\) steps give \(qP^t\).

A random walk on a four-cycleEach step moves to one of the two neighbours with probability 1/2. Probabilities of routes multiply along a route and add across routes; nothing can cancel. After t steps on the line, the spread is about √t. 0 → 1: 1/2; 1 → 2: 1/2; 2 → 3: 1/2; 3 → 0: 1/2A random walk on a four-cycle1/21/21/21/20123each vertex also steps the other way with probability 1/2 (arrows show one direction)
Each step moves to one of the two neighbours with probability 1/2. Probabilities of routes multiply along a route and add across routes; nothing can cancel. After \(t\) steps on the line, the spread is about \(\sqrt t\).

Why not simply make this walk coherent, replacing the coin flip by a superposition of left and right? On the line, the naive map \(\ket x\mapsto\frac{1}{\sqrt2}(\ket{x-1}+\ket{x+1})\) is not unitary. Apply it to \(\ket0\) and \(\ket2\): both images contain \(\ket1\) with amplitude \(\frac{1}{\sqrt2}\), so the images overlap, \(\frac12\neq0\), although \(\ket0\) and \(\ket2\) are orthogonal. A unitary must preserve orthogonality. The walker needs to remember something more than its position.

Problems
  1. After \(T=100\) classical steps, what is the standard deviation of the position, and roughly how likely is the walker to be beyond \(\pm30\)?

    Show solutionHide solution

    The standard deviation is \(\sqrt{100}=10\). Being beyond \(\pm30\) is three standard deviations; for a nearly Gaussian distribution that has probability about \(0.003\).

  2. Write the transition matrix for the random walk on a cycle of four vertices. What is its stationary distribution?

    Show solutionHide solution

    \(P_{x,x\pm1}=\frac12\) (indices modulo 4) and all other entries \(0\). The uniform distribution \((\frac14,\frac14,\frac14,\frac14)\) is stationary since every column also sums to one. (Because 4 is even, the walk alternates between even and odd vertices and does not converge from a single start; a lazy walk fixes that.)

  3. Show that the map \(\ket x\mapsto\frac{1}{\sqrt2}(\ket{x-1}+\ket{x+1})\) on a cycle of \(N=3\) vertices is also not unitary.

    Show solutionHide solution

    The images of \(\ket0\) and \(\ket1\) are \(\frac{1}{\sqrt2}(\ket2+\ket1)\) and \(\frac{1}{\sqrt2}(\ket0+\ket2)\). Their inner product is \(\frac12\), not zero. The map sends orthogonal states to non-orthogonal ones, so it cannot be unitary.

6.1.2 Coin and shift registers§

coined quantum walkcoin registershift operator

Give the walker a direction. Its state is \(\ket{c,x}\), with a coin register \(c\in\{0,1\}\) for left or right and a position register \(x\). One step of the coined quantum walk does two things:

  1. Coin: apply a unitary \(C\) to the coin, for example the Hadamard gate, creating a superposition of directions.
  2. Shift: move according to the coin, \(S\ket{0,x}=\ket{0,x-1}\) and \(S\ket{1,x}=\ket{1,x+1}\).

The shift operator \(S\) is a permutation of the basis states \(\ket{c,x}\), so it is unitary: the coin label tells us which way the walker came, so the move can be undone. The step is \(W=S(C\otimes I)\). The coin is what fixes the obstruction we found for the naive coherent walk: the two contributions to position \(x\) now arrive with different coin labels, \(\ket{1,x}\) from the left and \(\ket{0,x}\) from the right, so the images of different basis states stay orthogonal.

One step of a coined walk on a cycleThe coin qubit is rotated by H; then the position register is decremented if the coin is 0 (open control) and incremented if it is 1 (filled control), modulo N. Each shift box is reversible arithmetic built as in the Coherent Computation chapter. Read each circuit left to right; double lines carry classical measurement records.One step of a coined walk on a cyclecoinposition |x⟩Hx−1x+1W=S(H⊗ I), with S|0,x⟩=|0,x−1⟩ and S|1,x⟩=|1,x+1⟩
The coin qubit is rotated by \(H\); then the position register is decremented if the coin is 0 (open control) and incremented if it is 1 (filled control), modulo \(N\). Each shift box is reversible arithmetic built as in the Coherent Computation chapter.

On a cycle of \(N\) vertices, positions are taken modulo \(N\) and the shift is a controlled increment or decrement, built from the reversible incrementer. Here is a four-cycle starting at \(\ket{0,0}\), with Hadamard coin. One step gives \(\frac{1}{\sqrt2}(\ket{0,3}+\ket{1,1})\). Two steps give

\[\tfrac12\big(\ket{0,2}+\ket{1,0}+\ket{0,0}-\ket{1,2}\big).\]

Figure guide. The figure traces the coined quantum walk on the 4-cycle through its first steps by applying the Hadamard coin and conditional shift. Follow the two signed branches into the third step to see how opposite-sign paths cancel at vertex 1 and reinforce at vertex 3.

What to observe

Apply the Hadamard gate to the coin and shift. The contributions to \(\ket{0,1}\) and \(\ket{1,1}\) cancel exactly, while those to \(\ket{0,3}\) and \(\ket{1,3}\) add: the state is \(\frac{1}{\sqrt2}(\ket{0,3}+\ket{1,3})\). After three steps the walker is at vertex 3 with certainty. A classical walker after three steps is at vertex 1 or 3 with probability \(\frac12\) each.

That deterministic arrival is interference among routes, which classical walks cannot have. It also shows a hazard. Measuring the position after every step would collapse each superposition and turn the quantum walk back into a classical random walk. The walk must run coherently, and only the final position is measured.

Problems
  1. Verify the two-step state of the four-cycle walk from the one-step state.

    Show solutionHide solution

    The Hadamard gate on the coin of \(\frac{1}{\sqrt2}(\ket{0,3}+\ket{1,1})\) gives \(\frac12(\ket{0,3}+\ket{1,3}+\ket{0,1}-\ket{1,1})\). Shifting: \(\ket{0,3}\to\ket{0,2}\), \(\ket{1,3}\to\ket{1,0}\), \(\ket{0,1}\to\ket{0,0}\), \(\ket{1,1}\to\ket{1,2}\). Result: \(\frac12(\ket{0,2}+\ket{1,0}+\ket{0,0}-\ket{1,2})\).

  2. For a walk on a graph where every vertex has degree \(d\), how large must the coin register be?

    Show solutionHide solution

    The coin must label the \(d\) outgoing edges, so it needs dimension \(d\), about \(\log_2d\) qubits. The shift sends \(\ket{c,x}\) to \(\ket{c',y}\), where \(y\) is the neighbour along edge \(c\) and \(c'\) labels the edge back to \(x\); this is a permutation when the edge labels are consistent.

  3. Replace the Hadamard coin by the identity. What does the walk do? By \(X\)?

    Show solutionHide solution

    With the identity coin, the walker keeps its direction and moves ballistically one step per time step, deterministically. With \(X\), it reverses every step and oscillates between two positions. Neither spreads interestingly; the coin must create superpositions of directions for interference to matter.

6.1.3 Ballistic spreading§

ballistic spreading

Run the Hadamard walk on the line for many steps from a symmetric initial coin \(\frac{1}{\sqrt2}(\ket0+i\ket1)\) at position \(0\). The distribution looks nothing like the classical bell curve.

Quantum and classical walks after 60 stepsPosition distributions on the line after T=60 steps (even positions only; odd positions have probability zero). The Hadamard walk (bars) spreads to about ± T/√2 with standard deviation about 0.54T≈32; the classical walk (curve) has standard deviation √T≈7.7. Horizontal axis: position after 60 steps; vertical axis: probability. Quantum and classical walks after 60 steps00.050.10.150.2-60-42-200204260position after 60 stepsprobabilityquantum (Hadamard coin)classical random walk
Position distributions on the line after \(T=60\) steps (even positions only; odd positions have probability zero). The Hadamard walk (bars) spreads to about \(\pm T/\sqrt2\) with standard deviation about \(0.54T\approx32\); the classical walk (curve) has standard deviation \(\sqrt T\approx7.7\).

After \(T=60\) steps the quantum distribution has two sharp peaks near \(\pm T/\sqrt2\approx\pm42\) and is spread almost flat between them; its standard deviation is about \(32.5\approx0.54\,T\). The classical walk has standard deviation \(\sqrt{60}\approx7.7\). The quantum spread grows linearly in \(T\), ballistic spreading, like a particle moving at constant speed, while the classical spread grows like \(\sqrt T\).

Why the difference? No walker moves more than one site per step, so the spread can never exceed \(T\). In the classical walk the steps are independent and partly cancel, like a sum of coin flips, which leaves only \(\sqrt T\). The quantum walker’s amplitudes do not average this way. To see what they do instead, we need the eigenvectors of a walk, which we find for walks on a cycle once we can exponentiate a matrix.

Faster spreading is suggestive but is not an algorithm. An algorithm needs a problem, an input model, and a measurement with a high chance of answering it. The quadratic difference between \(T\) and \(\sqrt T\) does foreshadow a recurring pattern, though: quantum walks often reach their targets in about the square root of the classical time. Turning that pattern into theorems requires stated assumptions about the problem and the access.

Problems
  1. How many steps does a classical walk need for a typical distance of \(100\)? A Hadamard walk?

    Show solutionHide solution

    Classical: \(\sqrt T=100\) gives \(T=10{,}000\). Quantum: \(0.54\,T=100\) gives \(T\approx185\).

  2. Why are the odd positions empty after an even number of steps, in both walks?

    Show solutionHide solution

    Each step changes the position by exactly \(\pm1\), so after \(T\) steps the position has the parity of \(T\). This is a property of the graph (the line is bipartite), not of quantum mechanics.

  3. Starting from coin \(\ket0\) instead of the symmetric coin, the distribution is lopsided. Explain why the Hadamard coin treats the two directions differently.

    Show solutionHide solution

    \(H\) maps \(\ket0\to\frac{1}{\sqrt2}(\ket0+\ket1)\) but \(\ket1\to\frac{1}{\sqrt2}(\ket0-\ket1)\): the minus sign appears only on one direction. Starting in \(\ket0\), interference is constructive for one drift direction and destructive for the other. The symmetric initial coin \(\frac{1}{\sqrt2}(\ket0+i\ket1)\) makes the two contributions add incoherently (they never interfere, because the walk’s dynamics keeps real and imaginary parts separate), producing a symmetric distribution.

6.2

Continuous Walks

A coined walk takes discrete steps, and its behaviour over many steps is hard to read off from the step itself. Can a walk instead flow continuously in time, guided only by the graph’s edges? Asking for such a flow forces the exponential of a matrix, which we compute on a two-vertex graph. Eigenvalues then make every such exponential easy to apply. On a cycle the eigenvectors are Fourier modes, and their phases explain why quantum walks spread at a constant speed. The same exponentials are what quantum simulation must later build from gates.

6.2.1 Evolution generated by a graph§

continuous-time quantum walk

What should a walk that flows continuously look like? Let \(U(t)\) be the operation that runs it for time \(t\). Running for \(s\) and then for \(t\) should equal running for \(s+t\), so \(U(s+t)=U(t)U(s)\) and \(U(0)=I\). Over a very short time \(\delta\), the walker should barely move: \(U(\delta)\approx I+\delta M\), where \(M\) has nonzero entries only along the graph’s edges.

Which \(M\) keep \(U\) unitary? To first order in \(\delta\), \(U(\delta)^\dagger U(\delta)\approx I+\delta(M+M^\dagger)\), so we need \(M^\dagger=-M\). Write \(M=-iH\). Then the condition becomes \(H^\dagger=H\): \(H\) must be Hermitian, equal to its own conjugate transpose. The adjacency matrix of a graph, scaled by a coupling strength \(\gamma\), is real and symmetric, so it qualifies. The factor \(-i\) is what turns a symmetric matrix into a small rotation rather than a stretch.

Now build time \(t\) from \(n\) short steps: \(U(t)=U(t/n)^n\approx(I-iHt/n)^n\). As \(n\) grows this becomes the matrix exponential. A continuous-time quantum walk on a graph with Hermitian \(H\) built from its edges evolves the state by

\[U(t)=e^{-iHt},\]

where the exponential of a matrix is defined by the same power series as for numbers: \(e^{M}=I+M+M^2/2!+M^3/3!+\cdots\). Take two vertices joined by an edge. Their adjacency matrix with coupling \(\gamma\) is \(H=\gamma X\), and for it the series is easy, because \(X^2=I\): even powers of \(X\) are \(I\) and odd powers are \(X\). Grouping terms,

\[e^{-i\gamma tX}=\Big(1-\tfrac{(\gamma t)^2}{2!}+\cdots\Big)I-i\Big(\gamma t-\tfrac{(\gamma t)^3}{3!}+\cdots\Big)X=\cos(\gamma t)\,I-i\sin(\gamma t)\,X.\]

So \(U(t)\ket0=\cos(\gamma t)\ket0-i\sin(\gamma t)\ket1\). The walker moves to the other vertex with probability \(\sin^2(\gamma t)\), completely at \(t=\pi/(2\gamma)\), and then back.

Coherent oscillation versus classical mixingProbability of finding the walker at the second vertex. The quantum walk with H=γ X oscillates as sin²(γ t) and never settles; the classical continuous random walk approaches 1/2 monotonically. Horizontal axis: time γ t; vertical axis: probability at vertex 1. Coherent oscillation versus classical mixing00.510π/2π3π/22πtime γ tprobability at vertex 1quantumclassical
Probability of finding the walker at the second vertex. The quantum walk with \(H=\gamma X\) oscillates as \(\sin^2(\gamma t)\) and never settles; the classical continuous random walk approaches 1/2 monotonically.

Is the result unitary, as the derivation intended? Here we can check directly: \((\cos\gamma t\,I+i\sin\gamma t\,X)(\cos\gamma t\,I-i\sin\gamma t\,X)=(\cos^2\gamma t+\sin^2\gamma t)I=I\), using \(X^2=I\). Notice also that only the product \(\gamma t\) matters. Doubling every coupling halves the time, so “time” alone is not a cost. The cost of simulating a walk on a quantum computer grows with \(\|H\|t\), where \(\|H\|\) is the operator norm.

Problems
  1. At \(t=\pi/(4\gamma)\), what is the two-vertex state, and what are the probabilities?

    Show solutionHide solution

    \(\frac{1}{\sqrt2}(\ket0-i\ket1)\). Each vertex has probability \(\frac12\); the relative phase \(-i\) matters for what happens next.

  2. Check that \(U(t)=\cos(\gamma t)I-i\sin(\gamma t)X\) is unitary by computing \(U(t)^\dagger U(t)\).

    Show solutionHide solution

    \(U^\dagger=\cos(\gamma t)I+i\sin(\gamma t)X\). The product is \[\cos^2I+i\cos\sin X-i\sin\cos X+\sin^2X^2=(\cos^2+\sin^2)I=I\].

  3. For the classical continuous walk on two vertices, the probability of being at vertex 1 is \(\frac12(1-e^{-2t})\). Contrast its long-time behavior with the quantum walk’s.

    Show solutionHide solution

    The classical probability rises monotonically to \(\frac12\) and stays: it mixes to the uniform distribution. The quantum probability \(\sin^2(\gamma t)\) oscillates between \(0\) and \(1\) forever: unitary evolution never forgets its initial state, so it does not converge. Quantum walk algorithms therefore choose a stopping time, or average over random times.

6.2.2 Matrix exponentials through eigenvalues§

Hamiltonianspectral decompositionground stateenergy gap

For larger graphs the power series is not summed so easily. Can eigenvalues do the work? If \(H\ket{v_j}=\lambda_j\ket{v_j}\), then every power acts on \(\ket{v_j}\) by \(\lambda_j^k\), so the series acts by the ordinary exponential:

\[e^{-iHt}\ket{v_j}=e^{-i\lambda_jt}\ket{v_j}.\]

The eigenvalues of a Hermitian matrix are real. Indeed, if \(H\ket v=\lambda\ket v\) with \(\braket vv=1\), then \(\lambda=\bra vH\ket v\), and conjugating gives \(\lambda^*=\bra vH^\dagger\ket v=\lambda\). As for unitaries, the spectral theorem, which we assume, provides an orthonormal basis of eigenvectors. Together these give the spectral decomposition \(H=\sum_j\lambda_j\ket{v_j}\bra{v_j}\). To evolve any state, expand it in eigenvectors, multiply each coefficient by its own phase \(e^{-i\lambda_jt}\), and recombine. Each phase has magnitude one because \(\lambda_j\) is real, so \(e^{-iHt}\) sends an orthonormal basis to an orthonormal basis: it is unitary for every Hermitian \(H\).

In physics a Hermitian generator of evolution is called a Hamiltonian, and its eigenvalues are energies. The eigenvector with the smallest eigenvalue is the ground state, and the difference between the two smallest eigenvalues is the energy gap. We will use these names whenever a Hermitian matrix plays this role.

Check on the two-vertex graph. \(X\) has eigenvectors \(\ket+\) (eigenvalue \(1\)) and \(\ket-\) (eigenvalue \(-1\)). So \[e^{-i\gamma tX}\ket0=\frac{1}{\sqrt2}(e^{-i\gamma t}\ket++e^{i\gamma t}\ket-)=\cos(\gamma t)\ket0-i\sin(\gamma t)\ket1\], as before.

Evolving through eigenvectorsFor H=γ X, expand |0⟩ in eigenvectors, give each its phase e^(−iλ t), and recombine. Motion comes from the difference between the two phases. Columns: Eigenvector, Eigenvalue, Coefficient in |0⟩, Coefficient at time t. |+⟩, γ, 1/√2, e^(−iγ t)/√2; |−⟩, −γ, 1/√2, e^(iγ t)/√2; result, , |0⟩, cosγ t |0⟩−isinγ t |1⟩Evolving through eigenvectorsEigenvectorEigenvalueCoefficient in|0⟩Coefficient attime t|+⟩γ1/√2e^(−iγ t)/√2|−⟩−γ1/√2e^(iγ t)/√2result|0⟩cosγ t |0⟩−isinγ t |1⟩
For \(H=\gamma X\), expand \(\ket0\) in eigenvectors, give each its phase \(e^{-i\lambda t}\), and recombine. Motion comes from the difference between the two phases.

This picture explains what a continuous walk does: each eigenvector rotates its phase at a rate given by its eigenvalue, and interference among them produces the motion. Differences between eigenvalues set the timescales. The largest eigenvalue magnitude, \(\|H\|\), sets the fastest timescale, which is why it controls simulation cost. And it is the same picture as phase estimation: running phase estimation on \(e^{-iHt}\) samples the eigenvalues \(\lambda_j\), weighted by the squared overlaps of the initial state.

Problems
  1. Find the eigenvalues and eigenvectors of \(H=Z\), and write \(e^{-iZt}\) as a matrix.

    Show solutionHide solution

    Eigenvectors \(\ket0\), \(\ket1\) with eigenvalues \(1\), \(-1\). So \(e^{-iZt}=\mathrm{diag}(e^{-it},e^{it})\).

  2. The path graph on three vertices has adjacency matrix with eigenvalues \(\sqrt2,0,-\sqrt2\). With \(\gamma=1\), what is the shortest time at which every eigenvector phase returns to its starting value, up to a common phase?

    Show solutionHide solution

    The phases are \(e^{-i\sqrt2t},1,e^{i\sqrt2t}\). They agree up to a common factor exactly when every difference of exponents, here \(\sqrt2t\), is a multiple of \(2\pi\). The first such time is \(t=2\pi/\sqrt2=\sqrt2\pi\). At that time the walk returns exactly to its initial state.

  3. Why does the spectral decomposition not give an efficient quantum algorithm for computing \(e^{-iHt}\) directly?

    Show solutionHide solution

    Diagonalizing \(H\) requires finding all its eigenvalues and eigenvectors, which for a \(2^n\)-dimensional matrix costs exponential classical time, and a circuit implementing the change to the eigenbasis is generally not efficient either. The decomposition is a tool for understanding; efficient simulation uses structure such as sums of simple terms.

6.2.3 Walks on a cycle and Fourier modes§

Fourier mode

Which graphs have eigenvectors we can write down? On a cycle of \(N\) vertices, the adjacency matrix \(A\) sends \(\ket x\) to \(\ket{x-1}+\ket{x+1}\). The cycle looks the same from every vertex, and the Fourier transform turns a shift into a phase, so we try Fourier states. Let \(\ket{\tilde k}=\frac{1}{\sqrt N}\sum_x\omega^{kx}\ket x\), with \(\omega=e^{2\pi i/N}\). Then

\[A\ket{\tilde k}=\frac{1}{\sqrt N}\sum_x\omega^{kx}(\ket{x-1}+\ket{x+1})=(\omega^{k}+\omega^{-k})\ket{\tilde k}=2\cos\!\left(\frac{2\pi k}{N}\right)\ket{\tilde k}.\]

Each Fourier mode is an eigenvector, with eigenvalue \(2\cos(2\pi k/N)\). The continuous walk on the cycle is therefore: Fourier transform, apply phases \(e^{-2i\gamma t\cos(2\pi k/N)}\), inverse Fourier transform. The quantum Fourier transform implements the change of basis efficiently, so for the cycle, and for other graphs with this kind of symmetry, the walk can be simulated exactly with \(O(n^2)\) gates.

Eigenvalues of a cycle are cosinesThe adjacency matrix of a cycle of N=12 vertices has Fourier modes as eigenvectors, with eigenvalues 2cos(2π k/N) (bars). The curve shows the continuous dispersion relation; its slope sets the speed of a wave packet. Horizontal axis: mode k; vertical axis: eigenvalue. Eigenvalues of a cycle are cosines-2-1012036912mode keigenvalue
The adjacency matrix of a cycle of \(N=12\) vertices has Fourier modes as eigenvectors, with eigenvalues \(2\cos(2\pi k/N)\) (bars). The curve shows the continuous dispersion relation; its slope sets the speed of a wave packet.

Now we can answer why quantum walks spread linearly in time. Take the walk \(e^{-i\gamma At}\), so mode \(k\) has eigenvalue \(\lambda(k)=2\gamma\cos(2\pi k/N)\), and suppose the initial state is built from modes with \(k\) close to some \(k_0\). Write \(\kappa=2\pi k/N\), so that mode \(k\) has amplitude proportional to \(e^{i\kappa x}\) at vertex \(x\). After time \(t\) it carries the extra phase \(e^{-i\lambda t}\). For \(\kappa\) near \(\kappa_0\), \(\lambda\approx\lambda_0+v(\kappa-\kappa_0)\), where \(v\) is the slope of \(\lambda\) as a function of \(\kappa\). Then

\[e^{i\kappa x}e^{-i\lambda t}\approx e^{i(\kappa_0x-\lambda_0t)}\;e^{i(\kappa-\kappa_0)(x-vt)}.\]

The first factor is common to all the modes. The second depends on \(x\) only through \(x-vt\), so the whole superposition is its initial shape moved a distance \(vt\). It travels at constant speed

\[v=\frac{d}{d\kappa}\,2\gamma\cos\kappa=-2\gamma\sin\kappa_0,\]

which ranges between \(-2\gamma\) and \(2\gamma\). A state built from many modes contains parts moving at all these speeds, so its width grows in proportion to \(t\). A classical walker has no phases to keep its moves aligned, and its width grows only like \(\sqrt t\). The coined Hadamard walk has eigenphases that depend on \(\kappa\) in a similar way; the same calculation, which we do not repeat, gives a largest speed of \(1/\sqrt2\) sites per step, matching the peaks near \(\pm T/\sqrt2\).

The cycle is special because its symmetry makes the eigenvectors known. For a general graph the eigenvectors are unknown, and a walk is implemented step by step from local access to the graph: given a vertex, list its neighbours. How can a walk be built from that local access alone?

Problems
  1. For \(N=4\), list the eigenvalues of the cycle’s adjacency matrix.

    Show solutionHide solution

    \(2\cos(2\pi k/4)\) for \(k=0,1,2,3\): \(2,0,-2,0\).

  2. Which Fourier mode of the cycle is unchanged (up to a phase) by both the walk and a measurement of position probabilities? Explain.

    Show solutionHide solution

    Every Fourier mode is an eigenvector, so the walk only multiplies it by a phase. Each mode also has uniform position probabilities \(1/N\). Starting in any single Fourier mode, the position distribution stays uniform forever: the walk does nothing visible. Motion comes from superpositions of modes with different eigenvalues.

  3. Why can the continuous walk on a cycle of \(2^n\) vertices be simulated exactly with \(O(n^2)\) gates, while the walk on an arbitrary graph of \(2^n\) vertices generally cannot?

    Show solutionHide solution

    For the cycle, the eigenbasis is the Fourier basis, implemented by the QFT in \(O(n^2)\) gates, and the eigenvalue phases are a computable function of \(k\), applied by phase arithmetic. For an arbitrary graph the eigenbasis has no known efficient circuit. Efficient simulation then relies on sparsity and local access, with approximation error.

6.3

Walks from Reflections

Amplitude amplification composed two reflections and rotated by an angle set by an overlap. Can a walk on a general graph be built the same way, using only local access? We choose the reflections from the transition probabilities of a classical Markov chain. Their product rotates in many planes at once, with angles set by the chain’s eigenvalues. Comparing those angles with the classical rate of mixing shows where the quadratic speedups of walk algorithms come from.

6.3.1 Szegedy’s walk§

Szegedy walkMarkov chain

How do we turn a classical chain into a pair of reflections? Let \(P\) be the transition matrix of a Markov chain, a walk whose next step depends only on its current vertex, on vertices \(x\in\{1,\ldots,N\}\). Work on pairs \(\ket x\ket y\), thought of as directed edges. For each \(x\), define the state that spreads from \(x\) according to \(P\):

\[\ket{\psi_x}=\ket x\otimes\sum_y\sqrt{P_{xy}}\,\ket y.\]

The states \(\ket{\psi_x}\) are orthonormal, since they have different first registers. Let \(R_A=2\sum_x\ket{\psi_x}\bra{\psi_x}-I\) be the reflection about their span, and define \(R_B\) the same way with the roles of the two registers exchanged (spreading from \(y\) back to \(x\)). The Szegedy walk is the product

\[W=R_BR_A.\]

Each reflection is built like the reflection about a prepared state: a circuit \(V\) with \(V\ket x\ket0=\ket{\psi_x}\), a reflection about \(\ket0\) on the second register, and \(V^\dagger\). So one walk step needs a coherent procedure that, given \(x\), prepares the superposition of its neighbours weighted by \(\sqrt{P_{xy}}\). For a graph given by neighbour lists, that is a coherent neighbour query plus a uniform superposition over the degree.

One step of Szegedy’s walkV|x⟩|0⟩=|x⟩Σ_y√(P_(xy))|y⟩. The first three boxes reflect about the span of the states |ψ_x⟩ (R_A); swapping the registers and repeating gives R_B. Each V needs coherent access to the neighbours of a vertex. Read each circuit left to right; double lines carry classical measurement records.One step of Szegedy’s walkR_AR_B|x⟩|y⟩V†S₀VV†S₀V
\(V\ket x\ket0=\ket x\sum_y\sqrt{P_{xy}}\ket y\). The first three boxes reflect about the span of the states \(\ket{\psi_x}\) (\(R_A\)); swapping the registers and repeating gives \(R_B\). Each \(V\) needs coherent access to the neighbours of a vertex.

Why two reflections? Start with the smallest case: one state \(\ket a\) from the first family and one state \(\ket b\) from the second, with real overlap \(\braket ab=\cos\theta\). In the plane they span, \(2\ket a\bra a-I\) reflects across the line through \(\ket a\), and \(2\ket b\bra b-I\) across the line through \(\ket b\). The two lines meet at angle \(\theta\), and we saw with the Grover iterate that two such reflections compose to a rotation by \(2\theta\). Outside the plane both act as \(-I\), so their product is the identity there.

With many states in each family the planes might seem to tangle. A linear-algebra result we quote, Jordan’s lemma, says they do not: the space splits into planes that both reflections preserve, plus pieces on which the product is simply \(\pm I\). The angles of the planes are set by the overlaps between the two families,

\[\braket{\psi_x}{\phi_y}=\sqrt{P_{xy}P_{yx}}=D_{xy},\]

where \(\ket{\phi_y}=\sum_x\sqrt{P_{yx}}\ket x\otimes\ket y\) are the states of the second family. For a symmetric chain \(D=P\). Szegedy’s construction (Szegedy, 2004) thus turns a classical chain into a quantum walk whose rotation angles are determined by the chain’s spectrum.

Problems
  1. For the walk on a complete graph of 3 vertices (move to each other vertex with probability \(\frac12\)), write \(\ket{\psi_1}\).

    Show solutionHide solution

    \(\ket{\psi_1}=\ket1\otimes\frac{1}{\sqrt2}(\ket2+\ket3)\).

  2. Show that \(\braket{\psi_x}{\psi_{x'}}=0\) for \(x\neq x'\) and \(1\) for \(x=x'\).

    Show solutionHide solution

    The first registers are \(\ket x\) and \(\ket{x'}\), orthogonal when \(x\ne x'\). For \(x=x'\), the norm is \(\sum_yP_{xy}=1\), since each row of a transition matrix sums to one.

  3. Why does a graph given as a classical adjacency list of \(N\) vertices not automatically give an efficient walk step?

    Show solutionHide solution

    A step needs the circuit \(V\) that prepares \(\sum_y\sqrt{P_{xy}}\ket y\) coherently for a superposition of \(x\). With a classical list in ordinary memory, this requires coherent access to the list (a quantum RAM or a data-loading circuit), whose cost must be counted. When the graph is implicit, defined by a rule computable from \(x\), the step is efficient. Query bounds for walks assume such coherent neighbour access.

6.3.2 Phase gap and spectral gap§

spectral gapphase gapstationary distributionmixing time

How fast does the classical chain forget where it started? Take a symmetric chain. Its rows and its columns sum to one, so the uniform distribution \(\pi\) satisfies \(\pi P=\pi\). A distribution left unchanged by a step is a stationary distribution. A symmetric \(P\) has real eigenvalues and orthonormal eigenvectors \(w_j\), with \(w_1\) proportional to \(\pi\) and eigenvalue \(\lambda_1=1\). Order the rest by magnitude, \(1\ge|\lambda_2|\ge|\lambda_3|\ge\cdots\). Expanding a starting distribution \(q_0=\sum_jc_jw_j\) gives

\[q_0P^t=\pi+\sum_{j\ge2}c_j\lambda_j^tw_j,\]

since \(c_1w_1=\pi\) for any distribution. Every other term shrinks at least as fast as \(|\lambda_2|^t\). The spectral gap is \(\delta=1-|\lambda_2|\), so the distance from stationarity falls like \((1-\delta)^t\le e^{-\delta t}\). The mixing time, the number of steps until the distribution is close to \(\pi\), is therefore of order \(1/\delta\), up to a logarithm of the required accuracy.

What are the walk’s rotation angles? Szegedy’s theorem, which we quote, completes the two-state picture. Each eigenvalue \(\lambda=\cos\theta\) of \(D\) gives a two-dimensional invariant plane on which \(W\) acts as a rotation by \(2\theta\), with eigenvalues \(e^{\pm2i\theta}\). The eigenvalue \(\lambda_1=1\) gives \(\theta=0\): a stationary state of the walk, unchanged by \(W\). The next eigenvalue \(\lambda_2=1-\delta\) gives \(\cos\theta=1-\delta\), so

\[\theta\approx\sqrt{2\delta}\quad\text{for small }\delta,\]

using \(\cos\theta\approx1-\theta^2/2\). The phase gap, the smallest nonzero eigenphase of \(W\), is \(2\theta\ge2\sqrt\delta\). A gap of \(\delta\) in the classical chain becomes a gap of order \(\sqrt\delta\) in the walk.

A spectral gap becomes a larger phase gapFor a classical gap delta, the walk’s phase gap is 2arccos(1−delta) (solid), at least 2√delta (dashed). For small delta the phase gap is much larger than delta itself (dotted), which is why phase estimation can detect it in order 1/√delta steps. Horizontal axis: classical spectral gap delta; vertical axis: gap. A spectral gap becomes a larger phase gap00.250.50.75100.0250.050.0750.1classical spectral gap deltagapphase gap2√deltadelta
For a classical gap \(\delta\), the walk’s phase gap is \(2\arccos(1-\delta)\) (solid), at least \(2\sqrt\delta\) (dashed). For small \(\delta\) the phase gap is much larger than \(\delta\) itself (dotted), which is why phase estimation can detect it in order \(1/\sqrt\delta\) steps.

This square root is the source of the speedup. Phase estimation distinguishes the stationary eigenphase \(0\) from all others with precision of order \(\sqrt\delta\), which costs order \(1/\sqrt\delta\) walk steps, against \(1/\delta\) classical steps. Amplitude amplification had the same structure. There the rotation angle satisfied \(\sin\theta=\sqrt p\), so a small probability \(p\) gave an angle of order \(\sqrt p\). Here \(\cos\theta=1-\delta\), so a small gap \(\delta\) gives an angle of order \(\sqrt\delta\). In both, the number of rotations needed is one over the angle.

Problems
  1. A chain has \(\lambda_2=0.99\). Compare the classical \(1/\delta\) with the quantum \(1/\sqrt\delta\).

    Show solutionHide solution

    \(\delta=0.01\). Classical: about \(100\) steps. Quantum: about \(10\) walk steps (phase gap \(\ge0.2\) radians).

  2. Compute the phase gap exactly for \(\lambda_2=0.5\).

    Show solutionHide solution

    \(\cos\theta=0.5\) gives \(\theta=\pi/3\), so the phase gap is \(2\pi/3\approx2.09\). The approximation \(2\sqrt{2\delta}=2\) is close; the lower bound \(2\sqrt\delta\approx1.41\) holds.

  3. Does a quadratically larger phase gap mean the quantum walk mixes to the uniform distribution quadratically faster?

    Show solutionHide solution

    Not directly. A unitary walk never converges to a stationary distribution; its state oscillates. What the phase gap gives is the ability to detect or prepare the stationary state with phase estimation in order \(1/\sqrt\delta\) steps, given a starting state that overlaps it. Quantum speedups for sampling from the stationary distribution exist under extra conditions, but “mixes faster” must be defined carefully.

6.4

Walk Algorithms

We now have walks whose spectra are tied to classical chains. How quickly can such a walk find a marked vertex? Combining the walk with amplification gives a general quadratic speedup for search on graphs. Choosing a graph whose steps reuse earlier work then gives an optimal algorithm for element distinctness. Finally we ask whether walks ever do better than quadratic, and what limits all of these results.

6.4.1 Searching with a walk§

walk searchhitting time

Suppose a fraction \(\varepsilon\) of the vertices of a graph are marked, and the classical walk has spectral gap \(\delta\). Classically, a simple strategy is: walk for order \(1/\delta\) steps to reach a nearly random vertex, check whether it is marked, and repeat about \(1/\varepsilon\) times. Total cost about \(\frac1\varepsilon\cdot\frac1\delta\) walk steps. This bounds the hitting time, the expected number of steps until the walker first reaches a marked vertex.

The quantum version replaces both loops by their square roots. The framework of Magniez, Nayak, Roland, and Santha (2007) performs amplitude amplification in which the reflection about the stationary state of the walk is implemented by phase estimation on \(W\), distinguishing phase \(0\) from phases at least \(2\sqrt\delta\). With setup cost \(\mathsf S\) (prepare the stationary state), update cost \(\mathsf U\) (one walk step), and checking cost \(\mathsf C\) (test whether a vertex is marked), walk search finds a marked vertex at cost

\[\mathsf S+\frac{1}{\sqrt\varepsilon}\left(\frac{1}{\sqrt\delta}\,\mathsf U+\mathsf C\right).\]

Compare classical \(\mathsf S+\frac1\varepsilon\big(\frac1\delta\mathsf U+\mathsf C\big)\). Both factors are square-rooted.

Classical and quantum walk searchCosts in walk steps and checks, with setup omitted. ε is the marked fraction and delta the spectral gap. The quantum framework square-roots both factors. Columns: Graph, delta, ε, Classical, Quantum. Complete graph, 1 marked, ≈1, 1/N, N, √N (Grover); 2D grid, 1 marked, ≈1/N, 1/N, Nlog N (hitting), √Nlog N; General, delta, ε, 1/ε(1/deltaU+C), 1/√ε(1/√deltaU+C)Classical and quantum walk searchGraphdeltaεClassicalQuantumCompletegraph, 1marked≈11/NN√N (Grover)2D grid, 1marked≈1/N1/NNlog N(hitting)√Nlog NGeneraldeltaε1/ε(1/deltaU+C)1/√ε(1/√deltaU+C)
Costs in walk steps and checks, with setup omitted. \(\varepsilon\) is the marked fraction and \(\delta\) the spectral gap. The quantum framework square-roots both factors.

On the complete graph, a random step already lands on a random vertex: \(\delta\approx1\), and with one marked item, \(\varepsilon=1/N\). The formula gives \(O(\sqrt N)\), and the walk reduces to Grover search. The value of the framework is on graphs where \(\delta\) is small but steps are cheap and reuse previous work, which is exactly the situation in element distinctness. On a two-dimensional grid of \(N\) vertices, walk search finds a marked vertex in \(O(\sqrt N\log N)\) steps (Ambainis, Kempe, and Rivosh, 2005), whereas a classical walk on the grid needs order \(N\log N\).

Problems
  1. A graph has \(\delta=10^{-2}\) and \(\varepsilon=10^{-4}\), with \(\mathsf U=\mathsf C=1\). Compare the classical and quantum costs (ignoring setup).

    Show solutionHide solution

    Classical: \(10^4(100+1)\approx10^6\). Quantum: \(10^2(10+1)\approx1.1\times10^3\).

  2. Show that the formula reproduces Grover’s \(O(\sqrt N)\) for the complete graph with one marked vertex.

    Show solutionHide solution

    \(\delta\) is a constant (close to 1), \(\varepsilon=1/N\), and with \(\mathsf U,\mathsf C=O(1)\) and cheap setup (a uniform superposition), the cost is \(\sqrt N\,(O(1)+O(1))=O(\sqrt N)\).

  3. Why does the framework need the marked set to be checkable by a coherent procedure \(\mathsf C\), not just recognizable after measurement?

    Show solutionHide solution

    The checking step is used inside amplitude amplification as the reflection \(S_G\), applied coherently to a superposition of vertices. A check that works only on measured classical vertices would collapse the superposition and lose the quadratic gain in \(1/\varepsilon\).

6.4.2 Element distinctness§

element distinctnessJohnson graph

Can a walk beat Grover search on a problem with structure? Given oracle access to a list \(T(1),\ldots,T(N)\), decide whether two entries are equal. This is element distinctness. Classically it needs order \(N\) queries. Grover search over all pairs needs \(\sqrt{N^2}=N\) queries, no better. Ambainis found an algorithm with \(O(N^{2/3})\) queries (Ambainis, 2004), and a matching lower bound of \(\Omega(N^{2/3})\) is known.

The walk is on the Johnson graph: vertices are subsets \(S\) of \(\{1,\ldots,N\}\) of size \(r\), and two subsets are adjacent if they differ in one element. Each vertex stores the queried values \(T(i)\) for \(i\in S\). A vertex is marked if its subset contains a colliding pair. What does each part of the walk-search cost formula become?

Setting up means querying \(r\) values, so \(\mathsf S=r\). An update swaps one element out of the subset and one in. That needs \(O(1)\) queries, because the other \(r-1\) stored values are reused, so \(\mathsf U=O(1)\). Checking costs nothing: the stored values already reveal any collision, so \(\mathsf C=0\).

How many vertices are marked? If one colliding pair exists, a random \(r\)-subset contains both of its elements with probability about \((r/N)^2\), so \(\varepsilon\approx r^2/N^2\). How fast does the walk mix? Each step replaces one of the \(r\) elements. After about \(r\) steps most of the original elements have been replaced, so the walk has forgotten its start, which suggests \(\delta\approx1/r\). The exact value, which we quote from the known spectrum of the Johnson graph, is \(\delta=N/\big(r(N-r)\big)\), close to \(1/r\) when \(r\ll N\).

Substituting into the walk-search cost, the total is

\[r+\frac{N}{r}\Big(\sqrt r\cdot O(1)+0\Big)=r+\frac{N}{\sqrt r}.\]

Balancing the two terms with \(r=N^{2/3}\) gives \(O(N^{2/3})\) queries.

Element distinctness on the Johnson graphVertices are r-subsets with their stored values. Choosing r=N^(2/3) balances setup against search and gives O(N^(2/3)) queries, which is optimal. The algorithm stores r values in coherent memory. Columns: Parameter, Value, Reason. Setup S, r queries, query every element of the first subset; Update U, O(1) queries, swap one element, reuse the rest; Check C, 0 queries, stored values reveal a collision; Marked fraction ε, ≈ r²/N², subset must contain both colliding indices; Spectral gap delta, ≈1/r, property of the Johnson graph; Total, r+N/√r, minimized at r=N^(2/3)Element distinctness on the Johnson graphParameterValueReasonSetup Sr queriesquery every element ofthe first subsetUpdate UO(1) queriesswap one element, reusethe restCheck C0 queriesstored values reveal acollisionMarked fraction ε≈ r²/N²subset must contain bothcolliding indicesSpectral gap delta≈1/rproperty of the JohnsongraphTotalr+N/√rminimized at r=N^(2/3)
Vertices are \(r\)-subsets with their stored values. Choosing \(r=N^{2/3}\) balances setup against search and gives \(O(N^{2/3})\) queries, which is optimal. The algorithm stores \(r\) values in coherent memory.

The insight is reuse. Grover over pairs pays one query per check and finds nothing between checks. The walk keeps a large set of values in memory and changes it a little at a time, so each step is cheap and checking is free. The price is space: the algorithm stores \(r=N^{2/3}\) values coherently, and its gate count includes data-structure operations on that memory. The query count is optimal; the time and space costs depend on how that coherent memory is implemented.

Problems
  1. For \(N=10^6\), compare \(N\), \(N^{2/3}\), and the subset size \(r\).

    Show solutionHide solution

    \(N=10^6\) classical queries; \(N^{2/3}=10^4\) quantum queries; the algorithm stores \(r=10^4\) values in coherent memory.

  2. What happens to the cost if we choose \(r=\sqrt N\)? If \(r=N\)?

    Show solutionHide solution

    \(r=\sqrt N\): \(\sqrt N+N/N^{1/4}=O(N^{3/4})\), worse. \(r=N\): setup alone costs \(N\). The optimum balances setup against search.

  3. Why does checking cost zero queries, and what does it cost in gates?

    Show solutionHide solution

    The values \(T(i)\), \(i\in S\), are already stored, so no new queries are needed to see whether two are equal. But a coherent check compares stored values, which needs a data structure (for example, sorted storage or a hash table) supporting collision detection and efficient updates. Its gate cost is polylogarithmic per operation with careful design, but it is not zero, and the space is \(N^{2/3}\) words.

6.4.3 Exponential speedups and limits§

glued trees

Can a walk ever give more than a polynomial speedup? On one specially built problem, yes. In the glued trees problem, two binary trees of depth \(n\) are joined at their leaves by a random cycle, and we are given an oracle that returns the neighbours of a vertex, with vertices labelled by random strings. Starting at one root, find the other. A classical algorithm gets lost in the exponentially many middle vertices and provably needs exponentially many queries. A continuous-time quantum walk, viewed in a basis of “column” states that group vertices by distance from the root, behaves like a walk on a line of length \(2n\) and reaches the far root in polynomial time (Childs et al., 2003).

What quantum walks achieveQuery complexities with coherent neighbour access. Time complexity adds the cost of implementing that access and any coherent data structures. Columns: Problem, Classical, Quantum walk. Search, complete graph, N, √N; Search, 2D grid, Nlog N, √Nlog N; Element distinctness, N, N^(2/3), optimal; Glued trees traversal, exponential, polynomial; General Markov chain hitting, 1/(εdelta), 1/√εdeltaWhat quantum walks achieveProblemClassicalQuantum walkSearch, complete graphN√NSearch, 2D gridNlog N√Nlog NElement distinctnessNN^(2/3), optimalGlued trees traversalexponentialpolynomialGeneral Markov chainhitting1/(εdelta)1/√εdelta
Query complexities with coherent neighbour access. Time complexity adds the cost of implementing that access and any coherent data structures.

The glued-trees result is an oracle separation for a contrived problem; it has no known practical application. It shows that walks can exploit global structure, the symmetry of the graph, in a way classical exploration cannot.

The limits are as important as the results. Walk algorithms are stated in query models with coherent neighbour access. Their time complexity includes the cost of implementing that access, the coherent data structures, and the precision of phase estimation inside the framework. A spectral gap must be known or bounded to set parameters. And on graphs that are classically easy to search, a walk cannot do better than a quadratic improvement in general.

The walk operator \(W\) has an eigenvalue structure tied to a matrix \(D\) through \(\lambda=\cos\theta\). The same relation will hold for any matrix placed inside a unitary, provided we can place a matrix that is not unitary inside a unitary at all.

Problems
  1. Why do the glued trees defeat a classical algorithm that remembers every vertex it has visited?

    Show solutionHide solution

    The vertex labels are random, so the algorithm cannot tell from a label how far it is from either root. Near the middle there are about \(2^n\) vertices, and a classical walk or search drifts among them; any classical algorithm needs exponentially many queries to find the exit with non-negligible probability. Remembering visited vertices does not tell it which direction leads onward.

  2. In the column basis, the walk behaves like a walk on a line of \(2n+2\) sites. Why does that give polynomial time?

    Show solutionHide solution

    A continuous walk on a line of length \(O(n)\) spreads ballistically, reaching the far end in time \(O(n)\) with probability at least inverse polynomial in \(n\) (the middle defect from the random cycle scatters only part of the amplitude). Simulating it for time \(O(n)\) with neighbour queries costs polynomially many queries.

  3. A claim states that a quantum walk solves a graph search problem “in \(O(\sqrt N)\) time.” What should you check?

    Show solutionHide solution

    Whether \(O(\sqrt N)\) counts queries, walk steps, or gates; how neighbour access and the stationary-state preparation are implemented and costed; whether the spectral gap and the marked fraction were assumed or bounded; the success probability; and what the best classical algorithm for that specific graph achieves, since for some graphs classical algorithms already do well.

Summary

Questions and worked problems

Attempt each question before opening a hint. Explain your reasoning, then compare it with the solution.

1. Quick check §

For the coined Hadamard walk on the line starting at |0, 0⟩, compute the state after two steps and the position probabilities.

Hint 1

One step gives (|0, −1⟩ + |1, 1⟩)/√2.

Hint 2

Apply H to each coin, then shift.

Worked solution

After the coin on the one-step state: ½(|0,−1⟩ + |1,−1⟩ + |0,1⟩ − |1,1⟩). Shifting: ½(|0,−2⟩ + |1,0⟩ + |0,0⟩ − |1,2⟩). Positions −2, 0, 2 have probabilities 1/4, 1/2, 1/4, the same as classically. Differences from the classical walk appear from the third step on.

Revisit the relevant explanation

2. Quick check §

For the continuous walk on two vertices with \(H=X\) (\(\gamma=1\)), starting at vertex \(0\), find the first time at which the probability of vertex \(1\) equals \(3/4\). Can the classical continuous walk, with probability \(\frac12(1-e^{-2t})\), ever reach \(3/4\)?

Hint 1

The quantum probability is \(\sin^2t\).

Hint 2

The classical probability increases toward a limit.

Worked solution

The quantum probability is \(\sin^2t\), which equals \(3/4\) first at \(t=\pi/3\) (\(\sin(\pi/3)=\sqrt3/2\)). It reaches \(1\) at \(t=\pi/2\) and then oscillates back. The classical probability \(\frac12(1-e^{-2t})\) increases monotonically toward \(1/2\) and never exceeds it. The classical walk forgets its starting point and settles into the stationary distribution. The quantum walk is unitary, keeps oscillating, and has no stationary limit, so “run it long enough” is not a strategy. Quantum walk algorithms must choose their running time or randomize it.

Revisit the relevant explanation

3. Quick check §

List the eigenvalues of the adjacency matrix of the six-cycle, and of the simple random walk \(P=A/2\) on it. Why does this classical walk never converge to the uniform distribution from a single starting vertex, and how does a lazy walk \(P'=\frac12(I+P)\) fix it?

Hint 1

The eigenvalues are \(2\cos(2\pi k/6)\) for \(k=0,\dots,5\).

Hint 2

An eigenvalue \(-1\) of \(P\) corresponds to a pattern that alternates sign at every step.

Worked solution

The adjacency eigenvalues are \(2,1,-1,-2,-1,1\), so \(P\) has eigenvalues \(1,\frac12,-\frac12,-1,-\frac12,\frac12\). The eigenvalue \(-1\) comes from the alternating mode \(k=3\). The six-cycle is bipartite: from vertex \(0\) the walker is on even vertices after even steps and odd vertices after odd steps, so the distribution oscillates forever. The second-largest absolute eigenvalue is \(1\), so the gap is zero. The lazy walk has eigenvalues \(\frac12(1+\lambda)\in\{1,\frac34,\frac14,0\}\), all nonnegative, with gap \(\delta=1/4\). Staying put half the time costs a factor of two in speed and removes the oscillation.

Revisit the relevant explanation

4. Worked problem §

The continuous walk on a cycle of N = 4 vertices with γ = 1 starts at vertex 0. Using Fourier modes, find the amplitude at vertex 2 at time t.

Hint 1

The eigenvalues are 2, 0, −2, 0 for k = 0, 1, 2, 3.

Hint 2

|0⟩ = ½ Σ_k |k̃⟩, and ⟨2|k̃⟩ = ½ (−1)^k.

Worked solution

The amplitude is ¼ Σ_k (−1)^k e^{−iλ_k t} = ¼(e^{−2it} − 1 + e^{2it} − 1) = ½(cos 2t − 1) = −sin² t. So the probability at vertex 2 is sin⁴ t, reaching 1 at t = π/2: the walker transfers perfectly to the opposite vertex.

Revisit the relevant explanation

5. Worked problem §

Run the Hadamard walk on the line for three steps from \(\ket{0,0}\), where coin \(0\) moves left. Find the position distribution and compare it with the classical walk. Compute \(\mathbb E[x^2]\) for both. What does the comparison say about using small examples to judge spreading speed?

Hint 1

The two-step state is \(\frac12(\ket{0,-2}+\ket{1,0}+\ket{0,0}-\ket{1,2})\).

Hint 2

Apply \(H\) to the coin, then shift, and collect terms by position.

Worked solution

Applying \(H\) to the coin of the two-step state and shifting gives amplitudes at positions \(-3,-1,1,3\) with probabilities \(\frac18,\frac58,\frac18,\frac18\). For example, \(\ket{0,-1}\) receives \(\frac{1}{2\sqrt2}(1+1)\) from \(\ket{1,0}\) and \(\ket{0,0}\), giving amplitude \(\frac{1}{\sqrt2}\) and probability \(\frac12\). The classical walk gives \(\frac18,\frac38,\frac38,\frac18\). The quantum walk is lopsided toward the left, because the Hadamard coin gives the \(\ket1\) branch a minus sign that causes cancellation on the right. Both distributions have \(\mathbb E[x^2]=3\). After so few steps the ballistic \(T^2\) growth is invisible: it emerges only for large \(T\), where the quantum spread approaches \(0.54\,T\) against the classical \(\sqrt T\). A few steps check the calculation; they do not show the scaling.

Revisit the relevant explanation

6. Worked problem §

The path graph on three vertices \(1-2-3\) has adjacency eigenvalues \(\sqrt2,0,-\sqrt2\), with eigenvectors \(\frac12(1,\sqrt2,1)\), \(\frac{1}{\sqrt2}(1,0,-1)\), and \(\frac12(1,-\sqrt2,1)\). For the continuous walk \(e^{-iAt}\) starting at vertex \(1\), find the amplitude at vertex \(3\) as a function of \(t\), and the first time it reaches probability \(1\).

Hint 1

Expand \(\ket1=\frac12\ket{v_+}+\frac{1}{\sqrt2}\ket{v_0}+\frac12\ket{v_-}\).

Hint 2

Multiply each coefficient by \(e^{-i\lambda t}\) and read off the third component.

Worked solution

The overlaps of \(\ket1\) with the three eigenvectors are \(\frac12,\frac{1}{\sqrt2},\frac12\). After time \(t\), the third component is \(\frac12e^{-i\sqrt2t}\cdot\frac12+\frac{1}{\sqrt2}\cdot\big(-\frac{1}{\sqrt2}\big)+\frac12e^{i\sqrt2t}\cdot\frac12=\frac12\big(\cos\sqrt2t-1\big)\). The probability is \(\frac14(1-\cos\sqrt2t)^2=\sin^4(t/\sqrt2)\). It first equals \(1\) at \(t=\pi/\sqrt2\), when \(\cos\sqrt2t=-1\): the walker is transferred from one end to the other with certainty. This perfect transfer happens because the eigenvalues are evenly spaced, so all relative phases align at once. On longer paths the eigenvalues are not commensurate, and transfer is imperfect.

Revisit the relevant explanation

7. Worked problem §

Consider the lazy walk \(P=\frac12I+\frac14A\) on a cycle of \(N=16\) vertices. Its eigenvalues are \(\frac12(1+\cos(2\pi k/N))\). Compute the spectral gap \(\delta\), the angle \(\theta=\arccos\lambda_2\) of Szegedy’s walk, and compare \(1/\delta\) with \(1/\theta\). How do the two scale with \(N\)?

Hint 1

\(\lambda_2=\frac12(1+\cos(\pi/8))\).

Hint 2

For small \(\delta\), \(\theta\approx\sqrt{2\delta}\).

Worked solution

\(\lambda_2=\frac12(1+\cos\frac\pi8)\approx\frac12(1+0.9239)=0.9619\), so \(\delta\approx0.0381\) and \(1/\delta\approx26\). Then \(\theta=\arccos0.9619\approx0.277\), close to \(\sqrt{2\delta}\approx0.276\), and \(1/\theta\approx3.6\). For large \(N\), \(\delta\approx\pi^2/N^2\), so classical mixing takes order \(N^2\) steps, while \(\theta\approx\sqrt2\pi/N\) and phase estimation resolves the walk’s gap with order \(N\) steps. On the cycle the quadratic improvement is the familiar ballistic-versus-diffusive difference. It applies to resolving the stationary eigenphase, which is what walk search uses, not to producing a classical sample from the uniform distribution.

Revisit the relevant explanation

8. Misconception §

To “watch the quantum walk work,” a programmer measures the position after every step of the four-cycle Hadamard walk from \(\ket{0,0}\). The coherent walk reaches vertex \(3\) with certainty after three steps. What distribution over vertices does the monitored walk give after three steps, and why?

Hint 1

After a position measurement, branches at different positions can no longer interfere.

Hint 2

With only one route through each measured history, the probabilities simply multiply.

Worked solution

Monitoring the position gives vertices \(1\) and \(3\) with probability \(\frac12\) each, the same as the classical random walk. Each measurement keeps one position and erases the coherence between positions. The later steps then add probabilities along histories instead of amplitudes. The certainty of the coherent walk came from the cancellation at vertex \(1\) of the third step, which needs the two routes to vertex \(1\) to coexist as amplitudes. A walk algorithm must run coherently and measure only at the end; a measured walk is a classical walk with extra steps.

Revisit the relevant explanation

9. Extension §

A walk on r-subsets of an N-element set has setup cost r, update cost 1, checking cost √r, marked fraction (r/N)², and spectral gap 1/r. Use the walk-search formula to find the optimal r and the total cost.

Hint 1

The cost is r + (N/r)(√r + √r).

Hint 2

Balance r against N/√r.

Worked solution

The cost is r + (N/r)(√r·1 + √r) = r + 2N/√r, minimized when r ≈ N^{2/3}, giving O(N^{2/3}). Checking at cost √r does not change the order here because it is no larger than the update term √r·U. If checking cost grew faster than √r, it would dominate and change the optimum.

Revisit the relevant explanation

10. Extension §

Before the walk algorithm, element distinctness had a simpler quantum algorithm: query a random set \(S\) of \(r\) values and store them, then Grover-search the remaining items for one whose value appears in \(S\), and wrap the whole procedure in amplitude amplification. (a) Estimate the success probability of one run when exactly one colliding pair exists. (b) Show that the amplified cost is about \(\sqrt{N/r}\,(r+\sqrt N)\) and optimize \(r\). (c) Compare with the walk’s \(N^{2/3}\), and identify what the walk reuses that this algorithm does not.

Hint 1

A run succeeds if one member of the pair is in \(S\): probability about \(2r/N\).

Hint 2

Balance \(\sqrt{Nr}\) against \(N/\sqrt r\).

Worked solution

(a) The run succeeds if \(S\) contains one member of the colliding pair, which happens with probability about \(2r/N\); Grover search then finds the other member with about \(\sqrt N\) queries. (b) One run costs \(r+O(\sqrt N)\) queries, and amplification needs about \(\sqrt{N/r}\) repetitions. The total is \(\sqrt{N/r}\,(r+\sqrt N)=\sqrt{Nr}+N/\sqrt r\). The two terms balance at \(r=\sqrt N\), giving \(O(N^{3/4})\) queries. (c) \(N^{3/4}\) lies between the classical \(N\) and the walk’s optimal \(N^{2/3}\). This algorithm pays the full setup cost \(r\) inside every amplification round. The walk instead keeps its stored set and changes it by one element per step, so it pays the setup cost \(r\) only once, and each update costs \(O(1)\).

Revisit the relevant explanation

Where this leads. the Operator Embedding chapter embeds matrices that are not unitary inside larger unitaries, so that their actions, and later their spectra, can be manipulated by circuits.

Search this book

Search the course.