magic square formula

procyon

Junior Member
Joined
Aug 13, 2011
Messages
53
Hi for the first time everyone, please be gentle ;-)

I'm in no way a beginner to algebra and have loved fiddling with equations for years. I used to mess about with magic squares years ago and just decided to have another dip in. I have become unstuck when I wanted to create equations for a magic square. I intended writing equations that would give correct row, column and diagonal counts regardless of whether it was a magic square or not (i.e. all numbers unique). I started thus:

a
x
b c



where a, b, c and x are given arbitrary numbers and all rows, columns and diagonals will add up to a+x+b

from here, column 1, row 3 becomes (a+x+b)-(c+b) = a-c+x

a
x
a-c+x b c



and column 1, row 1 is (a+x+b) - (c+x) = a+b-c

a+b-c a
x
a-c+x b c



column 3, row 1 can now be (a+x+b) - x - (a-c+x) = a+x+b-x-a+c-x = b+c-x from diagonal
or (a+x+b) - a - (a+b-c) = a+x+b-a-a-b+c = -a+c+x from top row

=> b+c-x = -a+c+x => b-x = x-a

which wasn't a constriction I had imposed (or so I thought).

Am I going letter-blind or what have I missed

Many thanks for all who point an old man in the right direction (hopefully not a home for the mathematically insane)

pro
 
So 2x = a + b ; x = (a + b) / 2

You did innocently impose that restriction, by claiming(!) a+x+b as the common sum.

Why are you complaining anyway? ;)
You can get your x value directly from a and b, plus you know a and b
must be both odd, or both even, due to division by 2.

Anyhow, all that aside, is there a reason why you're not using the fact that the
common sum is 15? Like, x = 15 - a - b ?

Hi Denis,

Thanks for the reply.

You're assuming all magic squares have row etc values of 15. I am attempting to write equations for a general 3x3 magic square, not just the one that uses the integers 1-9.

Anyhow, me thinks sleep (or lack of) was the problem (my post was at 02:54am my time).
It wasn't a restriction I had unknowingly imposed, it is a restriction of a magic square.

I restarted (using the unknown total Magic Number M) like this:


a M-b-c
c
b

which leads to

a M-b-c b+c-a
b-2a+2c cM-b+2a-3c
M+a-b-2cb2c-a

all row, columns and one diagonal add up to M, the other diagonal from top left to bottom right adds up 3c.

Replacing c = M/3 in the above gives

a(2M/3)-bb-a+(M/3)
b-2a+(2M/3)M/32a-b
(M/3)+a-bb(2M/3)-a

which is what I was after. A general solution to any 3x3 magic square.
 
Top