Problems & Puzzles: Puzzles


Puzzle 865. Area Magic Squares

What is wrong in the magic square below?

2 7 6
9 5 1
4 3 8

William Walkington saw that while the 9 integers inside the cells are different, the geometric area of the 9 cells containing these 9 integers, are equal. That's what is wrong in there!

Then William started looking for a scheme such that these 9 cells could be drawn in a simple way and that the geometrical area of the 9 cells were in correspondence to the 9 integers contained in them.

Here is his first approximate solution.

On December 30 2016, he published this solution/greetings in his blog and asked for better and exact solutions.

The first exact solution came from Walter Trump, following an idea of Inder J. Taneja about to use the sequence 5 to 13 instead of the sequence 1 to 9.

The whole story about the Trump's findings and method is here. From this we now know that:

a) Not all sequences of integers produce a valid geometrical solution
b) But when a sequence has a solution there is always a second one
c) Area Magic Squares are not possible for nxn orders n>3.

A valid solution is such that the four slanted straight lines that produce the 9 cells inside the perimeter square, must intersect, by pairs, out of the perimeter square (if all the polygons are going to be quadrilaterals) or at the most in the border of the perimeter square (then, one or two of the 9 polygons are going to be triangles).

The algorithm developed by Trump in order to try to get a valid solution works the sequence of 9 integers as input and produces the 4 slopes for the 4 slanted straight lines that produces the 9 areas inside the perimeter square.

Trump's algorithm
Input Immediate Output Ulterior Output Condition satisfied
9 integers, Ni 4 slopes, Mi 9 Areas, Ai (Ni/Nj)=(Ai/Aj) for all i<>j

While knowing the 9 integers we can check very easily the magical condition, due that in general the 4 slopes and the 9 areas are non-integer numbers we can not check the area magical condition as easily as for the integers magical condition.

More over, there is not a way to compute the ulterior 9 areas from the only knowledge of the 4 slopes, first of all because you need to define a numerical size for the perimeter square.

The only good new in these last worries is that Francis Gaspalou found the exact arithmetical conditions that relates the 9 given integers (Aij, in his equations) and the 4 slopes (m1 to m4) for the 4 straight lines, in any valid solution.

This is not a candy, or yes?

Is there a way to avoid that irritating "u" strange value?

Is there a way to relate directly the 9 integers with the 4 slopes and nothing more?

Well, it's time to stop crying, is better to start asking

Q1. Is there a valid area magic square for a set of 9 prime numbers, using the Trump's approach? (See this site for prime magic square examples)

Q2. Is there another geometrical simple scheme to approach -other than the Trump's one-to the original William's aim: (looking for a scheme such that these 9 cells could be drawn in a simple way and that the geometrical area of the 9 cells, were in correspondence to the 9 integers contained in them)

Contribution came from Jan van Delden


Jan wrote:

Question 1:


I converted a magic square consisting of palprimes: 


Contributed by Carlos Rivera and Jaime Ayala to on May 22, 1999.


In white the direction coefficients.

The quadrilaterals are numbered in the style of Gaspalou: Aij:  Area at row i and column j.

m2= 0.0753157136185
m3= 0.0643670825273
S = A11+A12+A13=3.A22=37702429563

A check on the difference between the approximation of the value of S given the values of m[i] and Aij reveals |approx(S)-S|<0.1 for all 4 equations described below. However, I used a different set of equations.


Question 2:


In the given link the work by Gaspalou can be found. He uses a square of size 6u by 6u. The total area is therefore (6u)^2 which should equal 3S, with S the magic-square constant. So one could substitute u^2=S/12 in his equations to find the correct value for u.

I decided to try and find similar equations using a slightly different approach, compared with Gaspalou:

  • Take the origin in the center of the magic square
  • I prefer that the absolute size of the parameters m[i] in the equations are nearly equal
  • I prefer that the construction process is still visible in the presentation of the equations.

For the near horizontal lines I used a direction-vector of the form (1,m[i]), i.e. m[i]=direction coefficient.

