Find all functions $f$ such that if $a+b$ is a square, then $f(a)+f(b)$ is a square

Question:

For any $a,b\in \mathbb{N}^{+}$, if $a+b$ is a square number, then $f(a)+f(b)$ is also a square number. Find all such functions.

My try: It is clear that the function $$f(x)=x$$ satisfies the given conditions, since: $$f(a)+f(b)=a+b.$$

But is it the only function that fits our needs?

It's one of my friends that gave me this problem, maybe this is a Mathematical olympiad problem. Thank you for you help.

• Well, for each $k \in \mathbb N^+$ there is the function $f(x) = k^2x$. – TonyK Apr 28 '14 at 11:35
• It is proven that if $f$ is polynomial then $f(n)=a^2n$ or $f(n)=a^2/2$ for some constant $a$; see the article :On the sum-pth-power polynomial by Lwins G – Elaqqad Feb 20 '15 at 21:03
• Let $A$ be a subset of $\mathbb{N}^+$ not containing two elements with perfect square sum. For instance, $A$ can be the set of natural numbers of the form $3n+1$. Define $f(n)$ to be $1$ if $n\in A$ and $8$ otherwise. $f$ is a solution. – Mohsen Shahriari Jul 29 '15 at 19:31
• A generalization: Let $A$ be like I said. Define $f(n)$ to be $l^2-2k^2$ if $n\in A$ and $2k^2$ otherwise (where of course $2k^2<l^2$). $f$ is a solution. – Mohsen Shahriari Jul 29 '15 at 19:48
• Perhaps I am being pessimistic, but to me there seem to be far too many solutions, none of which resemble each other in anyway, for this question to be manageable without further restriction - the condition on $f$ as it stands is very weak. To me it feels likely that your friend thought they solved it but missed something, or forgot additional info when they passed on the problem. – Julien Godawatta Dec 26 '15 at 21:44

It's not a complete answer, but as mentioned in comments, this problem probably missed some restrictions, and so have too many solutions. Thus I decided to answer this question for the case that $f$ have constant value in infinite (or finite by little changes) partition of $\mathbb N$.
I expect another answers for remained cases e.g when $f$ is an increasing function (polynomial case mentioned in comments).

Let $A$ is an infinite subset of $\mathbb N$, not containing two numbers with square sum (like https://oeis.org/A203988 except elements of the form $\frac{(2k)^2}{2}$ in this sequence) and $A'=\mathbb N -A$ . Suppose $A_1,A_2,...$ is an infinite non-empty partition of $A$, now $f$ could be defined as below
$$f(n) = \begin{cases} a=\frac{(2k)^2}{2}& \quad \text{if } n \in A' \\a_1^2-a & \quad \text{if } n \in A_1\\a_2^2-a & \quad \text{if } n \in A_2\\.\\.\\. \end{cases}$$ where $k$ and $a_i \in \mathbb N$ .

Now if $x,y \in \mathbb N$ and $x+y$ is a perfect square, then both of $x$ and $y$ should be contained in $A'$, or on of them is in $A'$ and another one is in $A$ (and so contained in one of the $A_i$), in both cases $f(x)+f(y)$ is a perfect square .

protected by Zev ChonolesDec 28 '15 at 7:45

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).