Showing posts with label Magic Squares. Show all posts
Showing posts with label Magic Squares. Show all posts

Friday, February 10, 2012

Magic Squares: The Math that Drives Them


   

                   What is the Math behind Magic Squares?   

    A magic square is basically just an arithmetic sequence arranged in a special way.  What do we know about an arithmetic sequence?  An arithmetic sequence is a sequence of numbers each with a common difference. Looking at it a different way, it is a sequence of number by which each number in the sequence is found by adding a specific number to the first number in the sequence. For Example:  The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11....
 is a  sequence  that starts with 1 and each successive number in the  sequence  is found by adding 1 to the previous number in the  sequence .   Now let’s say we want to know the sum of the first 9 digits in this sequence. We could just add them all up one at a time, but that generally takes more time. And with larger sequences it would take a really long time. So we will set up a formula.

Looking at a arithmetic sequence algebraically we need to set up some variables. We will denote the starting value with, a, and the common difference with x and each term is n so algebraically an arithmetic sequence looks like this A, (A + X),( A + 2X), (A +3X), (A +4X),  ….. (A + Nx),
Where (A + nX) is the nth   term in the sequence.  sis the sum of the ne terms
When we wish to know the sum of n terms of the sequence what we are saying algebraically is
sn =           a         +   (a + x)          +...+ (a + 2x) + …+ (a + (n-2) x) + (a + (n-1) x)

And in order to reduce this to a simple formula we can work with we will take the above sequence and reverse it and add it to itself.

     Sn =           a         +   (a + x)          +...+ (a + 2x) + …+ (a + (n-2) x) + (a + (n-1) x)
+   Sn = (a + (n-1) x) + (a + (n-2) x)  +…+ (a + 2x) +… +    (a + x)      +              a

2 Sn =   (2a + (n-1) x) + (2a + (n-1) x) + …+(2a + (n-1) x) +…+(2a + (n-1) x) 

Since we are working with sequences of n terms grouping the last part is as simple as taking
(2a + (n-1) x), and multiplying it by n

2 Sn = n (2a + (n-1) x)

Then when we divide by 2 we have Sn = n (2a + (n-1) x)
                                                                           2
The resulting equation is close to what we will be using for magic squares.
The only difference is that with
Sn = n (2a + (n-1) x) is used with linear sequences that can be graphed out on a
               2
number line.   In order to modify this for working with magic squares we simply square the n Inside the parenthesis ()
  which changes our equation to Sn = n (2a + (n2-1) x)   We do this
                                                                 2                     
 because (n-1) is used to represent last term and in magic squares the number of terms is the dimension squared so the last term would be (n2-1).

Magic squares: basic construction method



       How to construct a 3x3 magic square

         In this section we will be constructing the basic magic square with the dimension 3x3 starting value 1 and common difference 1. If you do not know what a magic square is please refer to the Magic Squares: Introduction section. It is also important to note that this method works with all magic squares that have an odd
dimension. i.e. 5x5 7x7 9x9.......
                                                                                                                       

1. )  First we will begin with an empty 3x3 array.







2.)   Next we place the starting value 1 in the middle of the top row.
                                     


                                                                                                                   







3.) Now we move right one space and up one space, 
but as we can see highlighted in yellow this places the  2
outside the bounds of the 3x3 square.When this happens we 
simply bring  the 2 down to the bottom  square of the column it is positioned over.







4.) In this step we start with the 2 and once again we go right         
 one space and up one space. And once again this leaves us
out side the bounds of the 3x3 square so we place the 3 at the 
beginning of the row it is outside of. 









5.) Here we start with the 3 and once again move right 
one space and up one space, but this time it puts us in an
occupied space. when that happens we simply place the 4        
underneath the 3. 






6.)   In this step we start with the 4 and again move right one
 space and up one space. This space is within the bounds of the 
square and unoccupied so we can simply leave the 5 here.                   








7. ) Here we start with the 5 and go one space right and one
space up and as we can see we can once again simply just                    
place the 6 in this unoccupied space









8.) This time when we move right one space and up one 
space. we are not only outside the bounds of the square 
but we are also on a diagonal In case this happens we                             
place the 7 underneath the 6.












9.) Here we start with the 7 and move right one space
and up one space. Here we are again out side the bounds
of the square  so  we simply take the 8 and place it at the 
beginning of the row it is beside.








