Category Archives: Math Lesson

Summer Excursion #5 — Magic Squares

If you’ve never seen a magic square, then you’re going to love this excursion! Here’s an example of a magic square with a “magic constant” of 15.

$$
\begin{array}{|r r r|}
\hline
2 & 9 & 4\\
7 & 5 & 3\\
6 & 1 & 8\\
\hline
\end{array}
$$

Notice that all the rows, columns, and main diagonals add to 15 and that all the numbers used are different. In general, those are the only constraints that are needed to define a magic square. Some sources will say that a magic square for a \(3 \times 3\) square can only use the numbers from 1 to 9. But I don’t use this constraint.

Constructing magic squares can be a fun way to sneak in some arithmetic practice and build a little intuition about averages.

Here’s an example. Let’s try to make a magic square from these numbers: \(3,4,5,8,9,10,13,14,15\)

If you fiddle around with this, you may find a magic square that looks like this

$$
\begin{array}{|r r r|}
\hline
4 & 13 & 10 \\
15 & 9 & 3 \\
8 & 5 & 14 \\
\hline
\end{array}
$$

Notice that the rows, columns, and main diagonals all add to 27. If you look a little closer, you’ll notice that this square is very similar to the magic square with a magic constant of 15.

Let’s try another one using only the first 9 odd numbers: \(1,3,5,7,9,11,13,15,17\)

Maybe you came up with a square like this:
$$
\begin{array}{|r r r|}
\hline
3 & 13 & 11\\
17& 9 & 1\\
7&5 &15\\
\hline
\end{array}$$

This one also has a magic constant of 27.

So what’s going on here? Let’s take a look at the sum of all 9 numbers: $$1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 = 81$$ Next, if each row has to add up to the same number, then that number has to be \(\frac{81}{3} = 27\). Or if we wanted to think algebraically about it: \(x + x + x = 81\) where \(x\) is the sum of any row.

Excursion A

So armed with this bit of knowledge, a first question is if I give you nine numbers and tell you that they can construct a magic square, what is the magic constant? Consider these
$$7, 9, 11, 18, 20, 22, 29, 31, 33$$

Excursion B

For the numbers from Excursion A, you should have gotten a total sum of 180 and as such each row must sum to 60 (\(\frac{180}{3}=60\)). Thus, the magic constant is 60. Now the next excursion, how do we go about arranging these numbers so that we can construct a magic square?

There are a bunch of ways, but one hint is to put the average of the three numbers that add to \(60\) in the center. That average is \(20\).

$$\begin{array}{|r r r|}
\hline
a & b & c\\
d & 20 & f\\
g & h & i\\
\hline
\end{array}$$

Now comes a little bit of fiddling with a little knowledge about how averages work, or at the very least, we can discover a few things about averages.

Suppose we let \(b = 29\), then what should \(h\) be? Since the magic constant is \(60\), then \(h = 60 – 20 – 29 = 11\) and our magic square looks like

$$\begin{array}{|r r r|}
\hline
a & 29 & c\\
d & 20 & f\\
g & 11 & i\\
\hline
\end{array}$$

Now, here comes the fun and easy part. Let’s look at the first row. It is essentially \(a + 29 + c = 60\), which means that \(a + c = 31\). Given the remaining numbers, the only way we can sum to \(31\) is with \(9\) and \(22\).

$$\begin{array}{|r r r|}
\hline
9 & 29 & 22 \\
d & 20 & f\\
g & 11 & i\\
\hline
\end{array}$$

The second row requires that \(d + f = 40\) and that can only be done with \(7\) and \(33\). But should \(d = 7\) or should \(d = 33\)? A little bit of reasoning tells us that \(d = 33\) [why?]. This gives
$$\begin{array}{|r r r|}
\hline
9 & 29 & 22 \\
33 & 20 & 7\\
g & 11 & i\\
\hline
\end{array}$$

and which forces \(g = 18\) and \(i = 31\). And we have completed a magic square!

$$\begin{array}{|r r r|}
\hline
9 & 29 & 22 \\
33 & 20 & 7\\
18 & 11 & 31\\
\hline
\end{array}$$

Some of the lessons that students can walk away with are that average value doesn’t have to mean midpoint. Many students believe that the center of a distribution is the average. If we notice in the magic squares, all rows, columns, and main diagonals have an average of 20, but the number 20 isn’t in all rows and columns. However, notice, for example, the center column. The numbers are \(20 + 9\), \(20\), and \(20 – 9\). This makes for a good conversation starter. Similarly notice in the first column, we have \(20 – 11\), \(20 + 13\), and \(20 – 2\) — and it is no coincidence that \(13-11-2 = 0\). This is worth exploring and discussing for all the rows, columns, and main diagonals.

Excursion C

We put together our first magic square:
$$\begin{array}{|r r r|}
\hline
9 & 29 & 22 \\
33 & 20 & 7\\
18 & 11 & 31\\
\hline
\end{array}$$

Are there other ones that can be made? This is a good exercise in understanding / demonstrating some properties about addition and operations on magic squares.

  • What rows can we swap and still have a magic square?
  • What columns can we swap and still have a magic square?

Excursion D

Now it’s time to make a magic square with only one piece of information: the center number

$$\begin{array}{|r r r|}
\hline
a & b & c \\
d& 8 & f\\
g& h & i\\
\hline
\end{array}$$

There are many magic squares that can be made under these constraints:

  • all numbers must be positive
  • all numbers must be unique
  • all rows, columns, and main diagonals must sum to the same number

How many can you find?

Excursion E

Go to a \(4 \times 4\) square. How do things change? What generating strategies can we think of?

From here, there’s a lot more that can be explored. I hope you will! If you have questions, feel free to ask. There’s also a wealth of literature on this that’s a google search away.