Skip to main content
Log in

A family of unitaries for the quantum period finding algorithm

  • Published:
Quantum Information Processing Aims and scope Submit manuscript

Abstract

We use differentiable programming and gradient descent to find unitary matrices that can be used in the period finding algorithm to extract period information from the state of a quantum computer post-application of the oracle. The standard procedure is to use the inverse quantum Fourier transform. Our findings suggest that this is not the only unitary matrix appropriate for the period finding algorithm. There exists a family of unitary matrices that can affect out the same transformation and they are related by a symmetry. An analysis of this symmetry is presented. These unitary matrices can be learned by an algorithm which reveals the underlying symmetry. We also find simple neural networks are able to learn this symmetry and differentiate such unitary matrices from randomly generated ones.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11

Similar content being viewed by others

Data availability

The datasets generated during and/or analyzed during the current study are available from the corresponding author on reasonable request.

References

  1. Feynman, R.P.: Simulating physics with computers. Int. J. Theor. Phys. 21(6/7) (1982)

  2. Deutsch, D., Jozsa, R.: Rapid solution of problems by quantum computation. Proc. R. Soc. Lond. Ser. Math. Phys. Sci. 439, 553–558 (1992)

    ADS  MathSciNet  MATH  Google Scholar 

  3. Simon, D.R.: On the power of quantum computation. SIAM J. Comput. 26(5), 1474–1483 (1997). https://doi.org/10.1137/S0097539796298637

    Article  MathSciNet  MATH  Google Scholar 

  4. Baydin, A.G., Pearlmutter, B.A., Radul, A.A., Siskind, J.M.: Automatic differentiation in machine learning: a survey. J. Mach. Learn. Res. 18(153), 1–43 (2018)

    MathSciNet  MATH  Google Scholar 

  5. Wengert, R.E.: A simple automatic derivative evaluation program. Commun. ACM 7(8), 463–464 (1964). https://doi.org/10.1145/355586.364791

    Article  MATH  Google Scholar 

  6. Gepp, A., Stocks, P.: A review of procedures to evolve quantum algorithms. Genet. Program Evolvable Mach. 10(2), 181–228 (2009). https://doi.org/10.1007/s10710-009-9080-7

    Article  Google Scholar 

  7. Cincio, L., Subaşı, Y., Sornborger, A.T., Coles, P.J.: Learning the quantum algorithm for state overlap. New J. Phys. 20(11), 113022 (2018). https://doi.org/10.1088/1367-2630/aae94a

    Article  ADS  Google Scholar 

  8. Bang, J., Ryu, J., Yoo, S., Pawłowski, M., Lee, J.: A strategy for quantum algorithm design assisted by machine learning. New J. Phys. 16(7), 073017 (2014). https://doi.org/10.1088/1367-2630/16/7/073017

    Article  ADS  MATH  Google Scholar 

  9. Wan, K.H., Liu, F., Dahlsten, O., Kim, M.S.: Learning Simon’s Quantum Algorithm (2018)

  10. Morales, M.E.S., Tlyachev, T., Biamonte, J.: Variational learning of Grover’s quantum search algorithm. Phys. Rev. A 98, 062333 (2018). https://doi.org/10.1103/PhysRevA.98.062333

    Article  ADS  Google Scholar 

  11. Grover, L.K.: A fast quantum mechanical algorithm for database search. In: Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing. STOC ’96, pp. 212–219. Association for Computing Machinery, New York (1996). https://doi.org/10.1145/237814.237866

  12. Gammelmark, S., Mølmer, K.: Quantum learning by measurement and feedback. New J. Phys. 11(3), 033017 (2009). https://doi.org/10.1088/1367-2630/11/3/033017

    Article  ADS  Google Scholar 

  13. Lomont, C.: The hidden subgroup problem-review and open problems. https://arxiv.org/abs/quant-ph/0411037 (2004)

  14. Kingma, D.P., Ba, J.: Adam: a method for stochastic optimization. In: Bengio, Y., LeCun, Y. (eds.) 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, 7–9 May, 2015, Conference Track Proceedings (2015). arXiv:1412.6980

  15. Ruder, S.: An overview of gradient descent optimization algorithms. arXiv preprint arXiv:1609.04747 (2016)

  16. Abadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z., Citro, C., Corrado, G.S., Davis, A., Dean, J., Devin, M., Ghemawat, S., Goodfellow, I., Harp, A., Irving, G., Isard, M., Jia, Y., Jozefowicz, R., Kaiser, L., Kudlur, M., Levenberg, J., Mané, D., Monga, R., Moore, S., Murray, D., Olah, C., Schuster, M., Shlens, J., Steiner, B., Sutskever, I., Talwar, K., Tucker, P., Vanhoucke, V., Vasudevan, V., Viégas, F., Vinyals, O., Warden, P., Wattenberg, M., Wicke, M., Yu, Y., Zheng, X.: TensorFlow: Large-Scale Machine Learning on Heterogeneous Systems. Software available from tensorflow.org (2015). https://www.tensorflow.org/

  17. Jalabert, R.A., Pastawski, H.M.: Environment-independent decoherence rate in classically chaotic systems. Phys. Rev. Lett. 86, 2490–2493 (2001). https://doi.org/10.1103/PhysRevLett.86.2490

    Article  ADS  Google Scholar 

  18. Dreyfus, S.E.: Artificial neural networks, back propagation, and the Kelley-Bryson gradient procedure. J. Guid. Control. Dyn. 13(5), 926–928 (1990). https://doi.org/10.2514/3.25422

    Article  ADS  MathSciNet  Google Scholar 

  19. Leshno, M., Lin, V.Y., Pinkus, A., Schocken, S.: Multilayer feedforward networks with a nonpolynomial activation function can approximate any function. Neural Netw. 6(6), 861–867 (1993). https://doi.org/10.1016/S0893-6080(05)80131-5

    Article  Google Scholar 

  20. Nair, V., Hinton, G.E.: Rectified linear units improve restricted Boltzmann machines. In: Proceedings of the 27th International Conference on International Conference on Machine Learning. ICML’10, pp. 807–814. Omnipress, Madison (2010)

  21. Goodfellow, I.J., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative adversarial nets. In: Proceedings of the 27th International Conference on Neural Information Processing Systems—Volume 2. NIPS’14, pp. 2672–2680. MIT Press, Cambridge (2014)

  22. Mermin, N.D.: Period Finding and Continued Fractions. Quantum Computer Science, An Introduction, pp. 197–200. Cambridge University Press, Cambridge (2007)

    Book  Google Scholar 

