TITLE: How to make a matrix a magic square?
QUESTION [5 upvotes]: 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.

REPLY [10 votes]: 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}$$