Skip to main content
Log in

Using Shor’s algorithm on near term Quantum computers: a reduced version

  • Research Article
  • Published:
Quantum Machine Intelligence Aims and scope Submit manuscript

Abstract

Considering its relevance in the field of cryptography, integer factorization is a prominent application where Quantum computers are expected to have a substantial impact. Thanks to Shor’s algorithm, this peculiar problem can be solved in polynomial time. However, both the number of qubits and applied gates detrimentally affect the ability to run a particular quantum circuit on the near term Quantum hardware. In this work, we help addressing both these problems by introducing a reduced version of Shor’s algorithm that proposes a step forward in increasing the range of numbers that can be factorized on noisy Quantum devices. More specifically, the structure of the Shor’s circuit has been modified to reduce the number of gates in the modular arithmetic and the Quantum Fourier Transform. The implementation presented in this work is general and does not use any assumptions on the number to factor. In particular, we have found noteworthy results in most cases, often being able to factor the given number with only one iteration of the proposed algorithm. Finally, comparing the original quantum algorithm with our version on simulator, the outcomes are identical for some of the numbers considered.

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

Similar content being viewed by others

References

  • Anikeeva G, Kim IH, Hayden P (2021) Recycling qubits in near-term quantum computers. Physical Review A 103(4):042613 arXiv: 2012.01676

    Article  MathSciNet  Google Scholar 

  • Anschuetz ER, Olson JP, Aspuru-Guzik A, Cao Y (2018) Variational quantum factoring. arXiv:1808.08927 [quant-ph]

  • Beauregard S (2003) Circuit for Shor’s algorithm using 2n+3 qubits. arXiv:quant-ph/0205095

  • Buhler JP, Lenstra HW, Pomerance C (1993) Factoring integers with the number field sieve. In: Lenstra AK, Lenstra HW (eds) The development of the number field sieve. lecture notes in mathematics. Springer, Berlin, pp 50–94

  • Cleve R, Ekert A, Macchiavello C, Mosca M (1998) Quantum algorithms revisited. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences 454(1969):339–354 arXiv: quant-ph/9708016

    Article  MathSciNet  MATH  Google Scholar 

  • Crandall R, Pomerance C (2005) Prime numbers: A computational perspective. Springer-Verlag, New York, 2 edition

  • Draper TG (2000) Addition on a quantum computer. arXiv:quant-ph/0008033

  • Geller MR, Zhou Z (2013) Factoring 51 and 85 with 8 qubits. Scientific Reports 3(1):3023. Number: 1 Publisher: Nature Publishing Group

  • Kitaev AY (1995) Quantum measurements and the abelian stabilizer problem. arXiv:quant-ph/9511026

  • Lanyon BP, Weinhold TJ, Langford NK, Barbieri M, James DFV, Gilchrist A, White AG (2007) Experimental demonstration of a compiled version of shor’s algorithm with quantum entanglement. Phys Rev Lett 99(25):250505. Publisher: American Physical Society

  • Lu C-Y, Browne DE, Yang T, Pan J-W (2007) Demonstration of a compiled version of shor’s quantum factoring algorithm using photonic qubits. Phys Rev Lett 99(25):250504. Publisher: American Physical Society

  • Lucero E, Barends R, Chen Y, Kelly J, Mariantoni M, Megrant A, O’Malley P, Sank D, Vainsencher A, Wenner J, White T, Yin Y, Cleland AN, Martinis JM (2012) Computing prime factors with a Josephson phase qubit quantum processor. Nature Physics 8(10):719–723 arXiv: 1202.5707

    Article  Google Scholar 

  • Martin-Lopez E, Laing A, Lawson T, Alvarez R, Zhou X-Q, O’Brien JL (2012) Experimental realisation of Shor’s quantum factoring algorithm using qubit recycling. Nature Photonics 6(11):773–776 arXiv: 1111.4147

    Article  Google Scholar 

  • Monz T, Nigg D, Martinez EA, Brandl MF, Schindler P, Rines R, Wang SX, Chuang IL, Blatt R (2016) Realization of a scalable Shor algorithm. Science 351(6277):1068–1070. Publisher: American Association for the Advancement of Science Section: Report

  • Mosca M, Ekert A (1999) The hidden subgroup problem and eigenvalue estimation on a quantum computer. arXiv:quant-ph/9903071

  • Nielsen MA, Chuang IL (2010) Quantum computation and quantum information: 10th anniversary edition

  • Parker S, Plenio MB (2000) Efficient factorization with a single pure qubit and log N mixed qubits. Physical Review Letters 85(14):3049–3052 arXiv: quant-ph/0001066

    Article  Google Scholar 

  • Politi A, Matthews JCF, O’Brien JL (2009) Shor’s quantumfactoring algorithm on a photonic chip. Science 325(5945):1221–1221. Publisher: American Association for the Advancement of Science Section: Brevia

  • Proctor T, Rudinger K, Young K, Nielsen E, Blume-Kohout R (2020) Measuring the capabilities of quantum computers. arXiv:2008.11294 [quant-ph]

  • Rieffel EG, Polak WH (2011) Quantum Computing: A Gentle Introduction. Scientific and Engineering Computation. MIT Press, Cambridge, MA, USA

  • Rivest RL, Shamir A, Adleman L (1978) A method for obtaining digital signatures and public-key cryptosystems. Communications of the ACM 21(2):120–126

    Article  MathSciNet  MATH  Google Scholar 

  • Shor PW (1997) Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Journal on Computing 26(5):1484–1509 arXiv: quant-ph/9508027

    Article  MathSciNet  MATH  Google Scholar 

  • Smolin JA, Smith G, Vargo A (2013) Pretending to factor large numbers on a quantum computer. Nature 499(7457):163–165 arXiv: 1301.7007

    Article  Google Scholar 

  • Suo J, Wang L, Yang S, Zheng W, Zhang J (2020) Quantum algorithms for typical hard problems: a perspective of cryptanalysis. Quantum Information Processing 19(6):178

    Article  MathSciNet  Google Scholar 

  • Vandersypen LMK, Steffen M, Breyta G, Yannoni CS, Sherwood MH, Chuang IL (2001) Experimental realization of Shor’s quantum factoring algorithm using nuclear magnetic resonance. Nature 414(6866):883–887 arXiv: quant-ph/0112176

    Article  Google Scholar 

  • Vedral V, Barenco A, Ekert A (1996) Quantum networks for elementary arithmetic operations. Physical Review A 54(1):147–153 arXiv: quant-ph/9511018

    Article  MathSciNet  Google Scholar 

