Fundamental mathematical constants such as e and π are ubiquitous in diverse fields of science, from abstract mathematics and geometry to physics, biology and chemistry1,2. Nevertheless, for centuries new mathematical formulas relating fundamental constants have been scarce and usually discovered sporadically3,4,5,6. Such discoveries are often considered an act of mathematical ingenuity or profound intuition by great mathematicians such as Gauss and Ramanujan7. Here we propose a systematic approach that leverages algorithms to discover mathematical formulas for fundamental constants and helps to reveal the underlying structure of the constants. We call this approach ‘the Ramanujan Machine’. Our algorithms find dozens of well known formulas as well as previously unknown ones, such as continued fraction representations of π, e, Catalan’s constant, and values of the Riemann zeta function. Several conjectures found by our algorithms were (in retrospect) simple to prove, whereas others remain as yet unproved. We present two algorithms that proved useful in finding conjectures: a variant of the meet-in-the-middle algorithm and a gradient descent optimization algorithm tailored to the recurrent structure of continued fractions. Both algorithms are based on matching numerical values; consequently, they conjecture formulas without providing proofs or requiring prior knowledge of the underlying mathematical structure, making this methodology complementary to automated theorem proving8,9,10,11,12,13. Our approach is especially attractive when applied to discover formulas for fundamental constants for which no mathematical structure is known, because it reverses the conventional usage of sequential logic in formal proofs. Instead, our work supports a different conceptual framework for research: computer algorithms use numerical data to unveil mathematical structures, thus trying to replace the mathematical intuition of great mathematicians and providing leads to further mathematical research.
Subscribe to Journal
Get full journal access for 1 year
only $3.90 per issue
All prices are NET prices.
VAT will be added later in the checkout.
Tax calculation will be finalised during checkout.
Rent or Buy article
Get time limited or full article access on ReadCube.
All prices are NET prices.
All the results of the Ramanujan Machine project are shared in the paper, with newer updates appearing periodically on the project website.
Code is available at: http://www.ramanujanmachine.com/ and the GitHub links therein.
Finch, S. Mathematical Constants (Cambridge Univ. Press, 2003).
Bailey, D., Plouffe, S. M., Borwein, P. & Borwein, J. The quest for pi. Math. Intell. 19, 50–56 (1997).
Apéry, R. Irrationalité de ζ(2) et ζ(3). Asterisque 61, 11–13 (1979).
Zeilberger, D. & Zudilin, W. The irrationality measure of pi is at most 7.103205334137…. Moscow J. Combin. Number. Theory 9, 407–419 (2019).
Zudilin, W. An Apéry-like difference equation for Catalan’s constant. J. Combin. 10, R14 (2003).
Hardy, G. H. & Wright, E. M. An Introduction to the Theory of Numbers 5th edn (Oxford Univ. Press, 1980).
Berndt, B. C. Ramanujan’s Notebooks (Springer Science & Business Media, 2012).
Appel, K. I. & Haken, W. Every Planar Map Is Four Colorable Vol. 98 (American Mathematical Society, 1989).
Wilf, H. S. & Zeilberger, D. Rational functions certify combinatorial identities. J. Am. Math. Soc. 3, 147–158 (1990).
McCune, W. Solution of the Robbins problem. J. Autom. Reason. 19, 263–276 (1997).
Hales, T. C. A proof of the Kepler conjecture. Ann. Math. 162, 1065–1185 (2005).
Lample, G. & Charton, F. Deep learning for symbolic mathematics. In ICLR Conf. https://openreview.net/forum?id=S1eZYeHFDS (2020).
Cranmer, M. et al. Discovering symbolic models from deep learning with inductive biases. Preprint at https://arxiv.org/abs/2006.11287 (2020).
Turing, A. M. On computable numbers, with an application to the Entscheidungsproblem. Proc. Lond. Math. Soc. s2-42, 230–265 (1937).
Asimov, I. & Shulman, J. A. Isaac Asimov’s Book of Science and Nature Quotations (Weidenfeld & Nicolson, 1988).
Bohr, N. Rydberg’s Discovery Of The Spectral Laws (C.W.K. Gleerup, 1954).
Shimura, G. Modular forms of half integral weight. In Modular Functions of One Variable I 57–74 (Springer, 1973).
Cuyt, A. A., Petersen, V., Verdonk, B., Waadeland, H. & Jones, W. B. Handbook Of Continued Fractions For Special Functions (Springer Science & Business Media, 2008).
Scott, J. F. The Mathematical Work Of John Wallis (1616–1703) (Taylor and Francis, 1938).
Bowman, D. & Laughlin, J. M. Polynomial continued fractions. Acta Arith. 103, 329–342 (2002).
McLaughlin, J. M. & Wyshinski, N. J. Real numbers with polynomial continued fraction expansions. Acta Arith. 116, 63–79 (2005).
Press, W. H. Seemingly Remarkable Mathematical Coincidences Are Easy To Generate (Univ. Texas, 2009).
Euler, L. Introductio In Analysin Infinitorum Vol. 2 (MM Bousquet, 1748).
Petkovšek, M., Wilf, H. S. & Zeilberger, D. A = B (A. K. Peters Ltd., 1996).
Bailey, D., Borwein, J. & Girgensohn, R. Experimental evaluation of Euler sums. Exp. Math. 3, 17–30 (1994).
Wang, H. Toward mechanical mathematics. IBM J. Res. Develop. 4, 2–22 (1960).
Lenat, D. B. & Brown, J. S. Why AM and EURISKO appear to work. Artif. Intell. 23, 269–294 (1984).
Lenat, D. B. The nature of heuristics. Artif. Intell. 19, 189–249 (1982).
Davis, R. & Lenat, D. B. Knowledge-Based Systems In Artificial Intelligence (McGraw-Hill, 1982).
Fajtlowicz, S. On conjectures of Graffiti. In Annals of Discrete Mathematics Vol. 38, 113–118 (Elsevier, 1988).
Alessandretti, L., Baronchelli, A. & He, Y.-H. Machine learning meets number theory: the data science of Birch–Swinnerton-Dyer. Preprint at https://arxiv.org/abs/1911.02008 (2019).
Chen, W. Y., Hou, Q. H. & Zeilberger, D. Automated discovery and proof of congruence theorems for partial sums of combinatorial sequences. J. Diff. Equ. Appl. 22, 780–788 (2016).
Buchberger, B. et al. Theorema: towards computer-aided mathematical theory exploration. J. Appl. Log. 4, 470–504 (2006).
Ferguson, H., Bailey, D. & Arno, S. Analysis of PSLQ, an integer relation finding algorithm. Math. Comput. Am. Math. Soc. 68, 351–369 (1999).
Bailey, D., Borwein, P. & Plouffe, S. On the rapid computation of various polylogarithmic constants. Math. Comput. Am. Math. Soc. 66, 903–913 (1997).
Bailey, D. & Broadhurst, D. J. Parallel integer relation detection: techniques and applications. Math. Comput. 70, 1719–1737 (2000).
Wolfram, S. A New Kind Of Science Vol. 5 (Wolfram Media, 2002).
Schmidt, M. & Lipson, H. Distilling free-form natural laws from experimental data. Science 324, 81–85 (2009).
He, Y.-H. Deep-learning the landscape. Preprint at https://arxiv.org/abs/1706.02714 (2017).
Wu, T. & Tegmark, M. Toward an artificial intelligence physicist for unsupervised learning. Phys. Rev. E 100, 033311 (2019).
Greydanus, S., Dzamba, M. & Yosinski, J. Hamiltonian neural networks. In Advances in Neural Information Processing Systems (NEURIPS2019) Vol. 32, 15379−15389 (2019).
Iten, R., Metger, T., Wilming, H., del Rio, L. & Renner, R. Discovering physical concepts with neural networks. Phys. Rev. Lett. 124, 010508 (2020).
Udrescu, S. & Tegmark, M. AI Feynman: a physics-inspired method for symbolic regression. Sci. Adv. 6, eaay2631 (2020).
Wiles, A. Modular elliptic curves and Fermat’s last theorem. Ann. Math. 141, 443–551 (1995).
Smale, S. Mathematical problems for the next century. Math. Intell. 20, 7–15 (1998).
Van der Poorten, A. & Apéry, R. A proof that Euler missed…. Math. Intell. 1, 195–203 (1979).
Borwein, J., Borwein, P. & Bailey, D. Ramanujan, modular equations, and approximations to pi or how to compute one billion digits of pi. Am. Math. Mon. 96, 201–219 (1989).
Pilehrood, K. H. & Pilehrood, T. H. Series acceleration formulas for beta values. Discret. Math. Theor. Comput. Sci. 12, 223–236 (2010).
Kim, S. Normality analysis of current world record computations for Catalan’s constant and arc length of a lemniscate with a = 1. Preprint at https://arxiv.org/abs/1908.08925 (2019).
Nesterenko, Y. V. On Catalan’s constant. Proc. Steklov Inst. Math. 292, 153–170 (2016).
Zudilin, W. Well-poised hypergeometric service for diophantine problems of zeta values. J. Théor. Nomb. Bordeaux 15, 593–626 (2003).
Zudilin, W. One of the odd zeta values from ζ(5) to ζ(25) is irrational. By elementary means. Symmetry Integr. Geom. 14, 028 (2018).
Raayoni, G. et al. The Ramanujan machine: automatically generated conjectures on fundamental constants. Preprint at https://arxiv.org/abs/1907.00205 (2019).
Dougherty-Bliss, R. & Zeilberger, D. Automatic conjecturing and proving of exact values of some infinite families of infinite continued fractions. Preprint at https://arxiv.org/abs/2004.00090 (2020).
Tshitoyan, V. et al. Unsupervised word embeddings capture latent knowledge from materials science literature. Nature 571, 95–98 (2019).
Zudilin, W. A third-order Apéry-like recursion for ζ(5). Mathematical Notes [Mat. Zametki] 72, 733–737 [796–800] (2002).
Rivoal, T. Rational approximations for values of derivatives of the Gamma function. Trans. Am. Math. Soc. 361, 6115–6149 (2009).
We thank M. Soljačić, B. Weiss, D. Soudry and D. Carmon for helpful discussions. I.K. is grateful for the support of R. Magid and B. Magid and for the support of the Azrieli Faculty Fellowship. Y.M. acknowledges the support and guidance of the Israeli Alpha Program for Excellent High-School Students.
The authors declare no competing interests.
Peer review information Nature thanks Yang-Hui He, Doron Zeilberger and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Peer reviewer reports are available.
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Extended data figures and tables
The plots present the absolute difference between the PCF value and the corresponding fundamental constant (that is, the error) versus the number of terms calculated in the PCF. On the left are PCFs with exponential/super-exponential convergence rates, and on the right are PCFs that converge polynomially. The majority of previously known PCFs for π converge polynomially, whereas all of our newly found results converge exponentially.
About this article
Cite this article
Raayoni, G., Gottlieb, S., Manor, Y. et al. Generating conjectures on fundamental constants with the Ramanujan Machine. Nature 590, 67–73 (2021). https://doi.org/10.1038/s41586-021-03229-4
npj Systems Biology and Applications (2021)