Thursday, November 15, 2012

Magic Square


In recreational mathematics, a magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in all rows, all columns, and both diagonals sum to the same constant. A normal magic square contains the integers from 1 to n2. The term "magic square" is also sometimes used to refer to any of various types of word square.
Normal magic squares exist for all orders n ≥ 1 except n = 2, although the case n = 1 is trivial, consisting of a single cell containing the number 1. The smallest nontrivial case, shown below, is of order 3.
The constant sum in every row, column and diagonal is called the magic constant or magic sum, M. The magic constant of a normal magic square depends only on n and has the value
Magicsquareexample.svg
M = \frac{n(n^2+1)}{2}.
For normal magic squares of order n = 3, 4, 5, ..., the magic constants are:
15, 34, 65, 111, 175, 260, ...

For our simplicity we take only 3*3 and 4*4 squares. 

Initially let us consider  3*3

Let us consider 1 for simplicity 
consecutive numbers are 1, 2, 3 ,4, 5, 6, 7, 8, 9
Sum of all the numbers is equal to 45
3*3 matrix so
Divide 45/3= 15
so 15 Magic constant
Arrange 1 to 9 in rows and column not repeating the same numbers


6



7

2

1
5

9

8

3

4
Now, Sum in all the rows column and Diagonal are equal to 15,
Considering this as basic cell we can create any 3*3 matrix in this form for all the integers greater that 15 and divisible by 3,

Ex. for :- For 33,
Divide the subtract the 33 by 15 = 18
Divide the by 3 equals = 6 Add 6 to all the basic cell
arrange in the table following way  from table 1.
Add 6 to all the cell.

6+6



7+6

2+6

1+6

5+6

9+6

8+6

3+6

4+6
 Resulting cell,

12



13

8

7

11

15

14

9

10

this is the magic square starting from 7 to 9 consecutive natural numbers
i.e. 7, 8, 9, 10, 11, 12, 13, 14, 15
sum in all the direction ares 33,

Similarly 4*4 matrix,
Consider 16 numbers and the basic cell arrangement will be.

7

12

1

14

2

13

8

11

16

3

10

5

9

6

15

4

With this basic follow the same procedure as 3*3 matrix and greater than 34.
For all the numbers (N-34) which are divisible by 4.
N>34
For higher level basic cells please go through the following links.
Reference: