2121
2222In this demo we will not focus on understanding how the QFT is built,
2323as we can find a great explanation in the
24- `PennyLane Codebook </codebook/08- quantum-fourier-transform/01- changing-perspectives/>`__. Instead, we will develop the
24+ `PennyLane Codebook </codebook/quantum-fourier-transform/changing-perspectives/>`__. Instead, we will develop the
2525intuition for how it works and how we can best take advantage of it.
2626
2727Motivation
5454-----------------
5555
5656To apply the QFT to basic arithmetic operations, our objective now is to learn how to add,
57- subtract and multiply numbers using quantum devices. As we are working with qubits,
58- —which, like bits, can take the
57+ subtract and multiply numbers using quantum devices. As we are working with qubits—which ,
58+ like bits, can take the
5959values :math:`0` or :math:`1`—we will represent the numbers in binary. For the
6060purposes of this tutorial, we will assume that we are working only with
6161integers. Therefore, if we have :math:`n` qubits, we will be able to
7171
7272.. math:: m= \sum_{i = 0}^{n-1}2^{n-1-i}q_i.
7373
74- Note that :math:`\vert m \rangle` refers to the basic state
74+ Note that :math:`\vert m \rangle` refers to the basis state
7575generated by the binary encoding of the number :math:`m.`
7676For instance, the natural number :math:`6`
7777is represented by the quantum state :math:`\vert 110\rangle,` since :math:`\vert 110 \rangle = 1 \cdot 2^2 + 1\cdot 2^1+0\cdot 2^0 = 6.`
@@ -286,12 +286,12 @@ def sum2(m, k, wires_m, wires_k, wires_solution):
286286#
287287# To understand the multiplication process, let's work with the binary decomposition of
288288# :math:`k:=\sum_{i=0}^{n-1}2^{n-i-1}k_i` and
289- # :math:`m:=\sum_{j=0}^{l-1}2^{l-j-1}m_i .` In this case, the product would
289+ # :math:`m:=\sum_{j=0}^{l-1}2^{l-j-1}m_j .` In this case, the product would
290290# be:
291291#
292- # .. math:: k \cdot m = \sum_{i=0}^{n-1}\sum_{j = 0}^{l-1}m_ik_i (2^{n-i-1} \cdot 2^{l-j-1}).
292+ # .. math:: k \cdot m = \sum_{i=0}^{n-1}\sum_{j = 0}^{l-1} k_i m_j (2^{n-i-1} \cdot 2^{l-j-1}).
293293#
294- # In other words, if :math:`k_i = 1` and :math:`m_i = 1,` we would add
294+ # In other words, if :math:`k_i = 1` and :math:`m_j = 1,` we would add
295295# :math:`2^{n-i-1} \cdot 2^{l-j-1}` units to the counter, where :math:`n` and :math:`l`
296296# are the number of qubits with which we encode :math:`m` and :math:`k` respectively.
297297# Let's code to see how it works!
@@ -351,7 +351,7 @@ def mul(m, k):
351351# Let’s imagine now that we want just the opposite: to factor the
352352# number :math:`21` as a product of two terms. Is this something we could do
353353# using our previous reasoning? The answer is yes! We can make use of
354- # `Grover's algorithm <https://en.wikipedia.org/wiki/Grover%27s_algorithm>`_ to
354+ # `Grover's algorithm </qml/demos/tutorial_grovers_algorithm>`__ to
355355# amplify the states whose product is the number we
356356# are looking for. All we would need is to construct the oracle :math:`U,` i.e., an
357357# operator such that
@@ -404,15 +404,15 @@ def factorization(n, wires_m, wires_k, wires_solution):
404404
405405
406406plt .bar (range (2 ** len (wires_m )), factorization (n , wires_m , wires_k , wires_solution ))
407- plt .xlabel ("Basic states" )
407+ plt .xlabel ("Basis states" )
408408plt .ylabel ("Probability" )
409409plt .show ()
410410
411411######################################################################
412- # By plotting the probabilities of obtaining each basic state we see that
412+ # By plotting the probabilities of obtaining each basis state we see that
413413# prime factors have been amplified! Factorization via Grover’s algorithm
414- # does not achieve exponential improvement that
415- # `Shor's algorithm <https://en.wikipedia.org/wiki/Shor%27s_algorithm>`_ does, but we
414+ # does not achieve the exponential improvement that
415+ # `Shor's algorithm </codebook/shors-algorithm/shors-algorithm/>`__ does, but we
416416# can see that this construction is simple and a great example to
417417# illustrate basic arithmetic!
418418#
@@ -427,3 +427,9 @@ def factorization(n, wires_m, wires_k, wires_solution):
427427#
428428# Thomas G. Draper, "Addition on a Quantum Computer". `arXiv:quant-ph/0008033 <https://arxiv.org/abs/quant-ph/0008033>`__.
429429#
430+
431+
432+
433+
434+
435+
0 commit comments