Download references

Acknowledgements

This research work was supported by Generali Italia S.p.A. We thank them for fruitful discussions and useful insights.

Funding

This research work was funded by Generali Italia S.p.A.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Luca Asproni.

Ethics declarations

Conflict of interest

The authors declare no competing interests.

Additional information

Publisher's note

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

Appendices

Appendix A. Focus on original circuits

The original implementation of the QPE circuit, required by Shor’s algorithm, uses two quantum registries. The first one, named counting register, is initialized in superposition and its qubits control different unitary blocks. At the end, the phase of the unitary operator will be found in this register. The second register contains a convenient eigenstate that is the input of the unitary blocks. Overall, this circuit requires \(4n+2\) qubits. The structure of this circuit is illustrated in Fig. 6.

Fig. 6
figure 6

Complete order-finding circuit. The Shor’s algorithm applies a QPE circuit to find the order the function \(f(x) = a^{x}mod N\), where \(\{a\in R | 1<a<N\}\). The order of f(x) is defined as the smallest positive integer r such that \(a^{r}mod N = 1\). This circuit requires \(4n+2\) qubits where \(n = \lfloor log_{2}(N)\rfloor + 1\) and N is the number to be factored

In the classical implementation of the order-finding circuit, each qubit of the first register controls only one unitary block. Therefore, the overall number of qubits can be reduced using only one control qubit that is recycled 2n times. This is the idea behind the circuit proposed by Beauregard (2003); Mosca and Ekert (1999) that requires only \(2n+3\) qubits. The quantum circuit is shown in Fig. 7.

Fig. 7
figure 7

Order-finding circuit using 2n+3 qubits. At each step, the control qubit is initialized, controls a unitary block, undergoes a partial Inverse Fourier Transform and it is finally measured to obtain each bit of the estimated phase. \(R_i\) gates apply the rotation for the partial Inverse QFT, depending on the outcome of the previously measured values. More specifically, \(R_{j} = \left( \begin{array}{cc} 1 &{} 0\\ 0 &{} e^{i\theta _{j}}\end{array}\right)\) and \(\theta _{j} = -2\pi \sum _{k=0}^{j}\frac{m_{k}}{2^{j-k+1}}\) (Parker and Plenio 2000; Beauregard 2003)

Appendix B. Additional results

In order to improve the overall statistic, we further analyzed the behavior of the original circuit and our proposed approach on 5 pairs of (Na). More specifically, we executed 50 new runs for each couple on both circuits. Final outcomes are described in Fig. 8. Overall, the new success probability is very similar to the outcomes illustrated in the complete heat map. The success probability achieved by the optimized version remains high: considering the couple \((N = 57, a = 40)\), it is possible to factor in only one iteration for \(88\%\) of the tests, compared to the \(50\%\) displayed in the complete heat map.

Fig. 8
figure 8

Success probability histograms. Five couples of N and a have been selected from the complete success probability heat map, ranging from cases in which original circuit performed better, similarly or worse than the optimized version. For these values, we executed 50 tests for each circuit, using the IBM ‘\(ibmq\_qasm\_simulator\)’ simulator

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Rossi, M., Asproni, L., Caputo, D. et al. Using Shor’s algorithm on near term Quantum computers: a reduced version. Quantum Mach. Intell. 4, 18 (2022). https://doi.org/10.1007/s42484-022-00072-2

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s42484-022-00072-2

Keywords

Navigation