Download references

Acknowledgements

A.S. acknowledges the support of DST-SERB through Grant No. EMR/2016/007221 and the QuEST program of DST through Project No. Q113 under Theme 4.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to John George Francis.

Ethics declarations

Conflict of interest

The authors have no competing and conflict of interest to declare with regard to the content of this article.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendices

Appendix A The period finding algorithm

A function that takes n-bit numbers (integers) as input and outputs n-bit numbers of the form

$$\begin{aligned} f: \{0,2,3,4, \ldots 2^n-1\} \rightarrow \{0,2,3, \ldots 2^n-1\}, \end{aligned}$$

is given. The function is known to be periodic with an unknown period r, i.e., \(f(x + r) = f(x)\). In addition, it is stipulated that the values of f do not repeat within each period, i.e., \(f(i), f(i+1), f(i+2), \ldots f(i+r-1)\) are all unique for all values of i. Since the function is from integers to integers, this condition excludes only very few periodic functions. More importantly, this class encompasses the types of functions encountered in order finding that, in turn, is used in the integer factoring algorithm. Given the task of determining the period r, one approach is to compute \(f(1), f(2)\ldots f(i)\) until we get a value f(s) equal to f(1). Then, \(s=r\) will give the period of the function. However, this approach requires at least r function evaluations and r can be exponential in n since the domain of the function is also exponential in n. (r could be as big as \(2^{n-1}\).) This simple and straightforward approach whose computational complexity is exponential in n also turns out to be the best-known deterministic classical algorithm to find the period.

