Pairwise sums are perfect squares .
I thought of this problem as a simplification of the Euler-Brick problem .
$1)$For which $n$ is it possible to find $n$ distinct positive integers $a_1,a_2,\ldots,a_n$ such that all their pairwise sums , namely $a_i+a_j$ for $i \not = j$, are perfect squares .
For example when $n=3$ we can choose : $4$,$21$ and $60$ (with the sums $25$,$64$ and $81$ ) . Another example is $1$ , $24$ and $120$ .
If it's not possible for every $n$ then let $f(n)$ be the largest number of sums which can be perfect squares simultaneously. So $f(3)=3$ .
I can also achieve $f(4) \geq 4$ with $1,3,35,46$ .
My other question is :
$2)$ What bounds can we achieve for $f(n)$ ? (even for particular values is good ) . What I want is a better than 'linear' bound .
The motivation to ask this came from the Euler Brick problem which asks to find three positive integers $x,y,z$ such that $x^2+y^2$ , $y^2+z^2$ , $x^2+z^2$ are all perfect squares .
There are parametric solutions for this problem but for the $4$D brick problem not even a solution is known (see here https://en.wikipedia.org/wiki/Euler_brick)
This hard $4$D version made me ask this simplified version .
I am (almost) sure that I'm not the first considering this problem so there might be known results in the research literature , but I haven't found them yet.
Thanks for everyone who can help me with this problem . I appreciate all your efforts .
EDIT : I added the distinct condition , else the problem is easy . Here are the details :
Choose some $x=2a^2$ and then choose all the numbers to be $x$ . All the sums are now perfect squares so $f(n)=\binom{n}{2}$ for every $n$ .
Solution 1:
My Latest Answer
I have discovered a less trivial approximation for the growth rate of $f(n)$. But first I want to be rigorous about exactly what $f(n)$ is counting. I'm doing this in case I misinterpreted the question. My understanding is that $f(n)$ is the maximum number of distinct pairs $(i, j)$ with $1 \leq i < j \leq n$ such that there exists a set of $n$ positive integers $\{a_1, a_2, \dots, a_n\}$ with $a_i + a_j = s^2$ for some $s$. Clearly, $f(n) \leq {n \choose 2}$, since we can pick at most ${n \choose 2}$ pairs from $n$ objects.
Now, to find a lower bound for $f(n)$, we just need to find a set of pairs and a corresponding set of values, such that all values indexed by the pairs sum to perfect squares. Let's consider the set $\{1, 2, 3, \dots, n\}$ and define $h(n)$ as the number of distinct pairs of elements in this set that add to perfect squares. Clearly $h(n) \leq f(n)$. I will now put forth a very simple proof demonstration that:
$$n^{\frac32} \sim h(n)$$
Consider adding $n+1$ to the set $\{1, 2, 3, \dots, n\}$. We now form all the pairs $(1, n+1), (2, n+1), \dots, (n, n+1)$ whose corresponding sums are $n+2, n+3, \dots, 2n+1$. Now, let $s(a, b)$ denote the number of perfect squares in the interval $[a, b]$. Then we have:
$$h(n+1) = h(n) + s(n+2, 2n+1)$$
Now, how many perfect squares are in the interval $[n+2, 2n+1]$? Well, roughly there are:
$$\sqrt{2n+1} - \sqrt{n + 2} \approx \sqrt{2n} - \sqrt{n} = \sqrt{n}(\sqrt{2} - 1)$$
So, roughly speaking, we have:
$$h(n+1) \approx h(n) + \sqrt{n}(\sqrt{2} - 1)$$
Expanding out the recursion and factoring out the $(\sqrt{2} - 1)$ then we get:
$$h(n) \sim \sqrt{1} + \sqrt{2} + \dots + \sqrt{n} \sim \int_1^n \sqrt{x}\,dx \sim n^{\frac32}$$
My maths here is not up to my usual standard of rigour, but I think it's sound. This would imply that the growth rate of $f(n)$ is somewhere between $n^{\frac32}$ and $n^2$.
Update: We can arrive at a lower bound for $h(n)$ in a different way, avoiding the use of integration. Consider the set $\{1, 2, 3, \dots, n\}$. There are $\lfloor\sqrt{n}\rfloor$ perfect squares in this set. For each perfect square $k^2$, we can form it with $\lfloor\dfrac{k^2 - 1}{2}\rfloor \geq \dfrac{k^2}{2} - 1$ unique pairs:
$$(1, k^2 - 1), (2, k^2 - 2), \dots, (\lfloor\dfrac{k^2 - 1}{2}\rfloor, \lceil\dfrac{k^2 + 1}{2}\rceil)$$
These aren't all the squares that can be formed, but they are all possible, so they are valid for a lower-bound argument. Let $R=\lfloor\sqrt{n}\rfloor$ for ease of notation. A lower bound is then:
$$\sum_{i=1}^{R}\left(\dfrac{i^2}{2} - 1\right) = \frac12\sum_{i=1}^{R}i^2 - R = \dfrac{R(R+1)(2R+1)}{12} - R$$
Clearly this is of the order $n^{\frac32}$.
My Boring Original Answer
I will give a very trivial answer to $(2)$. We have the bound:
$$n - 1 \leq f(n)$$
To see why, choose $a_1 = 1$ and for all $i \neq 1$ choose $a_i = i^2 - 1$. Then we have that for all $i \neq 1$, $a_i + a_1 = i^2$. Since there are $n - 1$ values of $i \neq 1 \leq n$, we obtain the lower bound.
Update: Paying tribute to the commenter Crostul and the OP ComplexPhi, who have done more work than I, we can improve this lower bound to:
$$f(n) \geq f(k) + n - k$$
for any $k \leq n$.
Noting the discovery of the commenter Zander above, we have that $f(4) = 6$, and so we have the following bound:
$$f(n) \geq n + 2 \;\;\; \mathrm{where} \;\;\; (n \geq 4)$$