Variational Quantum Factoring

  • Eric Anschuetz
  • Jonathan Olson
  • Alán Aspuru-Guzik
  • Yudong CaoEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11413)


Integer factorization has been one of the cornerstone applications of the field of quantum computing since the discovery of an efficient algorithm for factoring by Peter Shor. Unfortunately, factoring via Shor’s algorithm is well beyond the capabilities of today’s noisy intermediate-scale quantum (NISQ) devices. In this work, we revisit the problem of factoring, developing an alternative to Shor’s algorithm, which employs established techniques to map the factoring problem to the ground state of an Ising Hamiltonian. The proposed variational quantum factoring (VQF) algorithm starts by simplifying equations over Boolean variables in a preprocessing step to reduce the number of qubits needed for the Hamiltonian. Then, it seeks an approximate ground state of the resulting Ising Hamiltonian by training variational circuits using the quantum approximate optimization algorithm (QAOA). We benchmark the VQF algorithm on various instances of factoring and present numerical results on its performance.


Integer factorization Quantum computation Discrete optimization 



We would like to acknowledge the Zapata Computing scientific team, including Peter Johnson, Jhonathan Romero, Borja Peropadre, and Hannah Sim for their insightful and inspiring comments.


  1. 1.
    Beauregard, S.: Circuit for Shor’s algorithm using 2n+3 qubits. Quant. Inf. Comput. 3(2), 175–185 (2003)MathSciNetzbMATHGoogle Scholar
  2. 2.
    Burges, C.J.C.: Factoring as Optimization. Microsoft Research, MSR-TR-200 (2002)Google Scholar
  3. 3.
    Dattani, N.S., Bryans, N.: Quantum factorization of 56153 with only 4 qubits, arXiv:1411.6758 [quant-ph] (2014)
  4. 4.
    Dridi, R., Alghassi, H.: Prime factorization using quantum annealing and computational algebraic geometry. Sci. Rep. 7(1), 43048 (2017)CrossRefGoogle Scholar
  5. 5.
    Ekerå, M.: Modifying Shor’s algorithm to compute short discrete logarithms. IACR Cryptology ePrint Archive (2016)Google Scholar
  6. 6.
    Farhi, E., Goldstone, J., Gutmann, S.: A quantum approximate optimization algorithm, arXiv:1411.4028 [quant-ph] (2014)
  7. 7.
    Farhi, E., Harrow, A.W.: Quantum supremacy through the quantum approximate optimization algorithm, arXiv:1602.07674 [quant-ph] (2016)
  8. 8.
    Fletcher, R.: Practical Methods of Optimization, 2nd edn. Wiley, New York (2000)CrossRefGoogle Scholar
  9. 9.
    Fowler, A.G., Devitt, S.J., Hollenberg, L.C.L.: Implementation of Shor’s Algorithm on a Linear Nearest Neighbour Qubit Array. Quantum Information & Computation 4, 237–251 (2004)MathSciNetzbMATHGoogle Scholar
  10. 10.
    Fried, E.S., Sawaya, N.P.D., Cao, Y., Kivlichan, I.D., Romero, J., Aspuru-Guzik, A.: qTorch: The quantum tensor contraction handler, arXiv:1709.03636 [quant-ph] (2017)
  11. 11.
    Geller, M.R., Zhou, Z.: Factoring 51 and 85 with 8 qubits. Sci. Rep. 3(3), 1–5 (2013)Google Scholar
  12. 12.
    Gidney, C.: Factoring with n+2 clean qubits and n\(-\)1 dirty qubits, arXiv:1706.07884 [quant-ph] (2017)
  13. 13.
    Johansson, J., Nation, P., Nori, F.: QuTiP: an open-source Python framework for the dynamics of open quantum systems. Comput. Phys. Commun. 183(8), 1760–1772 (2012)CrossRefGoogle Scholar
  14. 14.
    Jones, N.C., et al.: Layered architecture for quantum computing. Phys. Rev. X 2(3), 1–27 (2012)Google Scholar
  15. 15.
    Kitaev, A.Y.: Quantum measurements and the Abelian stabilizer problem, arXiv:quant-ph/9511026 (1995)
  16. 16.
    Lin, C.Y.-Y., Zhu, Y.: Performance of QAOA on typical instances of constraint satisfaction problems with bounded degree, arXiv:1601.01744 [quant-ph] (2016)
  17. 17.
    Martín-López, E., Laing, A., Lawson, T., Alvarez, R., Zhou, X.Q., O’brien, J.L.: Experimental realization of Shor’s quantum factoring algorithm using qubit recycling. Nat. Photonics 6(11), 773–776 (2012)Google Scholar
  18. 18.
    Nannicini, G.: Performance of hybrid quantum/classical variational heuristics for combinatorial optimization, arXiv:1805.12037 [quant-ph] (2018)
  19. 19.
    Nielsen, M.A., Chuang, I.: Quantum Computation and Quantum Information, 10th Anniversary edn. Cambridge University Press, Cambridge (2010)Google Scholar
  20. 20.
    Peruzzo, A., et al.: A variational eigenvalue solver on a photonic quantum processor. Nat. Commun. 5(May), 4213 (2014)CrossRefGoogle Scholar
  21. 21.
    Politi, A., Matthews, J.C.F., O’Brien, J.L.: Shor’s quantum factoring algorithm on a photonic chip. Science 325(5945), 1221–1221 (2009)MathSciNetCrossRefGoogle Scholar
  22. 22.
    Romero, J., Olson, J., Aspuru-Guzik, A.: Quantum autoencoders for efficient compression of quantum data. Quant. Sci. Technol. 2(4), 045001 (2017)CrossRefGoogle Scholar
  23. 23.
    Shor, P.W.: Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Rev. 41(2), 303–332 (1999)MathSciNetCrossRefGoogle Scholar
  24. 24.
    Zalka, C.: Shor’s algorithm with fewer (pure) qubits, arXiv:quant-ph/0601097 (2006)

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  • Eric Anschuetz
    • 1
  • Jonathan Olson
    • 1
  • Alán Aspuru-Guzik
    • 1
  • Yudong Cao
    • 1
    Email author
  1. 1.Zapata Computing Inc.CambridgeUSA

Personalised recommendations