The quantum period finding algorithm evaluates the period of a function in queries polynomial in n. We briefly recap the algorithm for completeness and for establishing the notation we use. The quantum circuit for the period finding algorithm is given in Fig. 12.

Fig. 12
figure 12

Quantum circuit for the period finding algorithm

The circuit consists of a register X of n qubits with Hilbert space of dimension \(N = 2^n\) and another register F with m qubits. All the qubits in both registers X and F are initialized into the state \(\vert 0\rangle \). In the first step of the algorithm, Hadamard gates are applied to each qubit in the register X. After these Hadamard gates, the joint state of the two registers is

$$\begin{aligned} \left| {\psi ^{(1)}}\right\rangle _{XF} = \frac{1}{ \sqrt{2^n} } \sum _{i} \vert i\rangle \vert \textbf{0}\rangle , \quad i = 0, \ldots , 2^{n}-1. \end{aligned}$$
(A1)

The oracle is a unitary transformation acting on the two registers X and F which implements the function in question. It takes the basis state \(\vert i\rangle \vert 0\rangle \) to \(\vert i\rangle \vert f(i)\rangle \). Thus, its action on \(\vert \psi ^{(1)}\rangle _{XF}\) is to produce the state \(\vert \psi ^{(2)}\rangle _{XF} = \frac{1}{\sqrt{2^n}} \sum _{i} \vert i\rangle \vert f(i)\rangle .\) Let us assume that r divides \(N=2^n\) exactly. A measurement on the second register (F) that yields a value f(s) with probability 1/r collapses \(\vert \psi ^{(2)}\rangle _{XF}\) to

$$\begin{aligned} \vert \psi ^{(3)} \rangle _{XF} = \frac{1}{\sqrt{N/r}} \sum _{p=0}^{N/r - 1} \vert s + pr\rangle \vert f(s)\rangle . \end{aligned}$$
(A2)

The iQFT is then applied on the first register as implemented by the corresponding post-processing unitary matrix which is the discrete Fourier transform matrix leading to

$$\begin{aligned} \sqrt{\frac{r}{N}} \sum _{p=0}^{N/r -1}\vert s + pr\rangle \rightarrow \textrm{iQFT} \rightarrow \frac{1}{\sqrt{r}} \sum _{q=0}^{r-1} \varphi _{s}^{qN/r} \vert qN/r\rangle \equiv \vert y_s (r)\rangle , \end{aligned}$$
(A3)

where \(\varphi _{s}^{qN/r}\) is a pure phase that is dependent on the offset s and q. The state of the two registers after the iQFT becomes

$$\begin{aligned} \left| {\psi ^{(4)}}\right\rangle _{XF} = \frac{1}{\sqrt{r}} \sum _{q=0}^{r-1} \varphi _{s}^{qN/r} \vert q[N/r]\rangle \vert f(s)\rangle . \end{aligned}$$
(A4)

The probability of measuring the first register in any one of the r states, \(q N/r\rangle \), does not depend on the phase \(\varphi _s^{qN/r}\). We see that measuring the first register in the computational basis yields any one of the r possible values, qN/r with probability 1/r each. The measurement statistics obtained by projecting the register X on to the complete set of computational basis states is therefore a probability distribution with equal height peaks at intervals of N/r. If r does not divide N exactly and N/r is not an integer, then the distribution has narrow peaks around the integer [qN/r], where the square brackets indicate rounding up or down to the nearest integer. By sampling this distribution, finding the location of these peaks and with some classical post-processing [22], to any desired level of accuracy one can compute the period, r, of the function. However, in this case \(\varphi _s^{qN/r}\) are not pure phases and we will come back to these offset dependent amplitudes \(\varphi _{s}^q\) in Sect. 6.

For example, suppose we had a function of period 8 and register X had 5 qubits. After the oracle, if the measured value on the second register was 7, corresponding to \(\vert 7\rangle \), the state of the system would be

