## Thursday, March 27, 2014

### A Simple Magic Square

Magic squares are tables of numbers where sums of every row, every column and both diagonals produce the same number. No, they were not invented by Ben Franklin, but have been around for thousands of years before. Take a look at this one on Gaudi’s Sagrada FamÃ­lia church in Barcelona:

Now, a little Magic Square puzzle suggested by our reader Lulu:

There is a 3 X 3 table with 9 cells in it and we are required to fill in the table with numbers from 1 to 9. Each number can be used only once. The numbers have to be placed in such a manner that they add up to 15 horizontally, vertically and diagonally. Can you do it?

Your thoughts and suggestions are accepted any time until midnight Eastern Time on Sunday, on our Family Puzzle Marathon

Annie said...

2. 7. 6
9. 5. 1
4. 3. 8

SN said...

Yes we can do it. And the 3x3 table will look like this:
6 7 2
1 5 9
8 3 4
Consider the numbers from 1 to 9 as 'a' to 'i' letters. So the table would be
a b c
d e f
g h i
which means;
a + e + i = 15
b + e + h = 15
c + e + g = 15
d + e + f = 15.
Or, a + i = b + h = c + g = d + f
Looking at the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9; 5 should be in the centre of the table with the other numbers around it arranged in a manner to get 15 vertically and horizontally.
Sorry for the long explanation. I was trying to figure out a way to explain it to my 3rd grader son..

Dennis (of Dennis and Katrina) said...

I can!

I note that the numbers 1-9 add to 45. In a three by three, we'd need three numbers to add to the same number, and since they all add to 45, that would be 45/3, or 15. The magic number for this square is 15. A little work and I get this:

8 1 6
3 5 7
4 9 2

Anonymous said...

8 1 6
3 5 7
4 9 2

From Grace

Anonymous said...

Tracy Z:
When I was in elementary school, a visiting teacher taught me a method for filling out magic squares that always works with odd-size magic squares, no matter what size they are. After learning this "trick", I got so interested in magic squares, I started filling out bigger and bigger ones, and then checking the sums. I think I got up to 21 x 21 before stopping.

A 3x3 magic square can be constructed as follows:
1st row: 8 1 6
2nd row: 3 5 7
3rd row: 4 9 2

It can also be constructed with the 1st and 3rd rows switched, and/or with the 1st and 3rd columns switched.

Here's the method I was taught:
(1) start with a square grid n x n in size, where n is a whole odd number (3 x 3; 5 x 5; 7 x 7)
(2) on each side of this grid, picture another square grid with the same dimensions
(3) start filling out the primary grid from (1) by placing a number 1 in the middle column of the top row.
(4) After this, follow the procedure of moving one cell up and one cell to the right to place each next number.
-- If this moves you off the original grid into an adjacent grid, place the next number in the cell in the original grid which matches the cell in the adjacent grid that you moved to; for example, for with a 3 x 3 grid, the number 2 would be placed in the lower-right cell. Then the number 3 would go into the middle cell of the left column.
--- If, when you try to move from one cell (call it cell A) into the cell up and to the right to place the next number, that cell is already occupied with a number, then place the next number in the cell just below cell A instead.

This method only works for odd-sized magic squares. Maybe there is a similar method for even-sized magic squares. .... actually I just took a look online, and couldn't find any generalized magic square algorithms for even-sized grids, though there are a number of explanations for 4 x 4 magic squares which use the numbers 1-16 and add up to 34. One I like explains how to construct different 4 x 4 magic squares (with larger numbers) in which the rows, columns, and diagonals each add up to a number greater than 34. The link is here: http://www.mrexcel.com/tip069.shtml.

Jerome said...

I like Melancholia by Durer which can be found just by googling it. The magic square (4 by 4) was used to tell the year the wood carving was done, or so the story goes.

The week's square
8 1 6
3 5 7
4 9 2

Appreciate the article referenced for the squares. I'm a true addict.

Anonymous said...

I suppose the trick here is to place 5 at the center and have the horizontally, vertically and diagonally opposite numbers add up to 10.
One way of arranging them is:
| 6 | 1 | 8 |
| 7 | 5 | 3 |
| 2 | 9 | 4 |

Lulu

Maria said...

