[math-fun] Magic Sqaures
I've found a curious transformation for Magic Squares of order 4. I didn't see it in my copy of Winning Ways, so perhaps it's new. The squares use the numbers from 1-16, and the magic sum is 34. Multiply each element in the square by a small number K, and reduce mod 17. This is a permutation on the 16 non-zero residues mod 17, so the numbers are still 1-16 in some order. The sum of each row/column/diagonal is still 0 mod 17, so it might be 17, 34, or 51. 17 and 51 are less likely, having a smaller number of decompositions into A+B+C+D (with 0<A<B<C<D<17) than 34 does. So sometimes, the new object will also be a magic square. For K=2, doubling: Mark a number white if it's < 8.5, and black if it's > 8.5. Then if each line of the magic square has two black and two white cells, doubling works. (But it might not work twice.) This seems to imply a curious result: There are a lot of other groups of cells that add up to the magic constant -- the four corners, the four center cells, etc. If each line of the square has two black & two white cells, then the other groups must also. K= -1 always works, and is the standard "subtract from 17" isomorphism. K=3 works when the total "overage" of a row is 4. Overage is the number of multiples of 17 dropped in the modular reduction, floor[N/5.66], 0 if N<=5, 1 for 6-11, 2 for N>=12. Again, rows with overage/=4 are less common. Under one way of counting, there are 880 MSQ4s. 880 = 16*55. A similar story should work for Magic Squares of order 6, since 37 is prime. But the chances are smaller, since more lines have to work, and the central tendency of the line sums is weaker. For order 5, 26 isn't prime, but odd K should work (except 13). ----- Counting MSQ6s. I looked at partitioning {1...36} into six sets of six numbers that add to 111. (Then we could count all the MSQ6s for a sample of the partitions, and estimate the MSQ6 total. Counting a sample of one million would give a 3-place estimate of MSQ6s.) 36! = 3.72 * 10^41. There are binom(36 6) = 1947792 ways of picking six of 36. Of these, 32134 sum to 111. A ratio of 1/60.6. One estimate of MSQ6 is 36! / 60.6^12 /192 = 788 quadrillion. The model is you dump the 36 numbers into the square and see what the chance is that the lines add up. The count of independent constraints is 12: 5 rows, 5 columns, 2 diagonals. One row and one column are redundant, since if 5 rows work, the sixth must also, etc. The 192 is for the group-of-the-square, and some more complicated permutations of the cells that preserve lines. (Another coincidence: same size as the groups for 4^3 and 5^3 TicTacToe.) 4739 of the 32134 potential row-sets contain "1". These are potential first sets of a partition. Extending to second rows, I count 8739938 pairs of (first,second). I'm assuming the second row must contain the smallest element that's missing from the first row. The ratio, 1844 combinations per first-row, is (very roughly) 1/e of 4739. Moving to third rows, I find 4957935915 combinations, again with the smallest-unused-element restriction. The ratio triples/pairs is 567, very roughly a 1/e drop from 1844. My program fills in one element at a time, so it's running out of steam about now. 100 minutes for the triple count. But it looks like the approach of listing all possible rows as bit patterns, and filtering the list recursively, could get to row 5. (Row 6 must work, since it's dependent.) My estimate for the total number of partitions is roughly 4 trillion. Attempting to guess the number of MSQ6s per partition, I wind up with a guess of 600 quadrillion total MSQ6s. This matches the simple probability method above. If we need 1 nsec to count each magic square, that's about 20 years. Just over the edge of practicality. But the edge moves. Rich rcs@cs.arizona.edu
participants (1)
-
Richard Schroeppel