Skip to main content
QUICK REVIEW

[Paper Review] Counting magic squares in quasi-polynomial time

Alexander Barvinok, Alex Samorodnitsky|ArXiv.org|Mar 8, 2007
Markov Chains and Monte Carlo MethodsMathematics25 references5 citations
TL;DR

This paper presents a randomized quasi-polynomial time algorithm to approximate the number of $n \times n$ magic squares with line sum $t$ within relative error $\epsilon$, leveraging log-concave functions and volume estimation via matrix scaling. The key contribution is a complexity of $(1/\epsilon)^{O(1)} N^{O(\log N)}$ where $N = nt$, significantly improving on prior methods for counting contingency tables with balanced margins.

ABSTRACT

We present a randomized algorithm, which, given positive integers n and t and a real number 0< epsilon <1, computes the number Sigma(n, t) of n x n non-negative integer matrices (magic squares) with the row and column sums equal to t within relative error epsilon. The computational complexity of the algorithm is polynomial in 1/epsilon and quasi-polynomial in N=nt, that is, of the order N^{log N}. A simplified version of the algorithm works in time polynomial in 1/epsilon and N and estimates Sigma(n,t) within a factor of N^{log N}. This simplified version has been implemented. We present results of the implementation, state some conjectures, and discuss possible generalizations.

Motivation & Objective

  • To develop an efficient algorithm for approximating the number of $n \times n$ non-negative integer matrices (magic squares) with all row and column sums equal to $t$.
  • To provide a randomized algorithm with quasi-polynomial time complexity in $N = nt$, achieving relative error $\epsilon$ for any $\epsilon > 0$.
  • To extend the approach to general contingency tables with given row and column sums, particularly when margins are balanced.
  • To establish theoretical bounds on the ratio between the number of magic squares and a related integral involving a log-concave density function.
  • To implement and evaluate a simplified polynomial-time version of the algorithm for practical computation.

Proposed method

  • The algorithm uses a randomized approach based on estimating the volume of a transportation polytope via a log-concave density function $\phi$ defined on the simplex $\Delta$.
  • It applies matrix scaling techniques to transform the problem into one where the permanent of a matrix approximates the number of integer points in the polytope.
  • The method relies on the homogeneity and monotonicity of the function $f(X) = \text{per}(X)$ and its factorization into a log-concave part $\phi$ and a slowly varying part $p$.
  • A key component is the use of a threshold $T$ in the integration domain to control error, with bounds derived using properties of log-concave functions and symmetric means.
  • The algorithm employs importance sampling and volume estimation techniques to approximate the integral $\int_Q f \, d\mu$, where $Q$ is the set of non-negative matrices with row sums equal to 1.
  • For the simplified version, the algorithm estimates the number of magic squares within a factor of $N^{O(\log N)}$ using polynomial-time sampling and scaling.

Experimental results

Research questions

  • RQ1Can the number of $n \times n$ magic squares with line sum $t$ be approximated within relative error $\epsilon$ in quasi-polynomial time?
  • RQ2What is the computational complexity of approximating the number of contingency tables with given row and column sums when margins are balanced?
  • RQ3How does the ratio $c(n,t) = |\Sigma(n,t)| / \int_\Delta \phi \, d\mu$ scale with $N = nt$, and can it be bounded by $N^{O(1)}$?
  • RQ4Can the permanent of a matrix be efficiently approximated using volume estimation and log-concave function integration?
  • RQ5What are the theoretical and practical bounds on the accuracy of heuristic formulas for contingency table counts, such as the Diaconis-Efron approximation?

Key findings

  • The paper presents a randomized algorithm that approximates $|\Sigma(n,t)|$ within relative error $\epsilon$ in time $(1/\epsilon)^{O(1)} N^{O(\log N)}$, where $N = nt$.
  • A simplified version of the algorithm runs in polynomial time and approximates $|\Sigma(n,t)|$ within a factor of $N^{O(\log N)}$.
  • The algorithm is implemented and validated on small instances, with results reported in Section 1.4, supporting the theoretical bounds.
  • Theoretical analysis shows that the ratio $c(n,t) = |\Sigma(n,t)| / \int_\Delta \phi \, d\mu$ is bounded by $N^{O(\log N)}$, with conjectures suggesting it may be $N^{O(1)}$ under stronger permanent inequalities.
  • The method generalizes to contingency tables with equal row sums or equal column sums, yielding similar complexity bounds.
  • The approach relies on the homogeneity and monotonicity of the permanent and the factorization of the integrand into a log-concave and slowly varying part.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.