[Unsolved] How many "magic squares" (combinatorial)?

  • MHB
  • Thread starter hxthanh
  • Start date
  • Tags
    Squares
In summary: Let $A$ be a set of all possible magic squares of size $3\times 3$ with row sum is $r$. Then $|A|=S_3(r)$.Now consider the following sets:$B_1$: set of all magic squares with magic number $r+4$.$B_2$: set of all magic squares with magic number $r+3$.$B_3$: set of all magic squares with magic number $r+2$.Then, we have:$B_1\cap B_2\cap B_3=\emptyset$$A=B_1\cup B_2 \cup B_3$By the principle of inclusion-exclusion,
  • #1
hxthanh
16
0
A "magic square" is an $n\times n$ table includes $n^2$ non-negative integers satisfying conditions sum on each row and each column are equal and equal to $r$.
Define $S_3(r)$ is number of all $3\times 3$ magic square with row sum is $r$

Prove that:
$\displaystyle S_3(r)={r+2\choose 4}+{r+3\choose 4}+{r+4\choose 4}$

p/s: (sorry, if my thread wrong place)
 
Mathematics news on Phys.org
  • #2
Re: [Unsolved] How many "magic square" (combinatorial)?

hxthanh said:
A "magic square" is an $n\times n$ table includes $n^2$ non-negative integers satisfying conditions sum on each row and each column are equal and equal to $r$.
Define $S_3(r)$ is number of all $3\times 3$ magic square with row sum is $r$

Prove that:
$\displaystyle S_3(r)={r+2\choose 4}+{r+3\choose 4}+{r+4\choose 4}$

p/s: (sorry, if my thread wrong place)

Only for clarification purpose: the $\displaystyle n^{2}$ numbers are $\displaystyle 1,2,...,n^{2}$ or a set of $n^{2}$ distinct nonnegative numbers with sum r?...

For example the following magic square with n=3...

$8\ 1\ 6$

$3\ 5\ 7$

$4\ 9\ 2$

... use the set 1,2,...,9 but in that case r is not an independent parameter because is...

$\displaystyle r = \frac{n\ (n^{2}+1)}{2} = 15$

Kind regards

$\chi$ $\sigma$
 
  • #3
Re: [Unsolved] How many "magic square" (combinatorial)?

hxthanh said:
A "magic square" is an $n\times n$ table includes $n^2$ non-negative integers satisfying conditions sum on each row and each column are equal and equal to $r$.
Define $S_3(r)$ is number of all $3\times 3$ magic square with row sum is $r$

Prove that:
$\displaystyle S_3(r)={r+2\choose 4}+{r+3\choose 4}+{r+4\choose 4}$

p/s: (sorry, if my thread wrong place)
The solution to 4 x 4 squares would be a lot more of a challenge. (Nerd)
There are only four 3 x 3 magic squares, with entries < 10 and r = 15, and they are rotations of one of them. ie.
\(\displaystyle \left ( \begin{array}{ccc} 8 & 1 & 6 \\ 3 & 5 & 7 \\ 4 & 9 & 2 \end{array} \right )\), \(\displaystyle \left ( \begin{array}{ccc} 4 & 3 & 8 \\ 9 & 5 & 1 \\ 2 & 7 & 6 \end{array} \right )\), \(\displaystyle \left ( \begin{array}{ccc} 2 & 9 & 4 \\ 7 & 5 & 3 \\ 6 & 1 & 8 \end{array} \right )\), \(\displaystyle \left ( \begin{array}{ccc} 6 & 7 & 2 \\ 1 & 5 & 9 \\ 8 & 3 & 4 \end{array} \right )\)

You can play with this for higher numbers than 1 - 9, but you will still only have the four rotated solutions. Thus, for valid values of r, \(\displaystyle S_3(r) = 4\).
-Dan

Addendum:
You can also have "reflections" of the original square. Such as
\(\displaystyle \left ( \begin{array}{ccc} 6 & 1 & 8 \\ 7 & 5 & 3 \\ 2 & 9 & 4 \end{array} \right )\)
and the like, so we get 8 more squares for a total of 12 overall.

Did I miss any more?

-Dan
 
Last edited by a moderator:
  • #4
Re: [Unsolved] How many "magic square" (combinatorial)?

$n^2$ non-negative integers is not necessarily different!

$\displaystyle S_3(0)={0+2\choose 4}+{0+3\choose 4}+{0+4\choose 4}=1$
$$\begin{matrix}0&0&0\\0&0&0\\0&0&0\end{matrix}$$
$\displaystyle S_3(1)={1+2\choose 4}+{1+3\choose 4}+{1+4\choose 4}=6$

$\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}1&0&0\\0&0&1\\0&1&0\end{bmatrix} \quad \begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\0&1&0\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\1&0&0\\0&1&0\end{bmatrix}$

$S_3(2)=21$

etc...

I tried transform magic square to follow
$$\begin{array}{|c|c|}\hline a&r-a-b&b\\ \hline r-a-c&a+b+c+d-r&r-b-d\\ \hline c&r-c-d&d\\ \hline\end{array}$$
 
Last edited:
  • #5
Re: [Unsolved] How many "magic square" (combinatorial)?

hxthanh said:
$n^2$ non-negative integers is not necessarily different!

$\displaystyle S_3(0)={0+2\choose 4}+{0+3\choose 4}+{0+4\choose 4}=1$
$$\begin{matrix}0&0&0\\0&0&0\\0&0&0\end{matrix}$$
$\displaystyle S_3(1)={1+2\choose 4}+{1+3\choose 4}+{1+4\choose 4}=6$

