# Magic $\mathbb{Z}\times\mathbb{Z}$-square

Is there an injective map $$j:\mathbb{Z}\times \mathbb{Z} \to \mathbb{Z}$$ satisfying: For every $$z\in \mathbb{Z}$$ we have $$\lim_{N\to \infty}\sum_{k=-N}^Nj(k,z) = 0 = \lim_{N\to \infty}\sum_{k=-N}^Nj(z,k)\text{ ?}$$

That is, for every $$z\in \mathbb{Z}$$ there is $$N_0=N_0(z)\in \mathbb{N}$$, such that for every integer $$N\geq N_0$$ we have $$\sum_{k=-N}^Nj(k,z) = 0 = \sum_{k=-N}^Nj(z,k).$$

Weaker variant: For $$A\subseteq \mathbb{N}=\{1,2,\ldots\}$$ we let $$\mu^+(A) = \lim\sup_{n\to\infty}\frac{|A\cap\{1,\ldots,n\}|}{n}.$$ Given an injective map $$j:\mathbb{Z}\times\mathbb{Z} \to \mathbb{Z}$$, and given $$z_0\in\mathbb{Z}$$, we say that $$N\in\mathbb{N}$$ is equitable with respect to $$z_0$$ if $$\sum_{k=-N}^Nj(k,z_0) = 0 = \sum_{k=-N}^Nj(z_0,k).$$ We denote the set of equitable integers with respect to $$z_0$$ by $$\text{Eq}(z_0)$$.

We say that an injective map $$j:\mathbb{Z}\times\mathbb{Z}\to\mathbb{Z}$$ is a weakly magic square if $$\mu^+(\text{Eq}(z))>0$$ for all $$z\in\mathbb{Z}$$.

Is there a weakly magic square?

