Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
In this tutorial, we implement 1D and 2D quantum walk. Quantum walks are quantum-mechanical extensions of classical random walks and play a central role in the design of quantum algorithms. In particular, quantum walks are known to provide polynomial, and in some cases exponential, speedups over classical methods for tasks such as search problems and the acceleration of Markov-chain-based procedures. There are two main types of quantum walks: discrete-time quantum walks and continuous-time quantum walks. In the discrete-time model, the time evolution is defined by a unitary operator U=S(C⊗I)U = S(C \otimes I), where CC is a coin operator and SS is a shift operator. In the continuous-time model, the adjacency matrix AA or the Laplacian LL of the graph is used as the Hamiltonian, and the state evolves according to the unitary operator e−iHte^{-iHt}. Unlike classical random walks, quantum walks exhibit dramatically different behavior due to interference and unitarity. For instance, the probability distribution does not take a Gaussian form; instead, it spreads ballistically, leading to an O(t)O(t) dispersion rather than the classical O(t)O(\sqrt{t}). These properties form the foundation for the speedups observed in quantum-walk-based algorithms. Quantum walks have a wide range of applications, including search algorithms, Hamiltonian simulation, quantum Markov chains, and quantum machine learning. In particular, Szegedy’s quantum walk provides a general framework for quantizing classical Markov chains into unitary operators, enabling powerful algorithmic constructions across diverse domains.

1D Quantum Walk

In a one-dimensional discrete-time quantum walk, the position space is the integer lattice Z\mathbb{Z}, and the coin space is a two-dimensional Hilbert space. The state is written as ∣ψt⟩=∑x=0N−1∑l=01αx,l∣x⟩⊗∣l⟩.|\psi_t\rangle = \sum_{x=0}^{N-1}\sum_{l=0}^{1} \alpha_{x,l}|x\rangle \otimes|l\rangle . Using a coin operator CC and a shift operator SS, one step of the time evolution is defined by U=S(C⊗I).U = S(C \otimes I). A typical example of a coin is the Hadamard coin: C=H=12(111−1).C = H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}. The shift operator moves the walker left or right depending on the coin state: S∣x⟩∣0⟩=∣x−1⟩∣0⟩,S∣x⟩∣1⟩=∣x+1⟩∣1⟩.S|x\rangle|0\rangle = |x-1\rangle|0\rangle,\qquad S|x\rangle|1\rangle = |x+1\rangle|1\rangle. As a result, the quantum walk spreads ballistically due to interference, producing a probability distribution very different from the Gaussian diffusion of classical random walks.
Output:
Output:
Output:
Output:
Output:
Output:
Output:
output

2 Dimentional Quantum Walk

In a discrete-time quantum walk on a two-dimensional lattice, the position space is Z2\mathbb{Z}^2, and a four-dimensional coin space is used to represent movement directions. The state is written as ∣ψt⟩=∑x=0N−1∑y=0N−1∑l=03αt(x,y,l)∣x,y⟩⊗∣l⟩.|\psi_t\rangle = \sum_{x=0}^{N-1}\sum_{y=0}^{N-1} \sum_{l=0}^{3} \alpha_t(x,y,l) |x,y\rangle \otimes |l\rangle. The coin operator CC is a 4×44 \times 4 unitary matrix. A commonly used example is the Grover coin: C=G4=12(−11111−11111−11111−1).C = G_4 = \frac{1}{2} \begin{pmatrix} -1 & 1 & 1 & 1 \\ 1 & -1 & 1 & 1 \\ 1 & 1 & -1 & 1 \\ 1 & 1 & 1 & -1 \end{pmatrix}. The shift operator SS moves the walker according to the coin state: S∣x,y⟩∣0⟩=∣x+1,y⟩∣0⟩,S∣x,y⟩∣1⟩=∣x−1,y⟩∣1⟩,S∣x,y⟩∣2⟩=∣x,y+1⟩∣2⟩,S∣x,y⟩∣3⟩=∣x,y−1⟩∣3⟩.\begin{aligned} S|x,y\rangle|0\rangle &= |x+1,y\rangle|0\rangle,\\ S|x,y\rangle|1\rangle &= |x-1,y\rangle|1\rangle,\\ S|x,y\rangle|2\rangle &= |x,y+1\rangle|2\rangle,\\ S|x,y\rangle|3\rangle &= |x,y-1\rangle|3\rangle. \end{aligned} The time evolution is given, as in the 1D case, by U=S(C⊗I).U = S(C \otimes I). Two-dimensional quantum walks exhibit richer interference patterns, and it is known that strong localization can occur, particularly when using the Grover coin.
Output:
Output:
Output:
Output:
output