$$\begin{aligned} \vert \psi ^{(4)} \rangle _{XF} = \frac{1}{2} \sum _{t=0}^3 \vert 7+8t\rangle \vert 7\rangle . \end{aligned}$$

Note that the amplitudes on the first register are concentrated on \(\vert j\rangle \) where j correspond to the red lines in Fig. 13. The periodicity of these amplitudes is revealed by the final post-processing step, namely the iQFT. It can be easily seen that the structure of the state of the X register in \(\vert \psi ^{(3)} \rangle _{XF}\) is independent of the outcome of the first measurement on the register F. We can therefore just as well ignore this measurement result which would be equivalent to tracing over the register F after the action of the post-processing unitary.

Fig. 13
figure 13

Example function with period 8. If the measurement on the second register yields the answer 7 after the oracle, then the amplitudes of the first register are concentrated on states \(\vert j\rangle \), where j is marked by the red lines in the figure (Color figure online)

Appendix B Phase of \(\Sigma _s (\varphi _s^j)^2\)

Proof

We show that the \(\Sigma _s (\varphi _s^j)^2\) mentioned in Sect. 6 has a phase that is independent of the function and its period r when N is not a multiple of r. Depending on whether s is less than or greater than \(\textrm{mod}(N-1,r)\), the calculation proceeds with a small difference in the normalization of the state after the quantum post-processing. This difference is because of there is one less peak in the output distribution when \(s > \textrm{mod}(N, r-1)\) as the size of the first register is limited to N. Denoting \(\textrm{mod}(N-1,r)\) as Q and \(k=\lfloor \frac{N-1}{r} \rfloor \), where \(\lfloor \cdot \rfloor \) is the floor function we have,

$$\begin{aligned} \varphi _s^j= & {} \frac{1}{\sqrt{(k+1)N}}(\omega ^{sj} + \omega ^{(s+r)j}... \; \omega ^{(s+kr)j}) \\= & {} \frac{1}{\sqrt{(k+1)N}}(\omega ^{sj})\frac{1-\omega ^{rj(k+1)}}{1-\omega ^{rj}} \;\;\; \forall s\le Q\\ \varphi _s^j= & {} \frac{1}{\sqrt{kN}}(\omega ^{sj} + \omega ^{(s+r)j}... \; \omega ^{(s+(k-1)r)j}) \\= & {} \frac{1}{\sqrt{kN}}\omega ^{sj}\frac{1-\omega ^{rjk}}{1-\omega ^{rj}} \;\;\; \forall s > Q \end{aligned}$$

Squaring and summing over s