For the near vertical lines I used a direction-vector of the form (m[i],1), i.e. m[i]=1/(direction coefficient).

  • Initial values of these parameters are found by considering the initial areas in the corners as being square.
    For instance m1=(sqrt(A11)-sqrt(A13))/(sqrt(S-A11-A13)=-0.06848 pretty close to -0.0768

The equations are:

24(1-m4.m1)^2.A11=S [2(3m4.m1-m4-2)(3m4.m1-m1-2)+m4(3m4.m1-m1-2)^2+m1(3m4.m1-m4-2)^2]

24(1-m1.m2)^2.A13=S [2(3m1.m2+m1-2)(3m1.m2+m2-2)-m1(3m1.m2+m2-2)^2-m2(3m1.m2+m1-2)^2]
24(1-m2.m3)^2.A33=S [2(3m2.m3-m2-2)(3m2.m3-m3-2)+m2(3m2.m3-m3-2)^2+m3(3m2.m3-m2-2)^2]
24(1-m3.m4)^2.A31=S [2(3m3.m4+m3-2)(3m3.m4+m4-2)-m3(3m3.m4+m4-2)^2-m4(3m3.m4+m3-2)^2]


Maybe you can appreciate the symmetry here. Every equation is invariant to the order of the values m[i].
In this case each equation can be written as a function of m[i]+m[j] and m[i].m[j], as an example:


24.(1-m1.m2)^2.A13 = -S [(m1+m2)(9(m1.m2)^2-17(m1.m2)+8)-6(m1.m2)^2+14(m1.m2)-8]


As a side note: if the Aij are about the same size we expect the m[i] to be close to 0, so m[i].m[j] is much closer to 0.
If we put this product equal to 0 we get, as an approximation:


24.A13 = approx = 8.S [1-(m1+m2)]

This suggests that if A13>S/3=A22 we should have m1+m2<0 as is the case. 


The two pairs of equations belonging to A11,A33 and A13,A31 are similar.

Only a few signs must be changed, due to the quadrant in which the Aij are situated.


This can be written into 4 equations, F[i](m1,m2,m3,m4)=0, each of which is a polynomial in 2 of the m[i] and of order 3.

One could solve these by using Here F is a vector consisting of the F[i], J the Jacobian of F, dm a vector of sought increment of m (a vector of the m[i]), so in the next step we use m+dm. This process will only be numerically stable if the pivots in the matrix J are not close to 0. Or in other words the increment dm will not suddenly ďgo all over the placeĒ.

For those people who are not into Linear Algebra, an example:




                       =x^2y^2-1 + 2x^2.ydy+2y^2.xdx+ terms of higher order in dx,dy


Where we assume that if dx,dy are small, the terms of higher order in dx,dy will be very close to 0
Start with values for x,y  and assume F(x+dx,y+dy) will be 0, we get an equation like:

A second function G(x,y) would give a second linear expression in dx,dy which we could solve together.


The Jacobian J consists of the partial derivatives of these functions F en G towards x and y (in matrix form).

Here  dF/dx=2x^2.y and dF/dy=2y^2.x, the same expressions, which are of course much easier to compute. 
The expression for F(x+dx,y+dy) describes the tangent plane at the graph of F(x,y) at the point (x,y). We look for the point in this plane where F(x+dx,y+dy)=0. Or in other words, the same process as applying Newton Raphson.


I didnít find a criterion relating the numbers Aij with existence of a solution (I didnít try). For instance the fact that the lines belonging to m1 and m3 must intersect on or outside the magic-square translates to |m1-m3|<2/3. But since the equations are rather complex this does not translate easily to the given numbers/areas. My intuition tells me the ratio of the areas in the opposite diagonal corners of the magic square canít be too large (if one divides the larger value through the smaller one).

In the blog of William Walkington the given magic square with the numbers 2..10 would give a ratio of: 9/3=3. All other shown magic squares with a solution have a smaller maximum value for this ratio. The square with the numbers 1..10 (which has no solution) has a value of 8/2=4>3.


The prime magic square with A11=43,A13=67,A33=31,A31=7 and S=111 has a maximum ratio of A13/A31=67/7 and does not give a solution.


He already sent this on Feb 04, 2017:

The Prime Area Magic Square with minimal magic sum S=213.


On Feb 25, 2017, Jan sent a new contribution on the same theme.

The major new issues are:

a) Invariance relation between the parameters

b) Two algorithms

c) Area semi-magic squares with integer coordinates

 Please see his contribution here.


On March 5, 2017, Jan updated the document linked above. Please see this new document here.




Records   |  Conjectures  |  Problems  |  Puzzles