• I think the answer to your original, stronger question mathoverflow.net/questions/343812/… is yes. – Ben Barber Oct 17 '19 at 10:20
• Thanks Ben - can you post your thoughts as an answer there? I think I follow your line of thought but still have some problems putting it into a proof – Dominic van der Zypen Oct 17 '19 at 14:37
• @BenBarber the previous linked "stronger question" is now pasted (and answered) here. – YCor Oct 18 '19 at 14:54
• (From Tir's comment to the duplicate post): "There is at least one paper in the literature on infinite magic squares (different from this generalization): Antoine Salomon, "Infinite sized magic square" the American Mathematical Monthly (January 2014) (freely available at Hal). There is also a discussion elsewhere on this site about infinite magic squares." – YCor Oct 19 '19 at 9:59

I'll try to show that we can make a square such that all rows and columns give zero sum. (Where "sum" is meant in the sense described in the question.) I.e., this is the answer to the stronger variant.1

The description is a bit informal, but I hope it could be clear how the construction goes.

We will proceed by induction and choose values $$j(k,l)$$ with $$-N\le k,l \le N$$. I.e., after $$N$$ steps the square of the size $$(2N+1)\times(2N+1)$$ will be filled. Moreover, will do it in such fashion that the row sums and column sums of the square are zeroes. (And in such way that no numbers in our table repeat.)

Base step. Let us start by putting $$j(0,0)=0$$.

In the first step of induction we want to add some other numbers into this three by three square $$\begin{array}{|c|c|c|} \hline \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \hphantom{0} & 0 & \hphantom{0} \\\hline \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \end{array}$$

Now we simply choose two distinct positive integers $$a$$, $$b$$ and add also $$-b$$, $$-a$$ in the opposite positions so that we get zeroes in the middle row and the middle column. $$\begin{array}{|c|c|c|} \hline \hphantom{-a} & a & \hphantom{-a} \\\hline b & 0 & -b \\\hline \hphantom{-a} &-a & \hphantom{-a} \\\hline \end{array}$$

We simply choose any integer $$x>\max(a,b)$$. If we then add $$x$$ to the topleft corner, we have only one possibility what to do in the other positions in order to get sum equal to zero

$$\begin{array}{|c|c|c|} \hline x & a & -a-x \\\hline b & \hphantom{a+}0\hphantom{+b} & -b \\\hline -b-x &-a & a+b+x \\\hline \end{array}$$

The condition $$x>\max(a,b)$$ implies that all numbers in this table are distinct.

Inductive step. We assume that we already have a square where row/columnns add up to zero. We want to add two more rows (at the top and at the bottom) and two more columns (left and right).

The construction in the inductive step will be somewhat similar to what we did in the base step.

We already have a "zero square" in the middle. $$\begin{array}{|c|ccc|c|} \hline \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\ \hphantom{0} & \hphantom{0} & 0 & \hphantom{0} & \hphantom{0} \\ \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \end{array}$$

We first add numbers above/below the square and also to the left and to the right. (I.e., only the four corners will be missing.) We will do this in such way that above the square we put some positive integers that neither these numbers, nor their opposites, have been used so far. And below the square we put their opposites. Similarly on the left and right side. After this the row and column sums are zeroes, with the possible exception of the first and last row/column - where we're going to add the missing values. Let us denote the sum of all numbers added "above" as $$A$$ and the sum of all numbers added on the left as $$B$$. We can also require that $$A\ne B$$. (If needed, we simply modify one of the numbers on the left.) $$\begin{array}{|c|ccc|c|} \hline \hphantom{0} & \hphantom{0} & A & \hphantom{0} & \hphantom{0} \\\hline \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\ B & \hphantom{0} & 0 & \hphantom{0} & -B \\ \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline \hphantom{0} & \hphantom{0} & -A & \hphantom{0} & \hphantom{0} \\\hline \end{array}$$ Again we choose some $$x$$ which is larger than the absolute values of the numbers we have used so far. (This will ensure that the numbers in the corners will be distinct from the existing ones.) The we have only one possibility what to add in the remaining positions. $$\begin{array}{|c|ccc|c|} \hline x & \hphantom{0} & A & \hphantom{0} & -x-A \\\hline \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\ B & \hphantom{0} & 0 & \hphantom{0} & -B \\ \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} & \hphantom{0} \\\hline -B-x & \hphantom{0} & -A & \hphantom{0} & x+A+B \\\hline \end{array}$$

Continuing in this way, we fill the whole $$\mathbb Z\times\mathbb Z$$ table in a way which fulfills the requirements stated in the question.

1Ben Barber suggested some approach in the comments to the original question. I do not understand those comments well enough to be able to judge whether the solutions proposed there is similar to this one. However, one of the comments suggests that we are in fact able to get a bijection - which seems more difficult (and more interesting).

• My suggestion was to do one column, then one row, then one column and so on, rather than working out in squares from the centre. At first I thought you might also be able to make your construction bijective, but it's not completely obvious how to pair the numbers you add in the corners, so perhaps I'll sketch my approach in another answer. – Ben Barber Oct 18 '19 at 9:37

With the unusual definition of convergence, and infinite space, there's so much flexibility that it's difficult to go wrong. Here's one way to proceed.

Enumerate the rows and columns arbitrarily and suppose we are currently trying to fill some row or column $$r$$ having previously filled $$n$$ rows and columns such that the desired property holds. Fill additional cells of $$r$$ (with distinct integers that have not been used so far) until

1. The filled in cells of $$r$$ form an interval centred about $$0$$.
2. The sum of the entries of these cells is $$0$$.
3. Every integer from $$-n$$ to $$n$$ appears somewhere in the part of the grid filled so far.

Once this is done (and it remains to check that it can be), fill in the remaining entries of $$r$$ by pairs $$a$$, $$-a$$ where $$a$$ is a power of the $$(n+1)$$st prime $$p_{n+1}$$.

(1) and (3) are easy to ensure. Once they are in place the filled in cells have some sum $$s$$. We seek some $$b$$ such that $$b$$ and $$-(b+s)$$ are both unused; placing them in the cells at either end of the filled in interval brings the sum so far to $$0$$.

To see that there exists such a $$b$$, let $$A$$ be the set of absolute values of integers used so far. $$A$$ contains only finitely many elements that are not powers of the first $$n$$ primes, so $$A$$ has zero density and its complement must contain an interval of length $$|s|+1$$. The endpoints of this interval, with the correct signs added, can be taken as $$b, -(b+s)$$.

Continuing in this way eventually fills the entire grid using every integer exactly once.