Computational projects on quantum computing suitable for students in a junior-level quantum mechanics course are described. In these projects students write their own programs to simulate quantum computers. Knowledge is assumed of introductory quantum mechanics through the properties of spin 1/2. Initial, more easily programmed projects treat the basics of quantum computation, quantum gates, and Grover's quantum search algorithm. These are followed by more advanced projects to increase the number of qubits and implement Shor's quantum factoring algorithm. The projects can be run on a typical laptop or desktop computer, using most programming languages. Supplementing resources available elsewhere, the projects are presented here in a self-contained format especially suitable for a short computational module for physics students.
References
Although tensor products are mentioned, it is not assumed that the reader is familiar with and able to compute tensor products. Therefore, an alternative method is given based on bitwise manipulation of matrix indices (Sec. VIII A). Similarly, a bitwise method is used to compute the modular-arithmetic gates needed for Shor's algorithm (Sec. IX D). A good understanding of binary numbers should suffice for both situations.
With four weekly meetings (one third of the semester) on quantum computing, students completed the three-qubit projects including Grover's algorithm and a variable amount of the more advanced material. Consistently reaching Shor's algorithm would require additional meetings.
Working code for these projects in Mathematica is available by email request to the author.
The particle could have a spatial wave function that stays fixed, for example.
Although electrons are identical fermions, it is not necessary to antisymmetrize if the electrons are not allowed to exchange places with one another.
In most computer languages will simply be an eight-element array of complex numbers. In matrix multiplications must be treated as a column vector: when multiplied on the left by a square matrix, the result is another column vector.
If desired, the program can compute once just before the measurement and then use this as the input for multiple measurements. This would not be possible in a physical quantum computer since measuring would collapse the quantum state.
The probability for any measurement result can be computed from Eq. (8) without making simulated measurements. However, there is pedagogical value in having the simulated quantum system act like a real quantum system. Seeing the results from repeating the quantum measurement a small number of times is closer to the operation of a physical quantum computer.
The left-arrow notation, e.g., , is used to denote the assignment of a new value to the program variable a. In most computer languages this is written a=a+1.
Gates can be moved along their lines as long as the order of operations on each line is unchanged. So for Fig. 3(b) the three Hadamard gates could be applied in any order.
One can object that to write Eq. (27), we need to know the answer to the search problem. For a useful application of Grover's algorithm, the oracle would be a quantum calculation that can be constructed without knowing the correct answer. For example, the oracle could implement the logic circuit of Fig. 2 using quantum gates. See Ref. 10, pp. 88–89, for further discussion.