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.

1.

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.

2.

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.

3.

Working code for these projects in Mathematica is available by email request to the author.

4.
“List of QC simulators,” Quantiki, <http://www.quantiki.org/wiki/List_of_QC_simulators>.
5.
Brian
Hayes
, “
Programming your quantum computer
,”
Am. Sci.
102
,
22
25
(
2014
).
6.
X.-D.
Cai
 et al, “
Experimental quantum computing to solve systems of linear equations
,”
Phys. Rev. Lett.
110
,
230501-1
5
(
2013
).
7.
Nanyang
Xu
 et al, “
Quantum factorization of 143 on a dipolar-coupling nuclear magnetic resonance system
,”
Phys. Rev. Lett.
108
,
130501-1
5
(
2012
).
8.
Michael A.
Nielsen
and
Isaac L.
Chuang
,
Quantum Computation and Quantum Information
(
Cambridge U.P.
,
Cambridge
,
2000
).
9.
Michel
Le Bellac
,
A Short Introduction to Quantum Information and Quantum Computation
(
Cambridge U.P.
,
Cambridge
,
2006
).
10.
N.
David Mermin
,
Quantum Computer Science: An Introduction
(
Cambridge U.P.
,
Cambridge
,
2007
).
11.
Giuliano
Benenti
,
Giulio
Casati
, and
Giuliano
Strini
,
Principles of Quantum Computation and Information—Vol.1: Basic Concepts
(
World Scientific
,
Singapore
,
2004
).
12.
Eleanor
Rieffel
and
Wolfgang
Polak
,
Quantum Computing: A Gentle Introduction
(
MIT Press
,
Cambridge, MA
,
2011
).
13.
Anirban
Pathak
,
Elements of Quantum Computation and Quantum Communication
(
Taylor and Francis
,
Boca Raton, FL
,
2013
).
14.
David
McMahon
,
Quantum Computing Explained
(
Wiley
,
Hoboken, NJ
,
2008
).
15.
“Quantum computer,” Wikipedia, <http://en.wikipedia.org/wiki/Quantum_computer>.
16.
“Grover's algorithm,” Wikipedia, <http://en.wikipedia.org/wiki/Grover's_algorithm>.
17.
“Shor's algorithm,” Wikipedia, <http://en.wikipedia.org/wiki/Shor's_algorithm>.
18.
Elizabeth
Gibney
, “
Quantum computer quest
,”
Nature
516
,
24
26
(
2014
).
19.

The particle could have a spatial wave function Ψ(x) that stays fixed, for example.

20.

Although electrons are identical fermions, it is not necessary to antisymmetrize |Ψ if the electrons are not allowed to exchange places with one another.

21.

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.

22.

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.

23.

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.

24.
Lieven M. K.
Vandersypen
 et al, “
Experimental realization of Shor's quantum factoring algorithm using nuclear magnetic resonance
,”
Nature
414
,
883
887
(
2001
).
25.

The left-arrow notation, e.g., aa+1, 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.

26.

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.

27.
Lov K.
Grover
, “
A fast quantum mechanical algorithm for database search
,” arXiv:quant-ph/9605043 (
1996
), <http://arxiv.org/abs/quant-ph/9605043>.
28.

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.

29.
This is written for array indices starting at zero as in Python or C++ (see Appendix).
30.
Peter W.
Shor
, “
Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer
,” arXiv:quant-ph/9508027 (
1995
), <http://arxiv.org/abs/quant-ph/9508027>.
31.
See Ref. 8 or 17 for proof. The branch of mathematics that studies primes, factoring, and other aspects of the integers is called number theory. It is well known from number theory that steps 1–6 factor the number C. Shor's contribution was to prove that step 4 can be done much more quickly on a quantum computer than classically.
32.
In physical quantum computers, gates typically operate on 1–3 qubits at a time, making this part of the period-finding calculation more complicated than the IQFT.
33.
“Quantum Fourier transform,” Wikipedia, <http://en.wikipedia.org/wiki/Quantum_Fourier_transform>.
34.
To compute a continued-fraction expansion like Eq. (41), invert the number, subtract off the integer part (which is the next number in the continued fraction), invert the fractional part, subtract off the integer part, and so on.
35.
Troels F.
Rønnow
 et al, “
Defining and detecting quantum speedup
,”
Science
345
,
420
424
(
2014
).
36.
This is a simplified description of computational complexity classes. For example, it has not been proven that NP is actually a different class than P. Based on Shor's algorithm, factoring is thought to lie in the class BQP (larger than P but not equal to NP) of problems that can be solved with high probability in polynomial time on a quantum computer. See “Computational complexity theory,” Wikipedia, <http://en.wikipedia.org/wiki/Computational_complexity_theory>, and Ref. 8, Sec. 3.2.
AAPT members receive access to the American Journal of Physics and The Physics Teacher as a member benefit. To learn more about this member benefit and becoming an AAPT member, visit the Joining AAPT page.