Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

A Fast Algorithm for Computing the Number of Magic Series

  • Published:
Annals of Combinatorics Aims and scope Submit manuscript

Abstract

We present a fast algorithm for computing the number of magic series, an enumeration problem of a certain integer partition. Kinnaes showed that the number appears as a coefficient in a Gaussian polynomial and that the exact value can be efficiently extracted with a finite variant of Cauchy’s integral formula. The algorithm requires a bit time complexity of \(O(m^4 M(m \log m))\) and \(O(m \log m)\)-bit space, where m is the order of the magic series and \(M(n)\) is the time complexity of multiplying two n-bit numbers. Through our analysis, we confirm that this is the most efficient among previously reported algorithms. In addition, we show that the number can be computed with a bit time complexity of \(O(m^3 \log m M(m \log m))\) by directly carrying out polynomial multiplication and division on the Gaussian polynomial. Though the space consumption increases to \(O(m^3 \log m)\) bits, we demonstrate that our method actually computes the number faster for large orders.

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

Access this article

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

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

Similar content being viewed by others

References

  1. G. E. Andrews. The Theory of Partitions, volume 2 of Encyclopedia of Mathematics and its Applications. Addison-Wesley, Reading, 1976.

  2. G. E. Andrews. Partitions: At the Interface of \(q\)-Series and Modular Forms. Ramanujan J., 7:385–400, 2003. https://doi.org/10.1023/A:1026224002193.

  3. G. E. Andrews and K. Eriksson. Integer Partitions. Cambridge University Press, 2004. https://doi.org/10.1017/CBO9781139167239.

  4. G. E. Andrews, R. Askey, and R. Roy. Special Functions, volume 71 of Encyclopedia of Mathematics and its Applications. Cambridge University Press, 1999.

  5. G. E. Andrews, P. Paule, and A. Riese. MacMahon’s Partition Analysis VI: A New Reduction Algorithm. Ann. Comb., 5:251–270, 2001. https://doi.org/10.1007/s00026-001-8011-y.

  6. D. Andrica and O. Bagdasar. The Cauchy integral formula with applications to polynomials, partitions and sequences. In Proceedings of the XVth International Conference on Mathematics and its Applications, pages 12–25. Politehnica University of Timişoara, 2018.

  7. D. Andrica and O. Bagdasar. A new formula for the coefficients of Gaussian polynomials. An. Univ. Ovidius Constanta, 27:25–35, 2019. https://doi.org/10.2478/auom-2019-0031.

  8. A. Arnold and M. Monagan. Calculating cyclotomic polynomials. Math. Comput., 80:2359–2379, 2011. https://doi.org/10.1090/S0025-5718-2011-02467-1.

  9. J. Bak and D. J. Newman. Complex Analysis. Springer-Verlag, New York, third edition, 2010. https://doi.org/10.1007/978-1-4419-7288-0.

  10. M. Beck and A. van Herick. Enumeration of \(4 \times 4\) magic squares. Math. Comput., 80:617–621, 2011. https://doi.org/10.1090/S0025-5718-10-02347-1.

  11. M. Beeler. Appendix 5: The Order 5 Magic Squares. (privately published), 1973.

  12. E. A. Bender. A generalized \(q\)-binomial Vandermonde convolution. Disc. Math., 1(2):115–119, 1971. https://doi.org/10.1016/0012-365X(71)90018-5.

  13. A. Borodin and I. Munro. The Computational Complexity of Algebraic and Numeric Problems. American Elsevier, 1975.

  14. P. B. Borwein. On the Complexity of Calculating Factorials. J. Algorithms, 6(3):376–380, 1985. https://doi.org/10.1016/0196-6774(85)90006-9.

  15. A. Bostan. Computing the \(N\)-th Term of a \(q\)-Holonomic Sequence. In I. Z. Emiris and L. Zhi, editors, Proceedings of the 45th International Symposium on Symbolic and Algebraic Computation (ISSAC ’20), pages 46–53. Association for Computing Machinery, New York, 2020. https://doi.org/10.1145/3373207.3404060.

  16. H. Bottomley. Partition and composition calculator. URL http://www.se16.info/js/partitions.htm.

  17. R. P. Brent and P. Zimmermann. Modern Computer Arithmetic. Cambridge University Press, 2010. https://doi.org/10.1017/CBO9780511921698.

  18. A. Cayley. Researches on the Partition of Numbers. Phil. Trans. R. Soc. Lond., 146:127–140, 1856. https://doi.org/10.1098/rstl.1856.0009.

  19. P. Diaconis and A. Gamburd. Random Matrices, Magic Squares and Matching Polynomials. Electron. J. Comb., 11(2), 2004. https://doi.org/10.37236/1859.

  20. K. Endo. (private communication), 2019.

  21. Free Software Foundation. The GNU Multiple Precision Arithmetic Library. URL https://gmplib.org.

  22. G. Ganapathy and K. Mani. Add-On Security Model for Public Key Cryptosystem Based on Magic Square Implementation. In Proceedings of the World Congress on Engineering and Computer Science (WCECS 2009). International Association of Engineers, 2009.

  23. J. Gathen and J. Gerhard. Modern Computer Algebra. Cambridge University Press, third edition, 2013. https://doi.org/10.1017/CBO9781139856065.

  24. R. Gerbicz. Robert Gerbicz’s Home Page. URL https://sites.google.com/site/robertgerbicz.

  25. J. W. L. Glaisher. On the number of partitions of a number into a given number of parts. Q. J. Pure Appl. Math., 40:57–143, 1909.

  26. I. J. Good. A new finite series for Legendre polynomials. Math. Proc. Camb. Phil. Soc., 51(2):385–388, 1955. https://doi.org/10.1017/S0305004100030334.

  27. W. G. Griffiths. On Integer Solutions to Linear Equations. Ann. Comb., 12:53–70, 2008. https://doi.org/10.1007/s00026-008-0336-3.

  28. H. Gupta, C. E. Gwyther, and J. C. P. Miller. Tables of Partitions, volume 4 of Royal Society Mathematical Tables. Cambridge University Press, 1958.

  29. B. Haible and T. Papanikolaou. Fast Multiprecision Evaluation of Series of Rational Numbers. In J. P. Buhler, editor, Algorithmic Number Theory (ANTS 1998), in Lecture Notes in Computer Science, 1423, pages 338–350. Springer, Berlin, Heidelberg, 1998. https://doi.org/10.1007/BFb0054873.

  30. D. Harvey and J. Hoeven. Integer multiplication in time \(O(n \log n)\). Ann. Math., 193(2):563–617, 2021. https://doi.org/10.4007/annals.2021.193.2.4.

  31. G. Kato and S. Minato. Enumeration of associative magic squares of order 7. 2019. arXiv:1906.07461.

  32. Y. Kim and J. Yoo. An algorithm for constructing magic squares. Disc. Appl. Math., 156(14):2804–2809, 2008. https://doi.org/10.1016/j.dam.2007.09.029.

  33. D. Kinnaes. Calculating exact values of \(N(x, m)\) without using recurrence relations. 2013. URL http://www.trump.de/magic-squares/magic-series/kinnaes-algorithm.pdf.

  34. D. E. Knuth. Seminumerical Algorithms, volume 2 of The Art of Computer Programming. Addison-Wesley, Reading, third edition, 1997.

  35. M. Kraitchik. Mathematical Recreations. George Allen & Unwin, 1943.

  36. B. Kronholm. On congruence properties of the coefficients of Gaussian polynomials. Proc. Amer. Math. Soc., 147:489–495, 2019. https://doi.org/10.1090/proc/14159.

  37. H. T. Kung. On Computing Reciprocals of Power Series. Numer. Math., 22:341–348, 1974. https://doi.org/10.1007/BF01436917.

  38. H. T. Kung and D. M. Tong. Fast Algorithms for Partial Fraction Decomposition. SIAM J. Comput., 6(3):582–593, 1977. https://doi.org/10.1137/0206042.

  39. U. V. Linnik. On the least prime in an arithmetic progression I. The basic theorem. Rec. Math. (Mat. Sb.) N.S., 15 (57):139–178, 1944.

  40. P. Loly, I. Cameron, W. Trump, and D. Schindel. Magic square spectra. Linear Algebra Applica., 430(10):2659–2680, 2009. https://doi.org/10.1016/j.laa.2008.10.032.

  41. P. A. MacMahon. Combinatory Analysis, volume I. Cambridge University Press, 1915.

  42. A. J. Menezes, P. C. Oorschot, and S. A. Vanstone. Handbook of Applied Cryptography. CRC Press, 1996. https://doi.org/10.1201/9780429466335.

  43. P. L. Montgomery. Modular Multiplication Without Trial Division. Math. Comput., 44:519–521, 1985. https://doi.org/10.1090/S0025-5718-1985-0777282-X.

  44. A. O. Munagi. Computation of \(q\)-Partial Fractions. Integers, 7(25), 2007.

  45. A. O. Munagi. The Rademacher conjecture and \(q\)-partial fractions. Ramanujan J., 15:339–347, 2008. https://doi.org/10.1007/s11139-007-9080-2.

  46. J. M. Pollard. The Fast Fourier Transform in a Finite Field. Math. Comput., 25:365–374, 1971. https://doi.org/10.1090/S0025-5718-1971-0301966-0.

  47. A. Ripatti. On the number of semi-magic squares of order 6. 2018. arXiv:1807.02983.

  48. A. Schönhage and V. Strassen. Schnelle Multiplikation großer Zahlen. Computing, 7:281–292, 1971. https://doi.org/10.1007/BF02242355.

  49. A. V. Sills and D. Zeilberger. Formulæ for the number of partitions of \(n\) into at most \(m\) parts (using the quasi-polynomial ansatz). Adv. Appl. Math., 48(5):640–645, 2012. https://doi.org/10.1016/j.aam.2011.12.003.

  50. N. J. A. Sloane. The On-Line Encyclopedia of Integer Sequences. URL https://oeis.org.

  51. R. P. Stanley. Enumerative Combinatorics, volume I. Cambridge University Press, 1997. https://doi.org/10.1017/CBO9780511805967.

  52. I. Stewart and D. Tall. Complex Analysis. Cambridge University Press, second edition, 2018. https://doi.org/10.1017/9781108505468.

  53. Y. Sugizaki and D. Takahashi. Fast Computation of the Exact Number of Magic Series with an Improved Montgomery Multiplication Algorithm. In M. Qiu, editor, International Conference on Algorithms and Architectures for Parallel Processing (ICA3PP 2020), in Lecture Notes in Computer Science, 12453, pages 365–382. Springer, Cham, 2020. https://doi.org/10.1007/978-3-030-60239-0_25.

  54. J. J. Sylvester. On Subinvariants, i.e. Semi-Invariants to Binary Quantics of an Unlimited Order. Amer. J. Math., 5(1):79–136, 1882. https://doi.org/10.2307/2369536.

  55. W. Trump. Magic Series: Exact number of series up to order 1000. URL http://www.trump.de/magic-squares/magic-series/exact.htm.

  56. W. Trump. Theory of Magic Series. 2002. URL http://www.trump.de/magic-squares/magic-series/magic-series.pdf.

  57. V. Shoup. NTL: A Library for doing Number Theory. URL https://libntl.org.

  58. G. Xin. Constructing all magic squares of order three. Disc. Math., 308(15):3393–3398, 2008. https://doi.org/10.1016/j.disc.2007.06.022.

Download references

Acknowledgements

The authors are grateful to the anonymous reviewers for their insightful comments and suggestions. This research in part used the computational resources of the Cygnus provided by the Multidisciplinary Cooperative Research Program in the Center for Computational Sciences, University of Tsukuba.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Yukimasa Sugizaki.

Ethics declarations

Conflict of Interest

The authors declare that they have no conflict of interest.

Additional information

Communicated by Alin Bostan.

Publisher's Note

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

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Sugizaki, Y., Takahashi, D. A Fast Algorithm for Computing the Number of Magic Series. Ann. Comb. 26, 511–532 (2022). https://doi.org/10.1007/s00026-022-00584-5

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00026-022-00584-5

Keywords

Mathematics Subject Classification