# Tag Info

Before we find a function to minimize, we should first find some equalities that determine whether a grid $(a_{ij})$ is a magic square. First off, a magic square has the restriction that the entries $a_{ij}$ are some permutation of $1$ to $n^2$. Here's a trick to ensure that: We just need to ensure that the polynomial $(X-a_{11}) \cdot (X-a_{12}) \cdots (X-... 0 Suppose there is an$n$X$n$square; so clearly it has$n^2$numbers: from$1$to$n^2$. Also, let$K$be the magic constant. Since this is a magic square, the sum of each row, column and diagonal are equal. For our purpose, let's consider the row-sums only. Since there are$n$rows which contain all the numbers from$1$to$n^2$exactly once, the sum of$...