Great answers. I love how Dennis and SN explained why the magic number is 15: add all the digits we are given 1+2...+8+9=45 This will be a sum of all the numbers in the square. If it is a Magic Square then each row, col and diag sum up to the same number. Sum of 3 rows = sum of all the square numbers. 45 / 3 = 15 Each row, col and diag should sum up to 15. It is the Magic number for this Magic Square.

The trick that Lulu tells is that the median number (center number from 1,2,3,4,5,6,7,8,9 ) should go to the center. In our case it is 5. Then play with the rest of the numbers so that horizontally, vertically and diagonally opposite numbers add up to 10.

And TracyZ provides a complete step-by-step algorithm for filling up any odd-number Magic squares. Wow, very cool. I think my kids could get this. Going to share!

Thank you all and a well-deserved puzzle point for everyone. Lulu - you are getting an additional 3 points for suggesting the puzzle. This was the rule I believe.

Anonymous said...

I know I'm past the deadline for points but I had so much fun with this I wanted to share anyway.

The question reminds me of Kakuro which is a puzzle I have recently started to enjoy. I tackled it using some of the same methodology I use in that game.

First I added up 9! and find that it's 45. Actually I make out the grid every time I play Kakuro; I usually don't get to 9 because there are usually only 7 and 8-digit rows as a maximum, but I am aware of the addition. So then it makes sense that you divide 45 into three rows or columns and get 15.

Ooops! I've just noticed that the diagonals are supposed to sum to 15 also. Well that narrows down the answers quite a bit.

Anyway, what are all the three-digit combinations that can sum up to 15? I made a chart:

951 861 762 654
942 852 753
843

You can analyze the information in the chart this way: For the digit 1 there are only two possible groupings, for the digit 2 there are three, and...1:2, 2:3, 3:2, 4:3, 5:4, 6:2, 7:2, 8:3, and 9:2.
The digit 5 enjoys the greatest possible number of combinations at four. Logically, since several of the digits can participate in only two possible groupings, the solution will be limited by those digits and their groupings. The two groupings would correspond to a row and a column for each digit, so we understand that any solution must use the same set of groupings, and any manipulation of the grid is going to have to preserve those groupings. Actually I didn't see that myself at first, but it becomes apparent (still working without the restriction on the diagonal which is how I started the problem).

Once you starting putting the digits in place it's easy to solve by trial and error:

1 8

9

At this point there with these three digits in place there is only one possible solution:

1 8 6
9 4 2
5 3 7

When you start envisioning more options, say by fixing the one digit in place and rotating the grid around it, you see you can take the mirror image of the grid. You can put the 1 digit in any of the four corners and do the same. You can also swap out any column or any row for another as long as the groupings remain constant. So we get

8 1 6 1 6 8 7 5 3
3 5 7 5 7 3 6 1 8
4 9 2 or 9 2 4 for instance. One can also go in the middle: 2 9 4

For each of the corner spots and middle of outer edge spots, there are two possible answers to my revised puzzle, and eight possible answers if you put the 1 digit in the middle, for a total of 24 answers. The eight configurations for the middle spot derive from rotating the answer to place another digit, say 2, in each of the four corners, and then taking the mirror image of each of those answers.

If we set the middle spot as the digit 5 to answer the original puzzle's demands, we see that there are eight possible answers, visually speaking, although the basic structure of the answer is the same. Voila! Thanks for a great puzzle.

Meg from North Carolina

Anonymous said...

A couple more things I noticed:

One useful tool while solving for a solution initially is to consider which digits cannot share the same row, column or diagonal. Here are all the possible combinations totaling 15 that break the rules:

3 3 9
4 4 7
5 5 5
6 6 3
7 7 1

So we see that 3 cannot be in line with 6 or 9, nor 4 with 7, nor 1 with 7.

Going back to the chart of possible combinations, I used my initial solution to zero in on the six groupings that were used for our rows and columns:

*951 *861 *762 654
*942 852 *753
*843

Apparently these six groupings remain constant. What’s exciting is that the two leftover combinations, 654 and 852, end up being the diagonals. And because 5 is the only digit those two groupings have in common, it MUST be in the middle position. Psyche, I think I just did a proof! Or part of one! LOL

Meg from North Carolina

Anonymous said...

3 4 13
8 8 56
5 3 ?