# how to make a matrix a magic square?

Suppose I have a matrix $$\begin{pmatrix} & 3 & 6\\ 5 & & 5\\ 4 & 7 & \end{pmatrix}$$

How can I find the three numbers on the main diagonal such that the sum of the numbers on every row and every column is equal (i.e. it's a magic square). Thank you.

-
There are many "matrix problems". Could you change the title to something more useful, such as "how to make a matrix a magic square" – akkkk Dec 22 '12 at 16:45

## 1 Answer

Let's say we put in the numbers $a$, $b$, and $c$: $$\begin{pmatrix} a & 3 & 6\\ 5 & b & 5\\ 4 & 7 & c \end{pmatrix}$$ The sums of the rows are $a+9$, $b+10$, and $c+11$. The sums of the columns are the same (indeed, if that were not the case, it'd be impossible to make it into a magic square). Thus, we want the numbers $a$, $b$, and $c$ to satisfy $$a+9=b+10=c+11.$$ Such triples of numbers are precisely those of the form $a=x$, $b=x-1$, and $c=x-2$ for some number $x$. But we also want the diagonals to add up to the same value; thus, we want $$a+b+c=4+b+6$$ $$x+(x-1)+(x-2)=4+(x-1)+6$$ $$3x-3=x+9$$ $$x=6$$ Thus, the unique entries we can put in to make the matrix a magic square are $$\begin{pmatrix} \fbox{6} & 3 & 6\\ 5 & \fbox{5} & 5\\ 4 & 7 & \fbox{4} \end{pmatrix}$$

-
He had the diagonals as one of the conditions, so you can see for $x$ and then have to check the last diagonal – Thomas Andrews Dec 22 '12 at 16:52
Well, the question only said "such that the sum of the numbers on every row and every column is equal", but now checking on Wikipedia I see that "magic square" also requires the diagonals to sum to the same value (which I was unaware of). I'll add to my answer. – Zev Chonoles Dec 22 '12 at 16:53
how to find the x? – palatok Dec 22 '12 at 16:55
sorry i forgot to tell about the diagonals. – palatok Dec 22 '12 at 16:56
@palatok: I've updated my answer. – Zev Chonoles Dec 22 '12 at 17:01