NPTEL C OURSE ON
M ATHEMATICS IN I NDIA :
F ROM V EDIC PERIOD TO M ODERN TIMES
Lecture 28
Magic Squares - Part 1
K. Ramasubramanian
IIT Bombay, Mumbai
Outline
I
Introduction
Classification of Magic squares
Purpose of studying (as stated by N
ar
ayan.a)
Kacchaput.a of N
ag
arjuna (c.100 BCE)
Sarvatobhadra of Var
ahamihira (550 CE)
The Turagagati method of obtaining magic squares
Possible no. of 4 4 PD squares (with elements 1,2. . . 16)?
Ancient Indian method for odd squares
Kut..taka and magic squares
Properties of 4 4 magic squares
Construction of magic squares using these properties
Introduction
Background and Relevance
I
Today there is a lot of discussion going on all around the world to
see how to make mathematics learning more interesting.
As far as arithmetic is concerned, certainly one way to make it
interesting is to introduce the topic of Magic Squarescalled
Bhadra-gan.ita in Indian Mathematics.
The nomenclature stems from the fact it was considered to fetch
bhadraall round prosperity/well-beingjust like yantras,
wherein we have various letters inscribed.
The earliest extant mathematical text in India that presents some
detailed treatment on the topic of magic squares is
Gan.itas
arakaumud of Thakkura Pher
u (c. 1300 CE).
A more detailed mathematical treatment, by way of exclusively
devoting a chapter (chap. 14, consisting of 75+ verses), is
provided by N
ar
ayan.a in his Gan.itakaumud (c. 1356).
Normal and Pan-diagonal Magic squares
I
Depending on the number of variant ways in which one can get
the desired sum, magic squares have been classified into:
I
I
I
semi-magic (only rows and columns sum up to the no.)
magic, (rows, columns & principal diagonals)
pan-diagonal magic (the above, plus the broken diagonals)
Example of a normal and a pan-diagonal (PD) magic squares:
A normal Magic Square
(Sum = 34)
A Pan-diagonal Magic Square
(Sum = 34)
12
13
10
13
14
11
16
11
16
14
10
15
15
12
PD Sum: 6 + 5 + 7 + 8 6= 34
PD Sum: 13 + 16 + 4 + 1 = 34
Classification of Magic squares
I
Thakkura Pher
u in his Gan.itas
arakaumud classifies n n magic
squares into the following types:
I
I
I
Samagarbha (n doubly-even or of the form 4m)
Vis.amagarbha (n singly-even or of the form 4m + 2)
Vis.ama (n is odd)
Having made this classification, Pher
u presents a few examples
of magic squaresthat are non pan-diagonal.
Moreover, they are normal magic squares of order
n = 3, 4, 5, 6, . . . , whose magic sum are S = 15, 34, 65, 111, . . ..
In these squares, the entries in the n2 cells will be sequence of
natural numbers 1, 2, . . . n2 and the magic sum will be
S=
n(n2 +1)
.
2
However, in the pan-diagonal magic square described by
N
ar
ayan.a the sum S need not be magic sum given above.
Purpose as laid down by Narayan.a
I
The purpose of magic squares has been delineated thus:
x +.ta:yea ya.n:a:a.va:d.Ma :pra.a:ta:yea k
.sa:
u +.ga:Na:k+a:na.a:m,a
;a.Na:ta:.ca:ma:tk
ga:vRa:a.[a:yEa va:[yea ta:tsa.a.=M Ba:d;ga:a.Na:ta.a:K.ya:m,a
ayan
. a observes:
Classifying the magic squares Nar
, Ba:d;m,a
.sa:ma:ga:BRa;a.va:Sa:ma:ga:BeRa ;a.va:Sa:ma.*.a
e : a.ta ;aa:Da.a Ba:vea:d
Defines them as follows:
Ba:d:a:*:
e ta:;
;vea:a .sa:ma:ga:BRa:m,a
e ..ca:tua.=:a:ea ;
a.na.=;g{a:k
ea tua ;a.va:Sa:ma:ga:Ba yea:k+a:g{ea :k
e +.va:lM ;a.va:Sa:ma:m,a
d
;a:g{
When the order of the magic square is divided by 4, if
the remainder r = 0, then it is samagarbha; if r = 2,
then it is vis.amagarbha; and if r = 3 or 1, then it is
vis.ama.
1
Gan.itakaumud 14.2.
Avatarika to Bhadragan.ita by Narayan.a
I One of the notable features of N
ar
ayan.a is that he methodically
introduces all topics that he discusses.
I For instance, in the chapter on Magic squares he sets apart 5 verses
right at the beginning to introduce the topic.
.sa:veRa:Sa.Ma Ba:d:a:Na.Ma (rea:Q:a.=:a:tya.a Ba:vea:d
, ga:a.Na:ta:m,a
yea:Sa.Ma ga:a.Na:ta:ma:Ba.a:M .sa.a:Dya.Ea .tea:Sa.Ma mua:Ka:pra:.ca:ya.Ea
...
ya:d;a. a:va:a.n
/
ta gxa:h.a:a.Na (rea:Q:a:a.va:Sa:yea Ba:vea:d
, ga:.cCH
x +. a.ta:ga:ta:k+ea:e ta:n}.Ua:lM .ja.a:ya:tea . ca.=;NaH
Ba:de k
I+h na.a.=:a:ya:Na:a.va:a.h:ta.a :pa:a=;Ba.a:Sa.a Ba:d;ga:a.Na:tea . ca
I
I
In all magic squares, it is through arithmetic progression . . .
By those desirous . . . the first term and the common
difference have to be determined.
As many as the number of boxes in the square will be equal
to the number of terms (n2 ).
Popularity of Magic squares in India
I The first chapter of Srinivasa Ramanujans Notebooks is on Magic
Squares. It is said to be much earlier than the remainder of the
notebooks.
I T. Vijayaraghavan, in his article on Jaina Magic Squares (1941) notes:
The author of this note learnt by heart at the age of nine the following
pan-diagonal square which was taught to him by an elderly person who
had not been to school at all.
8
11
13
14
12
15
10
16
I This clearly indicates the popularity of Magic Squares in India.
I Indian mathematicians specialized in the construction of a special class
of magic squares called sarvatobhadra.
Kacchaput.a of N
ag
arjuna (c.100 BCE)
I
The elements in the magic square are
given using the Kat.apay
adi system of
specifying numbers by the string arka
indunidh
an
ar . . . .
Half the blocks are filled with zeros.
These blocks can be simply filled with
n x, where x is alternate element
across the diagonal.
Ak
R
I+n,adu;
a.na:Da.ana.a.=:a
.tea:na l+
+;a.a ;a.vana.a.sana:m,a
n3
n6
n3
n5
n7
n4
n6
n4
n8
n1
n7
n1
n2
n9
n2
n8
Pan-diagonal with total 2n
Total 2n + 1
Kacchaput.a of N
ag
arjuna (c.100 BCE)
The following pan-diagonal magic square totaling to 100 has
also been called N
ag
arjunya
30
16
18
36
10
44
22
24
32
14
20
34
28
26
40
Sarvatobhadra of Var
ahamihira (550 CE)
In the Chapter on Gandhayukti of Br.hatsam
a, Var
ahamihira describes the
. hit
Sarvatobhadra perfumes
;a.d
/
d;yaA::Ba.a:gEaH
;aaI+a.n
;a.va:Sa:yaA::pa:[ad:h:na.aH
A:gua. H
:pa.Ma tua.+.SkZEa:le+ya.Ea
;a.pra:ya:
*:u mua:~ta.a.=;sa.aH
:k
e +.ZaH
x +.taO;:k.sa:a:Sa:q,;Ba.a:ga.aH
.~.pxa:*:+atva:k
, ta:ga.=:a:Na.Ma ma.Ma:~ya.a:(
a k
2
5
4
7
3
8
1
6
5
2
7
4
8
3
6
1
.sa:a+tua:vea:d..ca:ndEH ma:l+yana:Ka(ra.a:kk
u +.nd
u .+.k+aH
:Sa.ea:q+Za:k
e
k+..cC+pua:fe ya:Ta.a ta:Ta.a ;a.ma:a.(ra:tea . ca:tua:dR;v.yea
yeaY:.a:d:Za Ba.a:ga.a:~teaY:a.s
/ / / /
ma:n,a ga:nDa.a:d:ya.ea ya.ea:ga.aH
x +.ta.ea:b.d.ea:Da.aH
na:Ka:ta:ga.=;tua.+.Sk+.yua:ta.a .ja.a:ta.a:k+.pRUa.=;mxa:ga:k
gua:q+na:Ka:DUa:pya.a ga:nDa.aH k+.tRa:v.ya.aH
.sa:vRa:ta.ea:Ba:d:aH
In the Kacchaput.a with sixteen cells, [are placed] two parts of agaru, three parts of
patra, five parts of turus.ka and eight parts of saileya in the cells of the first row,....
When these are mixed in whatever way, there will be 18 parts. To such a mixture are
added nakha ..., in equal measures, and in this way the sarvatobhadra are produced.
Sarvatobhadra of Var
ahamihira (550 CE)
As the commentator Bhat..totpala (c.950) explains:
A:a.sma:n,
/////// a :Sa.ea:q+Za:k
e :Sa.ea:q+Za:k+.k+ea:;k
e
k+..cC+pua:fe ya:Ta.a ta:Ta.a yea:na :k
e +.na
:pra:k+a:=e;Na ..ca:tua:dR;v.yea ;a.ma:a.(ra:tea
x +.tea
O;:k
+a:k
..ca:tua:a.BRa:dR;v.yEaH ya:Ta.a:Ba.a:ga:pa:a=;k+.a.pa:tE
//// aH
2
5
4
7
3
8
1
6
5
2
7
4
8
3
6
1
x +.tEa.=:a yeaY:.a:d:Za Ba.a:ga.a Ba:va:a.nta
;a.ma:(ra.a:k
//
.teaY:a.s
///////
ma:n,a k+..cC+pua:fe ga:nDa.a:d:ya +.Dva.Ra:DaHk
+.mea:Na ; a.ta:yRa:gva.a ..ca:tua:SRua k+ea:Nea:Sua va.a
ma:Dya:ma:.ca:tua:Sk+ea:Nea va.a k+ea:Na:k+ea:;.ca:tua::yea va.a :pra.a:#pa:
*:;Ea va.a ma:Dya:ma:k+ea:;d
:yea va.a
a ma:Dya:ma:k+ea:;d
a va.a:d;a:nta:k+e
A:ntya:pa:*:;E
a:;k
e
va.a yea:na
:yea ya.a ;a.d
:ta.a:ya:txa:ta.a:ya:pa:*:;E
:k
e +.na :pra:k+a:=e;Na
. . . ta:sma.a:d;a:ta:~ta:ta.e
..ca:tua:SRua ;a.ma:a.(ra:tea:Sua A:.a:d:Za:Ba.a:ga.a Ba:va:a.nta
//
gxa:h:a:ma.a:Na.a A:.a:d:Za:Ba.a:ga.a Ba:va:a.nta
/ A:taH .sa:vRa:ta.ea:Ba:d;sMa:a.aH
Sarvatobhadra of Var
ahamihira (550 CE)
Translation of the commentary of Bhat.t.otpala
In this kacchaput.a with 16 cells, when four substances are
mixed in whatever way: When the four substances with their
mentioned number of parts are mixed, then the total will be 18
parts; this happens in the above kacchaput.a when the perfumes
are mixed from top to bottom (along the columns) or
horizontally (along the rows), along the four directions, or the
central quandrangle, or the four corner cells, or the middle two
cells of the first row together with those of the last row; the
middle two cells of the second and third row or the first and last
cells of the same, or in any other manner. If the substances in
such four cells are added there will be 18 parts in all. ... Since,
in whatever way they are mixed, they lead to 18 parts, they are
called Sarvatobhadra.
Sarvatobhadra of Var
ahamihira N
ar
ayan.as
This square
Var
ahamihiras
2
It is to be noted that all the three squares
are pan-diagonal.
This belongs to a class of 4 4
pan-diagonal magic squares studied by
N
ar
ayan.a Pan.d.ita in Gan.itakaumud
(c.1356).
Well see later that there are 384 possible
ways of constructing such (4 4) magic
squares.
N
ar
ayan.as
10
13
16
11
14
15
12
Jaina magic square ( inscriptional reference)
12
14
13
11
16
10
15
Pan-diagonal magic square found in the inscriptions at Dudhai
in Jhansi District (c.11th century) and at the Jaina temple in
Khajuraho (c.12th century).
Obtaining 4 4 PD squares: Horse-move method
;va.a:va:*:;E
. ca:tua.=;*:+tu
.Ea d
.Ea (rea:Q:a:sa:mua:;
a
a.=;ga:ga:tya.a d
nya:~ya k
+.ma.ea:tk
+.mea:Na . ca k+ea:E;k+.a O;:k+a:nta:=e;Na . ca 10
.sa:v.ya.a:sa:v.ya:tua.=;*:+ma.
=:a:tya.a k+ea::a:n,a :pra:pUa.=;yea:d:*:
E H
.sa:ma:ga:BeRa :Sa.ea:q+Za:gxa:h:Ba:de :pra.ea:+ea ;a.va: a.Da:(
a.a:ya:m,a 11
; a.ta:yRa:*:+e
a:;ga:ta.a:na.Ma +.DvRa:~Ta.a:na.Ma . ca k+.NRa:ga.a:na.Ma . ca
A:*:;a:na.
Ma .sMa:ya.ea:gaH
:pxa:Ta:
a*+;:ta.
ea .ja.a:ya:tea tua:yaH 12
I+h .sa:ma:ga:Ba.Ra:na.a:ma:pya:nyea:Sa.Ma o+;
;va:(
a:tua:BRa:d:a:t,a
. ca:tua.=;*:+tu
a.=;ga:ga:tya.a
13
12
14
11
16
15
10
d
.Ea d
.Ea
like the movement of horse in chess
choose pairs of numbers [from the sequence]
in two adjacent cells
and at an interval of one cell
by the method of the horse
moving to the left and right
:Sa.ea:q+Za:gxa:h:Ba:de in a magic square with 16 cells
k+ea:E;k+.a
O;:k+a:nta:=e;Na . ca
.sa:v.ya.a:sa:v.ya:tua.=;*:+ma.
=:a:tya.a
.sa:ma:ga:Ba.Ra:na.a:ma:pya:nyea:Sa.Ma
other magic squares of order 4m
Possible no. of 4 4 PD squares (with elements 1,2. . . 16)?
1
13
12
12
13
14
11
15
10
16
16
15
10
14
11
I N
ar
ayan.a now poses the question:
O;:k+a:d;ae:k+ea.a.=;k
e
:Sa.ea:q+Za:gxa:h:k
e Y:a.pa k+. a.ta . ca:tua:BRa:de
Bea:d.a va:d ya:a.d ga:a.Na:tea ga:Na:k+.va.=
A:~tya.a ga:vRa:~tea
I Having displayed 24 pan-diagonal 4 4 magic squares, with the top left
entry being 1, N
ar
ayan.a states:
O;:vMa . ca:tua:BRa:d;~ya . ca:tua:a.BRaH ya:ma:lE H
. ca:tua.=;Za.a:tya: a.Da:k Za:ta.a:ya:Bea:d.a Ba:va:a.n
//
ta
Thus there are 384 possibilities in a magic square . . .
I This has been proved by B. Rosser and R. J. Walker (1938); Much
simpler proof was provided by T. Vijayaraghavan (1941).
Ancient Indian method for odd squares
8
17
24
15
23
14
16
13
20
22
10
12
19
21
11
18
25
I This method of proceeding along
small diagonals (alpa
sruti) is
described as an ancient method
by N
ar
ayan.a Pan.d.ita in
Gan.itakaumud.
I N
ar
ayan.a actually also displays
the eight and only eight
3 3 magic squares that can be
constructed this way.
De La Laubere, French Ambassador in Siam, wrote in 1693 that he learnt this
Indian method from a French doctor M. Vincent who had lived in Surat.
Ancient Indian method for odd squares
Verses presented by N
ar
ayan.a
I+.a:Za.a:pra:Ta:mea k+ea:e (rea:Q.a:*:
M :pra:Ta:mMa nya:sea:t,a
ta:tpra:tya.a:Za.a:pra.a:ntya:k+ea:;sa:ma.a:pa:Ba:va:nea ta:taH 43
A:sma.a:d
, A:pa:(rua: a.ta:gxa:he:Sua A:*:;a:ne
a:k+a:a.d:k+a:n,a ;
a.l+Kea:t,a
k+.NRa:k+ea:e :pua.=H .sa.a:*:
e ta:t~ya.a:t,a :pa.a:d:pra:pUa.=;Na:m,a 44
ta:tpxa:;ga.a:n,a :pua:na:(
+.ma.a:t,a
Ea:vMa :pa.a:d.a:na.Ma :pUa.=;NMa k
A:Ta:va.a O;:vMa Ba:va:ntya:a.s
/ / / /
ma:n,a Bea:d.a Ba:de . ca ;vEa:Sa:mea 45
I+.a:Za.a
desired direction
in the top cell
:pra:Ta:mMa the first no. of the sequence
17
24
15
:pra:Ta:mea k+ea:e
23
14
16
(rea:Q.a:*:
M
13
20
22
nya:sea:t,a
10
12
19
21
11
18
25
may be placed
the opp. direction
A:pa:(rua: a.ta:gxa:he:Sua in the cells along the small diagonals
ta:tpra:tya.a:Za.a
k+.NRa:k+ea:e :pua.=H
with number
.sa.a:*:
e
if the next cell is already filled
Obtaining the magic sum
I Right at the beginning of the chapter, N
ar
ayan.a presents the formula for
finding the magic sum (S).
.sa:pa:dH
:pa:d:va:ga.eRaY:Da .+pa.a:a.d:.ca:yea:na Ba:va: a.ta .sa:*:+
a.l+ta:m,a
ta:t,a :pa:d:mUa:le+na &+tMa :P+lM Ba:vea:a.d::Ba:de ;vEa
I The term padam
. is used to refer to the number of terms. Denoting it by
N, the formula given may be written as:
sankalita
1 2
(N + N)
2
I Now the magic sum is given by
magic sum S =
I Taking N = 16, we will get S = 34.
sankalita
.
N
Kut..taka and magic squares
I Given the magic sum S, and the order of the magic square n, the first
thing to be done to construct the magic square is to obtain the
sred
. hidefined by (a, d).
2
I Having obtained (a, d), the
sred
. h having n elements is constructed
and this will be used to fill in n n square. N
ar
ayan.a makes use of the
following kut..ta
k
ara to obtain (a, d).
1
{a + (a + (n2 1)d)}
(1)
nS = n2
2
n
(n2 1)d
(2)
or
S = na +
2
I It is well known that in a kut..ta
k
ara problem there exists an infinite
number
of integral
solutions for (a, d) if S is divisible by the GCD of
n, n2 (n2 1) . In other words, S should be divisible by n when n is
odd, and by n2 for n even.
I N
ar
ayan.as example: Construct a 4 4 magic square with S = 40. Now
we have the equation 40 = 4a + 30d which is satisfied by the pairs
(a, d) = (5, 2) (10, 0) (25. 2), and so on.
Properties of 4 4 pan-diagonal magic squares
Property 1: Let M be a pan-diagonal 4 4 magic square with entries
1, 2, . . . , 16, which is mapped on to the torus by identifying
opposite edges of the square. Then the entries of any 2x2
sub-square formed by consecutive rows and columns on the
torus add up to 34.
1
12
13
15
10
16
14
11
1 + 12 + 15 + 6 = 1 + 12 + 14 + 7 = 34
Property 2: Let M be a 4 4 pan-diagonal magic square with entries
1, 2, . . . , 16, which is mapped on to the torus. Then, the sum
of an entry on M with another which is two squares away
from it along a diagonal (in the torus) is always 17.
1 + 16 = 6 + 11 = 15 + 2 = 4 + 13 = 14 + 3 = 9 + 8 = 17
Properties of 4 4 pan-diagonal magic squares
1
12
13
15
10
16
14
11
The neighbours of an element of a 4 4
pan-diagonal magic square (which is mapped on to
the torus as before) are the elements which are next
to it along any row or column. For example, 3, 5, 2
and 9 are the neighbours of 16 in the magic square
given in the LHS..
Property 3: Let M be a 4 4 pan-diagonal magic square with entries
1, 2, . . . , 16, which is mapped on to the torus. Then the
neighbours of the entry 16 have to be the entries 2, 3, 5 and 9
in some order.
We can use the above properties, and very easily construct 4 4
pan-diagonal magic squares starting with 1, placed in any desired cell.
Thanks!
T HANK YOU
More of Magic squares in the next lecture!