10.) now in the final step we only have one space left where we could go ahead and place the 9 there how ever I am still going to illustrate that the pattern still applies when there is only one space.  so we  start with the 8 move right one space and up one space. and again we are out side the bounds of the square, so we will move the 9 to the bottom of the column it is over.










Next in the series we will be looking deeper into the math behind these squares. 

Magic Squares: introduction

       

             What are magic Squares ?

          Magic squares are an arrangement of numbers in a grid of various dimensions to where each row, column, and diagonal will sum up to the same number. The grid they are placed in is generally a N x N array split into N² cells.For example: a 3 x 3 square will have 9 cells meaning there will be 9 numbers in the square.

Here is an example of a 3 x 3 magic square.


     
       Top Row :                4 + 9 + 2 = 15
       Middle Row:             3 + 5 + 7 = 15
       Bottom Row:            8 + 1 + 6 = 15
       Left Column:             4 + 3 + 8 = 15
       Middle Column:        9 + 5 + 1 = 15
       Right column:            2 + 7 + 6 = 15
       First Diagonal            4 + 5 + 6 = 15
       Second Diagonal       2 + 5 + 8 = 15

       Magic squares are an exciting study of number arrangements. Mathematicians have been fascinated by magic squares for centuries.They can be both fun and educational. Magic squares have a deep relation to a branch of mathematics known as combinatorics. However,  most just use them for entertainment.                          

                A birthday trick for magic squares

All Magic squares have a few basic components that you can use to create one. First you need a starting value, that is the lowest number that will be in the square. Second you need to know the common difference between the numbers in the square.  For example in the above square it contains all of the numbers 1, 2, 3 , 4 , 5 , 6, 7 ,8 , 9  each number in the series is obtained by adding 1 to the previous.  so the common difference between terms is 1   The third component of a magic square is the dimension. For Example. The above square has 3 rows and 3 columns so its dimension is 3 x 3. 
     Now for our birthday trick we will restrict the dimension to a 3 x 3. You may also want to keep a copy of the above square so you can see the order you put the numbers into, or you can save it and print it off to use in the trick..
(there is a method for constructing magic squares without using an already created one as a reference but ill include that in my continuation of the series on magic squares)



  1. Now what you will do is ask a person for the month and year they were born, or use your own birthday.You use the last 2 digits of the year they were born for simplicity(or if you are really comfortable with your mental math skills you could use the whole year)  
  2. You take those 2 digits and use it as the starting value  and you use the numerical value for the month as the common difference. 
  3.  And in your head you multiply the month times 4 and add it to the 2 digit year
  4.  you write down the result where they cant see you writing 
  5. then  you then put the piece of paper with the number on it in your pocket 
  6. you then use the year and month of their birth to construct a magic square.
  7. once constructed you show them that every row column and diagonal all have the same sum
  8. next you have them divide that sum by 3 and tell you the answer 
  9. you then pull the piece of paper out of your pocket and "magically" it is the same number
you can omit step 8 if you are comfortable multiplying  the number you wrote down in step 4 by 3 in your head

Ill show an example of this using Benjamin Franklin's birth day 01/17/1706

  1.  01/17/1706
  2.   .starting value =06 common difference=1
  3. 4 x the month 1 + 06 = 4 + 6 = 10   (here i will multiply times 3 so i can omit step 8 since) 10 x 3 = 30
  4. 30 ( not actually writing down  because this is an example)
  5. also skipping this step because its an example

   









 7.    Top Row :                 9 + 14 + 7 = 30

       Middle Row:            8 + 10 + 12 = 30
       Bottom Row:             13 +6 + 11 =30
       Left Column:                9 +8 + 13 =30
       Middle Column:        14 + 10 + 6 =30
       Right column:           7 + 12 + 11 = 30
       First Diagonal           9+ 10 + 11 = 30
       Second Diagonal      7 +10 + 11 = 30

As you can see the magic constant is the same number we got in step 3 

Here is a side by side comparison of the square from the example and the basic square I placed at the top so you can see how you can use the basic square to construct a square for the trick. 

 

The next part in the series will be how to construct a magic square given any starting value,common difference, and dimension without using the basic square as a template. I will be posting this in about 12 hours so be sure to check back with us.