$$\begin{aligned} \sum \limits _{s=0}^{r-1} \left( \varphi _s^j \right) ^2= & {} \frac{1}{(k+1)N}\sum \limits _{s=0}^{Q}\omega ^{2sj}\left( \frac{1-\omega ^{rj(k+1)}}{1-\omega ^{rj}}\right) ^2 + \frac{1}{kN}\sum \limits _{s=Q+1}^{r-1}\omega ^{2sj}\left( \frac{1-\omega ^{rjk}}{1-\omega ^{rj}}\right) ^2 \\= & {} \frac{1}{(k+1)N}\frac{\left( 1-\omega ^{rj(k+1)}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \sum \limits _{s=0}^{Q}\left( \omega ^{2sj}\right) + \frac{1}{kN}\frac{\left( 1-\omega ^{rjk}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2}\sum \limits _{s=Q+1}^{r-1}\omega ^{2sj} \\= & {} \frac{1}{(k+1)N}\frac{\left( 1-\omega ^{rj(k+1)}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \frac{1-\omega ^{2j(Q+1)}}{1-\omega ^{2j}} \\{} & {} \qquad + \;\frac{1}{kN}\frac{\left( 1-\omega ^{rjk}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2}\omega ^{2(Q+1)j} \frac{1-\omega ^{2j(r-(Q+1))}}{1-\omega ^{2j}} \end{aligned}$$

Now, kr is multiple of r just less than \(N-1\), and \(Q= \textrm{mod}(N-1,r)\); therefore, \(kr+Q=N-1\), or \(Q+1=N-kr\). Using this,

$$\begin{aligned} \sum \limits _{s=0}^{r-1} \left( \varphi _s^j \right) ^2= & {} \frac{1}{(k+1)N}\frac{\left( 1-\omega ^{rj(k+1)}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \frac{1-\omega ^{2j(N-kr)}}{1-\omega ^{2j}} \\{} & {} \;\; + \frac{\omega ^{2(N-kr)j}}{kN}\frac{\left( 1-\omega ^{rjk}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \frac{1-\omega ^{2j(r-N+kr)}}{1-\omega ^{2j}} \end{aligned}$$

using \(\omega ^{mN+l}=\omega ^l\) for any integers ml

$$\begin{aligned} \sum \limits _{s=0}^{r-1} \left( \varphi ^j_s \right) ^2= & {} \frac{1}{(k+1)N}\frac{\left( 1-\omega ^{rj(k+1)}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \frac{1-\omega ^{-2jkr}}{1-\omega ^{2j}} \nonumber \\{} & {} \;+ \frac{\omega ^{-2krj}}{kN}\frac{\left( 1-\omega ^{rjk}\right) ^2}{\left( 1-\omega ^{rj}\right) ^2} \frac{1-\omega ^{2j(k+1)r)}}{1-\omega ^{2j}} \end{aligned}$$
(B5)

The two terms in the RHS of the above equation are complex numbers with the same phase, and the phase is independent of r. To show this, let’s first consider a complex number of the form \(1-\omega ^\theta \).

$$\begin{aligned} 1 - \omega ^{\theta }= & {} 1 - \cos \bigg ( \frac{2\pi \theta }{N} \bigg ) + i\, \sin \bigg ( \frac{2\pi \theta }{N} \bigg ) \\= & {} 2 \sin ^2\bigg ( \frac{\pi \theta }{N} \bigg ) + 2 i\, \sin \bigg ( \frac{\pi \theta }{N} \bigg ) \cos \bigg ( \frac{\pi \theta }{N} \bigg ) \\= & {} 2 i \sin \bigg ( \frac{\pi \theta }{N} \bigg ) \bigg [ \cos \bigg ( \frac{\pi \theta }{N} \bigg ) - i \sin \bigg (\frac{\pi \theta }{N} \bigg ) \bigg ] \\= & {} 2 i \sin \bigg (\frac{\pi \theta }{N} \bigg ) \omega ^{\frac{\theta }{2}} \\= & {} iR\omega ^{\frac{\theta }{2}} \end{aligned}$$

where \(R = 2 \sin (\pi \theta /N)\) is a real number. Using this in Eq. (B5) and absorbing all the R’s into a single real number,

$$\begin{aligned} \sum \limits _{s=0}^{r-1}(\varphi ^j_s)^2= & {} R_1 \frac{\omega ^{rj(k+1)}}{\omega ^{rj}} \frac{\omega ^{-jkr}}{\omega ^{j}} + R_2\frac{\omega ^{-2krj}\omega ^{rjk}}{\omega ^{rj}} \frac{\omega ^{j(k+1)r}}{\omega ^{j}} \\= & {} R_1\omega ^{rjk+rj-jkr-rj-j} + R_2\omega ^{-2jkr+rjk+jkr+jr-rj-j} \\= & {} R_1\omega ^{-j} + R_2\omega ^{-j} \\= & {} R\omega ^{-j} \end{aligned}$$

\(\square \)

Thus, the phase of the sum on the LHS is \(2\pi j/N\), and it only depends on the index j and is independent of the function that is input to the period finding algorithm.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Francis, J.G., Shaji, A. A family of unitaries for the quantum period finding algorithm. Quantum Inf Process 22, 326 (2023). https://doi.org/10.1007/s11128-023-04079-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s11128-023-04079-x

Keywords

Navigation