3 x 3 MAGIC SQUARE SOLUTIONS
Represent square using letters:
A B C
D E F
G H I
A+B+C=S=D+E+F=G+H+I; A+B+C+D+E+F+G+H+I=3S.
A+E+I=B+E+H=C+E+G=D+E+F=S
(A+B+C+D+E+F+G+H+I)+3E=4S; 3S+3E=4S, E=S/3.
A+E+I=S, I=S-E-A, I=2S/3-A.
H=S-E-B, H=2S/3-B.
C=S-(A+B).
G=2S/3-C=2S/3-S+(A+B), G=A+B-S/3.
D+G=B+C=B+S-(A+B)=S-A; D=S-A-G=S-A-A-B+S/3, D=4S/3-(2A+B).
F=2S/3-D=2S/3-4S/3+2A+B, F=2A+B-2S/3.
Completed square:
A B S-(A+B)
4S/3-(2A+B) S/3 2A+B-2S/3
A+B-S/3 2S/3-B 2S/3-A
So A and B are arbitrary; S must be a multiple of 3 if square is to be whole numbers only.
EXAMPLE: A=1, B=5, S=18:
1 5 12
17 6 -5
0 7 11
Single digits can be 1 to 9 (sum=45) or 0 to 8 (sum=36). The common sum is 45/3=15 or 36/3=12.
In one case the middle digit is 5 (15/3) and in the other it's 4 (12/3).
In the first case, 5 must be in the middle of the square, and we need to see where 9 fits in. The common sum is 15 so 15-9=6 and the other two numbers must be (1,5) or (2,4). This tells us that 9 can only participate in two sums and therefore it must be in the middle of a side with 2 and 4 on either side of it. So B=9 and A=2.
2 9 4
7 5 3
6 1 8
is a solution. In the case for 0-8 we simply subtract 1 from each square:
1 8 3
6 4 2
5 0 7 and we can reorientate this:
7 2 3
0 4 8
5 6 1
There we have it: two solutions.