in Education, Technology / Programming

Magic Squares – What Are They?

Magic Squares have been around for a very long time. Essentially, the idea of a magic square is that every row, column, and diagonal must add up to the same number (known as the “Magic Constant”). Here’s an example of a Magic Square:

8 1 6
3 5 7
4 9 2

In this tiny Magic Square, the Magic Constant is 15. In other words, every row, column, and diagonal adds up to 15. Now, why should you care? Because they’re wicked awesome and have lots of of mathematical, computational, and artistic applications.

Creating Magic Squares

At this point, I’m sure you’re probably dying to humbly raise up the question that if you, too, can be a creator of a Magic Square, or is this form of mathematical beauty only reserved for the elite few? Well, I come as a bearer of glad tidings. You can create a Magic Square too, and use the same technique to make numerous, larger Magic Squares. And it’s not even complicated!

Quick aside: I got into Magic Squares after doing a STEM project in high school where I was supposed to upload a video on YouTube showing how to create a simple 3 x 3 Magic Square. The video got pretty popular and it kind of sparked my interest a few weeks ago to do something further with this topic, but more on that later. Here’s the video – it’s about 2 minutes – on how to create the Magic Square you saw above, and use the same technique to build larger Magic Squares:

Pretty sweet, huh? And you can use the same technique to build any odd number (3 x 3, 5 x 5, 99 x 99) Magic Square, which is kind of what I wanted to do (except not by hand, psh). So, I wrote a small program that would create any number Magic Square and create an informal proof for Magic Square Theory through verification. It’s pretty neat and fun to play with. I’ve uploaded the code to GitHub, which you can check out here. Unfortunately, I didn’t have time to create a user interface so you’ll have to compile the code – Sorry! 🙁 However, I have included a video below that shows the program being executed and the verification process. (Note: The video is best viewed on tablet/computer screen in HD or in landscape orientation on your phone).

Well, I hope you enjoyed reading about Magic Squares and using the Magic Square generator. It really is a fascinating topic and I encourage you to look more into it!

If you have knowledge, let others light their candles in it.” (Margaret Fuller)

Until Next Time,

It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedIn

Write a Comment