GENERATING AND COUNTING REGULAR PERFECT NUMBER SQUARES
(An extension to the Siam system)
A number square is an array of numbers in which the rows columns and diagonals all add up to the same total. Here are three examples (and there is a small selection of other types of square in the last section):-
In each of the above examples the numbers used are sequential, starting from one up to the number of cells in each square, (e.g. 1 to 25 in a five x five). Just using these numbers there are hundreds of ways to place the numbers in the square, and most of these will produce all sorts of random totals for the rows and columns. In the illustrations all rows and columns sum to a specific number. So one might be tempted to ask how on earth can we easily choose where to start and how to continue, in order to produce perfect squares, and how many will there be? And how do we decide what makes a perfect square? This latter question is the easiest to answer! The three by three is not a perfect square. The broken diagonals do not sum to 15! 8 +5+2=15, but 1+7+4=12, and 6+3+9=18. On the other hand, the broken diagonals of the four by four do sum to 34: 5+9+12+8=34, and 4+6+13+11=34. The four by four is looking pretty perfect. Yet, it is still better! The
corners sum to 34: 10+15+1+8=34. In fact this square is so perfect that there are numerous groups of four numbers all totalling 34.
The five by five is also a perfect square, the broken diagonals: 6+25+14+3+17=65 etc., the corners and centre: 23+15+1+17+9=65, other groups of five: 10+1+24+17+13=65!
So now to the more difficult question of where to start in laying out the numbers!
The four by four is particularly interesting because there is an elegant pattern to the array. It also appears to be the only pattern, but there are ways to produce different squares from the same pattern. If we look at the field of numbers below, the four by four square is outlined. The numbers in red indicate the pattern used to create the square.
The numbers coloured red form a diamond pattern, the numbers coloured green form a similar diamond downwards, but remember to make the horizontal numbers total 9, e.g. 4+5=9; 3+6=9; 7+2=9; and 1+8=9, otherwise it will not work! You will also see that the numbers 9,10,11,12 also form the same diamond upwards to the left, and the numbers 13,14,15,16; downwards to the left, making the sum 25 all the way.(viz. 12+13=25; 14+11=25; 15+10=25; 16+9=25.) 25 added to the nine makes the required total of 34. It is, however, only necessary to remember the first diamond and that the horizontal pairssum to nine. This is because, once you have laid the numbers one to eight, and guessed where to put the nine, the rest can be placed by logic, as illustrated below. Once the question mark is calculated there is only one number to calculate alongside, and so on until you need to use a diagonal. The best guess for the nine is in the columns that sum to ten, the more central square being the better choice.
The first set uses a slight variation of the numbers, viz. The two and the three are reversed.
The second set shows that you can use different sequences of numbers.
You are now in a position to find out which of the positions for the nine produce perfect or just interesting squares.
You will need to remember that the diagonals need to add up to 34 to complete the squares.
In some cases it is only a broken diagonal that totals 34. These I call imperfect squares, because only one or two of the diagonals total 34.
In fact there are only three different arrangements of numbers producing perfect squares. The internet says 48, but that is because each number field generates sixteen squares, which to me are all the same. You may well think you have found more, if you experiment with different number sequences in the diamond, but if you look at the numbers surrounding the ‘one’, then you will see that very different looking squares are actually the same as one of the three, but with the numbers rotated or reflected or both. The three are illustrated below with a non-different variant!
THE PATTERN FOR A FIVE BY FIVE.
As the size of square increases the difficulty of finding the right combination of numbers for a perfect square also increases. But the Chinese have the answer – as always. They observed that the numbers in perfect squares were often related by the movement two squares up and one square right. And having observed this relationship they used it in the game of chess as the knight’s move. It was probably observed in the three by three square first of all. As you can see, page 1, one to two, two to three, seven to eight, and eight to nine, are all related by the knight’s move. And amazingly enough, four to five and five to six!!!! But to see this latter relationship properly, you need to put two more three by three squares alongside the first square, one to the left and one to the right. This placing of identical squares alongside each other is crucial to the use of the ‘knight’s move pattern’ for the generation of perfect squares. The number field produced by this assemblage of squares is shown above for the four by four square. The nine shown boxed (on the number field on page one) is in an identical square and in the same relative position.
To construct a perfect five by five square, you simply place the numbers into the grid using the knight’s move, two up and one to the right. Start in the coloured square and try not to be confused by the other numbers milling around there. One to two, two to three, and then;
to position the four we need to utilise the concept of adjacent squares, as illustrated in the field above. This means that, in the square imagined below the main square, the three is positioned, as shown, in the top row of that square. Three to four, four to five, and we have arrived back at the one. To create a number field we just repeat the sequence one to five, as illustrated in the appropriate places in the field.
It is evident that there are twenty choices for placing the six in the 5 by 5 square, once the first five numbers are laid (twenty-five minus the five numbers just inserted). We cannot continue the sequence since the six falls where the one is! (The one is, as we started, in the bottom left corner of the square, and this square is repeated above and to the right of the centre square.) To produce a perfect square the six may be placed below the five, as illustrated. The number chain then continues until the eleven falls on the six, but do not panic, just remember that you placed the six below the five, so – place the eleven below the ten. And continue using the knight’s move until the sixteen falls on top of the eleven. Then just place the sixteen below the fifteen, and continue on until the twenty one falls on top of the sixteen, then place the twenty-one below the twenty. The resulting square, barring accidents, is perfect. It is illustrated in the field above, and in its correct position in
that field. Completing the unfinished centre square by moving numbers to their correct positions is left to you!
COUNTING HOW MANY PERFECT SQUARES ARE POSSIBLE
Since there are twenty positions for placing the six, it is evident that finding perfect squares is still a bit of a problem. It will be noted that once the position of the six is chosen – as below the five for example – then that position is chosen each time we reach a multiple of five. It has been found by trial and error that this is the simplest way.
Let us first see what happens if we choose a different position for the six. This time we will start with the one in the middle. And put the six alongside and to the left of the five; the eleven alongside and to the left of the ten, etc. On completion we find that the main diagonals total: 20+23+1+9+12=65, and 21+11+1+16+6=55; not a very pretty arrangement! However, the broken diagonal: 8+23+13+3+18=65, the total we are looking for; this means if we make twenty-three the centre of the square, as illustrated, we have a fairly pretty arrangement, but not a perfect square. I call these interesting or imperfect squares.
You might like to try putting the six alongside the five and to the right, not left. This produces a disaster of a square!!
There is a simple pattern for positioning the six in order to arrive at perfect squares, and the pattern is best seen if we start, once again with the number one, but this time in the centre of the square:-
If the six is placed on a square labelled ‘N’. NO SQUARE IS PRODUCED.
If the six is placed on a square labelled ‘I’. INTERESTING SQUARES CAN BE SELECTED, (by selecting the appropriate number to be the centre of the square as
illustrated by the number fields above).
If the six is placed on a square labelled ‘P’, PERFECT SQUARES ARE GENERATED.
The eleven, sixteen, and twenty-one, when baulked by existing numbers, may similarly only be placed in squares marked ‘P’ if perfect squares are to result.
So far we have only placed the baulked numbers in the same relative position at each change. E.g. the baulked numbers are always placed, under the five, ten, fifteen and twenty, or always placed alongside, or always placed at the same fixed position from these ‘break’ numbers. This is a simple (but not general) rule for making perfect squares and works particularly well as the size of square rises above a five by five. However, with a five by five square, the numbers after the break numbers may be placed in any of the squares marked as P. This means there are four positions for the six, three positions for the eleven, and two for the sixteen. This means that there must be 4x3x2=24 perfect squares using this knight’s move.
Are there any more? Well you may have guessed, as in the four by four square, we can change the first five numbers around, e.g. 1, 2, 3, 5, 4. There is a limiting factor however, that stops us making thousands of different squares. If we look back to the first example of a five by five and starting from the one, move two along to the right and one down, then we see that the number sequence we have laid is not, 1,2,3,4,5; but 1,3,5,2,4. Similarly as we move around we see the sequence, 1,5,4,3,2; and 1,4,2,5,3. We have thus laid four number sequences in each of our twenty four squares. This reduces the number possible considerably!! By my calculations there are only 144 different perfect squares ( you could say 144 times 25 i.e. 3,600, but they are not different number fields). Since the one is fixed there are only four numbers to be re-arranged. Thus there are just 4x3x2 variations with four used each time that makes just six sequences to be used in each of the twentyfour squares; 144 in total. Your confirmation is invited. E-mail:- squares@taudevinengineering.co.uk
Gaspalou (see last pages) seems to have found irregular squares and surely some irregular five by fives could exist?
All five by five perfect squares appear to be most perfect squares; see definition below. Page 11.
WHAT IS THE TOTAL REQUIRED IN A LARGER SQUARE?
If we consider the three by three, we have used the numbers one to nine, if we add these up and divide by three (there are three rows and three columns), we obtain the total.
1+2+3+4+5+6+7+8+9=45; 45/3 = 15. Now adding up 25 numbers for a five by five is a bit laborious. There is a quick way. In a three by three, nine times ten =90 which when divided by two gives 45!! The total we were looking for. In a four by four, sixteen times seventeen = some large number, but as we are about to divide by two we only need to multiply seventeen by eight which is easier and makes 136, if we divide by four (for the four rows and columns) this gives us the 34 we need. So in general, we just multiply the number of cells in the square by one extra then divide by two and then divide by the side of square.
So for a five by five we have: 25×26/ 2×5 which may be simplified (by using a calculator or) 5×13 = 65. For a seven by seven, we have: 49×50/2×7 = 7×25 = 175.
HOW DO WE GET THE SQUARE TO GIVE A DIFFERENT TOTAL?
This is easy for some numbers, but not for others. For a five by five, if we require a total of 70 then we simply add one to every number in the square. Which means we start at 2 and finish at 26. In general if we require a different total say 72, then deduct 65 from the 72 = 7, divide by five = 1 remainder 2. Add one to every number and an extra two, the remainder, to another five. The square will stay pretty if you use a group of five as laid initially; see below; the figures in red have had two added to them:-
To make an even higher total, say 96, then deduct 65 from the 96 = 31; divide this by five = 6 remainder 1. Thus you add six to every number and one extra to a selected five numbers.
GENERATING SEVEN BY SEVEN SQUARES
The same system is used as for a five by five square. The pattern for positioning the eight is shown below. Remember to use the same move for fourteen to fifteen as you did for seven to eight, and continue with the same movement at each of the multiples of seven.
HOW MANY SEVEN BY SEVEN PERFECT SQUARES CAN BE FOUND?
This is a bit of a problem. With the five by fives it was simple, but there are some differences in the seven by seven. Applying the same reasoning it would appear that for each of the eighteen positions that produce perfect squares, it would be possible to use any of them in any order. This appears not to be the case. Once you have chosen a yellow coloured square for the continuation, it seems that you must use the remaining yellows for the other continuations; mixing yellows and other colours (red or green) does not produce perfect squares. With this reasoning the eighteen potential squares appear to reduce to three!! If this is the case, then my conjecture is that there are three choices for the eight using the patterns as illustrated at P1, P2, or P3. The numbers one to seven can be placed in 720 sequences (e.g. 1, 3, 2, 4, 5, 6, 7 ). Each sequence produces two squares, for example 1,2,3,4,5,6,7 produces the same square as 1,7,6,5,4,3,2 as can be demonstrated by writing them out. The one is a rotation of the other about a diagonal. The numbers 1, 8, 15, 22, 29, 36, 43 can be placed in 720 sequences in their coloured squares only; these all appear to produce different squares. There are three patterns of coloured squares available, as above (P1, P2, and P3); there are therefore, 360*720*3=777,600 perfect squares.
Gaspalou, (see later pages) seems to have found perfect squares which do not follow the regular pattern. How do you count them?
I would be delighted to hear from anyone who has a better method for counting the squares or a more logical way of doing it from the generating pattern, or any other method for generating perfect squares; squares@taudevin-engineering.co.uk.
Looking again at the diagram above it would appear that the extended knight’s move and the double extended knight’s move do not produce original squares. Each ‘a’ square is covered by the shown positioning of 1 to 7 producing mirror images. Each ‘b’ position produces a square as the ‘a’ position, but with a different No sequence; e.g. the No sequence for the square shown is: 1, 4, 7, 3, 6, 2, 5. On the right is shown the sequence 1,2,3,4,5,6,7; giving the sequence shown! 1.6.4.2.7.5.3. Evens then odds!!! Thus the extended knight’s move does not produce more squares! Similarly for the double extended knight’s move. It just gives a different No sequence.
It also appears that the P3 position produces ‘most perfect squares’ as defined by Ollerenshaw and Br÷e (see page 10), {What I now like to call exceptionally perfect squares}, provided the pattern of seven is as on a playing card, i.e. with the row of three vertical, viz. the stars in the above square, page 7.
OTHER SIZES OF SQUARE
It would be a very perceptive question to ask, what happened to the six by six. It would be equally alarming to mention an eight by eight, or a nine by nine.
The simple method outlined above works when the side of square is a prime number. It sort of works for odd numbers, but usually, if the odd number is not prime then perfect squares do not fall out. 49 by 49 is an exception, it produces perfect squares, whereas 25 by 25 does not!
A six by six perfect square has not yet been achieved as far as I can ascertain. There are examples of eight by eight squares, but I have not discerned an easily recognised pattern in any of these. The knight’s move is in evidence, but not consistently. Some of these ‘problem’ squares are illustrated later.
THE ELEVEN BY ELEVEN SQUARE
There are TWO possible ‘Knight’ moves; the normal – starting the first run of numbers at ‘A’, and the single extended – starting at ‘H’. Illustrated in the grid below are two groups of letters, A, B, C, D and E, F, G, H. Inspection shows that using A, B, C, or D for the numbers produces some sort of symmetrical image, so just one needs to be used.
Similarly for E, F, G, and H.
Each of these moves generates a series of perfect squares just like the seven by seven, using any of a number of continuation positions for the 12, 23, 36… etc. There are eleven of these continuation positions, coloured red and dark blue. However only seven are available with any one ‘knight’ move since three are repeats (‘A’, ‘C’, & ‘G’) & one is used by the first lay. Based on the seven by seven we instantly arrive at the number of possible squares as:-
Base moves = 2
Continuation positions = 7
Continuation sequences= 1,814,400
Base number Sequences also = 10*9*8*7*6*5*4*3 = 1,814,400
A grand total of regular squares = 1,814,400*1,814,400*7*2 = 46,088,663,040,000
THIRTEEN BY THIRTEEN
Starts @ A, E, F
Follow on @ B, C, D, E, F, G, H, J, K
There are three groups of letters, A, B, C, D. and E, H, J, K; and F, G.
There are therefore, three choices for start.
There are nine choices for follow on.
There are 3,113,510,400 number sequences.
Therefore there are 1,548,737,096,417,280,000 possible squares.
THE NINE BY NINE SQUARE.
This, as mentioned, is a problem child. Because of its symmetries perfect squares are hard to find and are produced by breaking the symmetry in special ways. Here is an example of a Hendricks square, culled from the internet, all rows, columns and diagonals sum to 369. It is generated using the number sequence, 1,2,5,6,4,7,8,9,3.
The continuations are not as for the five by five and seven by seven, since the 46 and 64 are placed on normally forbidden squares, probably to break the symmetry. The Margossian family of these squares is also on the net!
There are lots of number sequences which generate perfect squares, but the standard sequence:- 1,2,3,4,5,6,7,8,9, does not appear to work. It is possible to generate additional squares from the same number sequence simply by alternating the positions of the follow on numbers. The Coloured squares show the sequence: – 1, 19, 73, 64, 55, 28, 46, 37, 10.
The sequences formed by selecting each alternate number also appear to work whenever I have tried them. E.g. 1, 73, 55, 46, 10, 19, 64, 28, 37. There would thus appear to be six in each family for one sequence and since the selection of alternating numbers appears to work for the basic sequence also, then this makes 36 in each family! I have so far culled 15 sequences from the net; these are appended at the end.
In line with the other squares the patterns are as shown below:-
A most perfect square is defined as a pan diagonal square where any group of ‘n’ symmetrically placed numbers (n=side of square) also sum to the constant. In a four by four and five by five it is a ‘domino’ pattern. The seven by seven is illustrated on page 7. The nine by nine is a nice solid block of threes. Other patterns are a bit complicated! Some of the perfect nine by nine squares are most perfect, despite reports to the contrary.
POSITIONS FOR SECOND NUMBER: there are six, labelled a,b,c,d,e,f. repeated letters indicate the position just generates an already counted number sequence and not a new square. Follow on, or break point, numbers are shown for an example, they differ for some number sequences!
Since there are six positions to choose from there would appear to be 36 times 6 possible squares, and as shown below as there are six positions for the break numbers this must make 36 times 6 times 6! 1296 squares, with the 15 sequences collected this makes 19440; but since each square contains two sequences this reduces to 9720. I have no idea how working sequences are found, so ideas would be most welcomed.
Positions for the break point numbers: there are six, a,c,d,e,f,g.
A SELECTION OF ‘INTERESTING’ SQUARES.
As indicated above, number squares have been known for thousands of years. In the days when adding up was a bit of a problem for most people, number squares had an aura of mystery. The four by four first illustrated above, is called a Jalna square as it was written up over the gateway into that Indian city (Dana Mackenzie says on a temple in Khajuraho). The first square illustrated below is known as Durer’s square as it appeared in his painting ‘Melancholia’, it has the year of the painting, 1514 in the bottom row. The second square is attributed to Jupiter, in ‘A New View over Atlantis’ by J. Mitchell. The third square is attributed to Mars, in the same book and the fourth to the Sun. Apparently he is just quoting a work by Cornelius Agrippa (1486-1535) as rather more elegantly explained on the Geocities website’s collection of ‘strange magic squares’ (now unfortunately elsewhere!). I thought the sun version was first published by Fermat in 1640, maybe he just knew of Cornelius Agrippa).
The first square below is one of Benjamin Franklin’s. The second is from the Boys Own
Book of Conjuring 1870.
MORE INTERESTING (PERFECT) SQUARES
Examples of nine by nine squares with number sequences after Margossian and Hendricks;
some with extended ‘knight’ move.
Single Knight move, Sequence:- 1,2,3,9,7,8,5,6,4.
Extended Knight move, Margossian sequence:- 1,2,5,6,4,7,8,9,3. and continuations
Extended knight move, sequence:- 1,2,3,9,7,8,5,6,4. Margossian continuations
Pattern and sequence after Hendricks. Sequence:- 1,9,5,6,2,7,8,4,3.
A Margossian square, again very perfect
Another particularly perfect square. Extended knights move, Sequence 1,2,5,6,4,7,8,9,3.
Two squares from the internet after Gaspalou, not fitting the regular pattern as far as I can
discern at present.
Number sequences for nine by nine perfect squares.
Seventeen by seventeen:-
The following symmetries exist:-
A, B, C, D.
E, H, J, M.
F, G, K, L.
N, T.
There are thus only four starts, A, E, F, & N.
Continuations at B, C, D, E, F, G, H, J, K, L, M, N.
Please email squares@taudevin-engineering.co.uk with any comments — good or bad ! —
on this article.
E.M Taudevin.