$\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}1&0&0\\0&0&1\\0&1&0\end{bmatrix} \quad \begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\0&1&0\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\1&0&0\\0&1&0\end{bmatrix}$

$S_3(2)=21$

etc...

I tried transform magic square to follow
$$\begin{array}{|c|c|}\hline a&r-a-b&b\\ \hline r-a-c&a+b+c+d-r&r-b-d\\ \hline c&r-c-d&d\\ \hline\end{array}$$
Okay. I have never seen magic squares with repeated numbers in them, so I guess my solutions would not be called "general."

-Dan
 
  • #6
Re: [Unsolved] How many "magic square" (combinatorial)?

hxthanh said:
$n^2$ non-negative integers is not necessarily different!

$\displaystyle S_3(0)={0+2\choose 4}+{0+3\choose 4}+{0+4\choose 4}=1$
$$\begin{matrix}0&0&0\\0&0&0\\0&0&0\end{matrix}$$
$\displaystyle S_3(1)={1+2\choose 4}+{1+3\choose 4}+{1+4\choose 4}=6$

$\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}1&0&0\\0&0&1\\0&1&0\end{bmatrix} \quad \begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix} \quad \begin{bmatrix}0&1&0\\0&0&1\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\0&1&0\\1&0&0\end{bmatrix} \quad \begin{bmatrix}0&0&1\\1&0&0\\0&1&0\end{bmatrix}$

$S_3(2)=21$

etc...

I tried transform magic square to follow
$$\begin{array}{|c|c|}\hline a&r-a-b&b\\ \hline r-a-c&a+b+c+d-r&r-b-d\\ \hline c&r-c-d&d\\ \hline\end{array}$$

Ok!... if we accept [because there are different definitions of 'magic square'...] that a 'magic square' is a n x n matrix with the sum of the elemnts of all rows and colums is the same number k, then, indicating $M_{n} (k)$ an n x n magic square with 'magic number' k, the following basic statement should hold...

$\displaystyle A_{n} (k) + B_{n} (1) = C_{n} (k+1)\ (1)$

... i.e. a magic square with magic number k+1 is the sum of a magic square with magic number k and a magic square with magic number 1. Now You have found that $\displaystyle S_{3} (0)=1$ and $\displaystyle S_{3} (1) = 6$... all right!...

Now $\displaystyle S_{3} (2)$ can be obtained computing the possible distict sum of all the magic square magic number 1 that is $\displaystyle S_{3} (2) = 6 + 5 + 4 + 3 + 2 + 1 = 21$. The behaviour for k > 2 will be analysed in next post...

Kind regards

$\chi$ $\sigma$
 
Last edited:
  • #7
Re: [Unsolved] How many "magic square" (combinatorial)?

hxthanh said:
A "magic square" is an $n\times n$ table includes $n^2$ non-negative integers satisfying conditions sum on each row and each column are equal and equal to $r$.
Define $S_3(r)$ is number of all $3\times 3$ magic square with row sum is $r$

Prove that:
$\displaystyle S_3(r)={r+2\choose 4}+{r+3\choose 4}+{r+4\choose 4}$
MY SOLUTION
First, we creating 2 rows into square by 2 equations $a_1+a_2+a_3=b_1+b_2+b_3=n$
Number of solutions of both equations as ${n+2\choose 2}$
Therefor, number of squares as ${n+2\choose 2}^2$ including type non-magic squares.

For each square created above, we seeking inappropriate condition:
$\begin{array}{|c|c|c|} \hline\\ a & b & n-a-b \\ \hline c & d & n- c-d\\ \hline n- a-c & n- b-d & a+b+c+d-n \\ \hline \end{array}$

We get condition is $a+b+c+d < n \Leftrightarrow a+b+c+d+e=n, \quad (0<e\le n)\quad (*)$
Number of solutions $(*)$ as ${n+3\choose 4}$
Similarly for the terms of 3th-row.

Result: Number of magic-square as
${n+2\choose 2}^2 -3 {n+3\choose 4}={n+4\choose 4} + {n+3\choose 4} + {n+2\choose 4} \quad \square$
 

Related to [Unsolved] How many "magic squares" (combinatorial)?

1. How are "magic squares" defined?

A "magic square" is a square grid filled with distinct positive integers where the sum of each row, column, and diagonal is the same.

2. How many possible "magic squares" are there?

The number of possible "magic squares" depends on the size of the grid. For an n x n grid, there are (n^2)!/(n^n) possible "magic squares."

3. What is the largest known "magic square"?

The current largest known "magic square" has an order of 404 x 404 and was discovered in 2017 by mathematicians from Japan and China.

4. Are there any unsolved questions regarding "magic squares"?

Yes, there are still many unsolved questions about "magic squares," including finding the smallest possible order for a "magic square" and determining the maximum number of "magic squares" that can be formed from a set of distinct numbers.

5. How are "magic squares" used in real life?

"Magic squares" have been used in various fields such as mathematics, art, and even cryptography. They can also be used as a tool for teaching mathematical concepts and problem-solving strategies.

Similar threads

  • General Math
Replies
2
Views
1K
Replies
68
Views
9K
  • General Math
Replies
1
Views
1K
Replies
1
Views
778
Replies
8
Views
2K
Replies
1
Views
732
  • Precalculus Mathematics Homework Help
Replies
1
Views
556
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
13
Views
2K
  • General Math
Replies
2
Views
997
Back
Top