Determine all Functions $f:\mathbb{Z} \to \mathbb{Z}$ such that $f(f(a)-b)+bf(2a)$ is a perfect square for all integers $a$ and $b$.
Problem
Source: 2021 APMO P5
Tags: function, number theory, functional equation, APMO
09.06.2021 09:37
Let $P(a,b): f(f(a)-b)+bf(2a)$ is a perfect square. Lemma: $f(0)=0$, $f(a)$ is a perfect square Let $f(0)=c$ $P(0,f(0)):c^2+c=k^2$ for some $k$ so $(2c+1)^2=(2k)^2+1$. The only time two perfect squares can be consecutive is $0,1$ so $k=0$ and thus $c=0/-1$ If $f(0)=-1$, $P(0,-1-b): f(b)+b+1$ is a perfect square, $P(a,0): f(f(a))$ is a perfect square. Thus, $f(f(a))+f(a)+1$ is a perfect square. If $f(a)$ is $1\pmod{4}$, then $f(f(a))+f(a)+1\equiv 2/3 \pmod{4}$, so it cannot be a perfect square. Thus $f(a)$ is not $1 \pmod{4}$ Now $P(0,0): f(-1)$ is a perfect square hence it is $0\pmod{4}$. But $P(-1,f(-1)): f(-1)f(-2)-1$ is a perfect square but it is $3$ mod 4, contradiction. This proves that $f(0)=0$. Now $P(0,-a): f(a)$ is a perfect square. Case 1: $f$ has a positive zero. Suppose $f(c)=0, c>0$. Then $P(a,f(a)-c): (f(a)-c)f(2a)=0$. Taking $a=c$, since $f(c)-c=-c<0$, $f(2c)=0$. Similarly, $f(4c),f(8c),...$ are all $0$. Now $P(a,f(a)-2^kc): (f(a)-2^kc)f(2a)=0$. Since $f(a)-2^kc$ is negative for large enough $k$, we must have $f(2a)=0$ for all $a$. This gives the solution $f(2x)=0$, $f(2x+1)=g(x)^2$ for any function $g:\mathbb{Z}\rightarrow \mathbb{Z}$. Case 2: $f(a)>0$ for any $a>0$ $P(a,f(a)-2a): (f(a)-2a+1)f(2a)$ is a perfect square. Hence for positive $a$, $f(a)-2a+1$ is a perfect square. Take $k=\frac{p+1}{2}$ where $p$ is prime, since $f(k)$ and $f(k)-p$ are both perfect squares, $f(k)=k^2$. So $f(a)=a^2$ for infinitely many $a$. Also, this means $f(a)\le a^2$ for positive $a$, as bigger than that, the difference of squares would be more than $2a-1$ so $f(a)-2a+1$ won't be a perfect square. Take any $x,y$ such that $f(x)=x^2,f(y)=y^2$ and $x,y$ positive. $P(x,x^2-y): y^2+(x^2-y)f(2x)=y^2-yf(2x)+x^2f(2x)$ is a perfect square. Fix $x$ and increase $y$ towards infinity, we have that $4(y^2-yf(2x)+x^2f(2x))=(2y-f(2x))^2-f(2x)^2+4x^2f(2x)$ which means $f(2x)=4x^2$. Thus, taking any integer $a$, $P(x,x^2-a): f(a)+(x^2-a)(4x^2)$ is a perfect square, so $4x^4-4ax^2+f(a)=(2x^2-a)^2+f(a)-a^2$ is a perfect square. Taking $x$ to infinity, we have $f(a)=a^2$ for all integers $a$, the second solution. 1/3 done during the test, 1/3 done at home, 1/3 my senior told me
09.06.2021 11:15
Say \(f\) is even-vanishing if it sends all evens to zero, and let \(Q\) be the set of all \(q\) such that \(|q|=1\) or \(|q|\) is prime. The answer is \(f(x)\equiv x^2\) or \(f\) is an even-vanishing function that sends odds to perfect squares. All such functions clearly work, so we show they are the only solutions. Let \(P(a,b)\) denote the assertion. From \(P(0,f(0))\), we know \(f(0)+f(0)^2\) is a perfect square. If \(f(0)\ne0\), then we can bound this between \(f(0)^2\) and \((f(0)+1)^2\), so \(f(0)=0\). Applying \(P(0,-x)\), we find that \(f(x)\) is a perfect square for all \(x\). By \(P(x,f(x)-2x)\),we have \(f(2x)(f(x)-2x+1)\) is always a perfect square. In particular, for all \(x\), either \(f(2x)=0\) or \(f(x)-2x+1\) is a square. Call this property \((\star)\). Claim 1: For \(q\in Q\), either \(f(q+1)=0\) or \(f(\frac{q+1}2)=(\frac{q+1}2)^2\). Proof. By taking \(x=\frac{q+1}2\) in \((\star)\), we know that \(f(q+1)=0\) or \(f(\frac{q+1}2)-q\) is a square. In the latter case, take \(f(\frac{q+1}2)=u^2\) and \(f(\frac{q+1}2)-q=v^2\) for \(u,v\ge0\), so \(q=u^2-v^2=(u-v)(u+v)\). It follows that \(u+v=|q|\), and the conclusion readily follows. \(\blacksquare\) Claim 2: If \(n\equiv1\pmod4\), if \(f(n+1)=0\), then \(f\) is even-vanishing. Proof. Take \(P(f(a),f(a)-n-1)\) for arbitrary \(a\). Then \(f(2a)(f(a)-n-1)\) is a square, so either \(f(2a)=0\) or \(f(a)-n-1\) is a square. In the latter case, \(n+1\equiv2\pmod4\) is the difference between two squares, absurd. \(\blacksquare\) Claim 3: If \(f(n)=0\) for any \(n\ne0\), then \(f\) is even-vanishing. Proof. Take \(P(f(a),f(a)-n)\) for arbitrary \(a\). Then \(f(2a)(f(a)-n)\) is a square, so either \(f(2a)=0\) or \(f(a)-n-1\) is a square. Assume for contradiction \(f\) is not even-vanishing, so we may choose a large prime \(q\equiv1\pmod4\) with \(f(q+1)\ne0\) by Claim 2, i.e.\ \(f(\frac{q+1}2)=(\frac{q+1}2)^2\) by Claim 1. Select \(a=\frac{q+1}2\), so \((\frac{q+1}2)^2-n\) is a square. For \(q\gg n\) this is absurd. \(\blacksquare\) Assume \(f\) is not even-vanishing, so the goal is to show \(f(x)\equiv x^2\). Claim 4: \(f(\frac{q+1}2)=(\frac{q+1}2)^2\) for all \(q\in Q\). Proof. From Claim 3 above, we know \(f(n)\ne0\) for \(n\ne0\), and thus the desired result follows from Claim 1. \(\blacksquare\) It is now easy to generalize via induction; first, we verify the following: Claim 5: If \(f(n)=n^2\) then \(f(2n)=4n^2\). Proof. There are infinitely many \(k\) with \(f(k)=k^2\) by Claim 4; for each \(k\), consider \(P(n,f(n)-k)\). Then \(k^2-f(2n)k+n^2f(2n)\) is a perfect square. Since this is a perfect square for infinitely many \(k\), it must itself be a perfect square trinomial in \(k\), so \(f(2n)^2=4n^2f(2n)\), i.e.\ \(f(2n)=4n^2\). \(\blacksquare\) Now we proceed by induction to show \(f(n)=f(-n)=n^2\) for \(n\ge0\); base cases \(n=0,1,2,3\) readily follow from Claim 4. Let \(a=n-1\), and consider \(P(f(a),f(a)-n)\): we know \(f(n)+4a^2(a^2-n)\) is a square. Recall from \((\star)\) that \(f(n)-2n+1\) is a square; hence \(0\le f(n)\le n^2\). Then it is easy to verify that \[\left(2a^2-n-1\right)^2<f(n)+4a^2(a^2-n)\le\left(2a^2-n\right)^2,\]so equality holds on the right and \(f(n)=n^2\). Analogously, \(P(f(a),f(a)+n)\) will show \(f(-n)=n^2\), so the induction is complete.
09.06.2021 12:20
All answers are the benign $f(x) = x^2$ and any $f$ that sends $\text{even}\mapsto 0$ and $\text{odd}\mapsto\text{perfect square}$, all of which clearly works. We divide the proof into multiple claims. Claim: $f(0)=0$ and $f(x)$ is perfect square for any $x$ Proof: Plugging $a=0$ and $b=f(0)$ gives $f(0)^2+f(0)$ is a perfect square, which is enough to force that $f(0)=0,-1$. To rule out $-1$, we plug in $a=0$ to find out that $f(x)+x+1$ is a perfect square. Moreover, plugging in $b=0$ gives $f(f(x))$ is a perfect square. Thus, we have that \begin{align*} f(f(f(2))) + f(f(2)) + 1 &= \text{ perfect square} \\ f(f(2)) + f(2) + 1 &= \text{ perfect square} \\ f(2) + 3 &= \text{ perfect square} \\ \end{align*}Considering the first equation in mod $4$ forces $f(f(f(2))) \equiv f(f(2)) \equiv 0\pmod 4$. The second equation then gives $f(2)\equiv -1,0\pmod 4$, and lastly, the third equation gives the contradiction. Hence, $f(0)=0$. Finally, plugging in $a=0$ gives the second assertion. $\blacksquare$ Now, we give the main step. Claim: Either one of the following assertions must be true. There exists an infinite sequence of positive integers $x_1<x_2<\hdots$ such that $f(2x_1) = f(2x_2) = \hdots = 0$. There exists an infinite sequence of positive integers $x_1<x_2<\hdots$ such that $f(x_i) = x_i^2$ and $f(2x_i)\ne 0$ for all $i$. Proof: The main idea of the proof hinges from the substitution $b=f(a)-2a$. This gives $$f(2a) + (f(a)-2a)f(2a) = f(2a)(f(a)-2a+1) \text{ is a perfect square}.$$Therefore, for each $a$, either $f(2a)=0$ or $f(a)-2a+1$ is a perfect square. Motivated by this, we commit to select $a = \tfrac{p+1}{2}$ for an odd prime $p$. Thus, either $f(p+1)=0$ or $f\left(\tfrac{p+1}{2}\right) = p$ is a perfect square. However, if the latter happens, then both $f\left(\tfrac{p+1}{2}\right)$ and $f\left(\tfrac{p+1}{2}\right)-p$ must be a perfect square, which forces (by difference of squares) $f\left(\tfrac{p+1}{2}\right) = \left(\tfrac{p+1}{2}\right)^2$. In conclusion, for any prime $p$, either $f(p+1)=0$ or $f\left(\tfrac{p+1}{2}\right) = \left(\tfrac{p+1}{2}\right)^2$, which is enough to imply the claim. $\blacksquare$ Of course, we do both cases separately. The following claim finishes the first case. Claim: Suppose the first assertion: there exists an infinite sequence of positive integers $x_1<x_2<\hdots$ such that $f(2x_1) = f(2x_2) = \hdots = 0$. Then, $f(\text{even}) = 0$. Proof: We plug in $b = f(a)-2x_i$ to get that $(f(a)-2x_i)f(2a)$ is a perfect square. However, if $2x_i > f(a)$, then it forces $f(2a)=0$ for sign reason. $\blacksquare$ Now, assume the second case: there exists an infinite sequence of positive integers $x_1<x_2<\hdots$ such that $f(x_i) = x_i^2$ and $f(2x_i)\ne 0$ for all $i$ . We need the following well-known lemma. Lemma: Suppose that $a,b$ are integers such that $a^2\ne 4b$. Then, there are finitely many $x$ such that $x^2+ax+b$ is perfect square. Proof: Just complete the square. I don't bother writing the details. $\blacksquare$ To finish, we prove the following two claims. Claim: For any $i$, $f(2x_i) = 4x_i^2$. Proof: Vary $j$ through all positive integers and plug in $a=x_i$ and $b=x_i^2-x_j$ to obtain that $$f(x_j) + (x_i^2-x_j)f(2x_i) = x_j^2 - x_jf(2x_i) + x_i^2f(2x_i) \text{ is a perfect square},$$so by the lemma, $f(2x_i)^2 = 4x_i^2f(2x_i)\implies f(2x_i) = 4x_i^2$ (reminder: $f(2x_i)\ne 0$). $\blacksquare$ Claim: $f(k)=k^2$ for any $k$ Proof: Vary $i$ through all positive integers and plug in $a = x_i$ and $b = x_i^2-k$ to obtain that $$f(k) + 4x_i^2(x_i^2-k) = (2x_i^2)^2 + (2x_i^2)\cdot 2k + f(k) \text{ is perfect square},$$so by the lemma once again, we get that $(2k)^2 = 4f(k)\implies f(k)=k^2$. $\blacksquare$
09.06.2021 14:45
My solution at the exam : Let $$P(a,b)^2=f(b)+f(a)f(2a)-bf(2a)$$from $P(0,0)^2$ we have $f(0) \in \{0,-1\}$. Assume $f(0)=0$. now if $a>0,f(a)=0$ we have from $P(a,a)^2$ that $-af(2a)$ is a perfect square. Also from $P(0,2a)^2$ we have $f(2a)$ is a perfect square aswell. Hence $f(2a)=0$. now from $P(x,2^n a)^2$ we have $f(x)f(2x)-2^naf(2x)$ is a perfect square. hence $f(2x)=0$ for all integers $x$. now the condition goes : $P(a,b)^2=f(b)$ hence $f(2k+1)=g(k)^2,f(2k)=0$ works for every arbitrary function $g$. Now if $f(a)$ is non zero for positive $a$ we have : $$P(a,2a)^2=f(2a)(1+f(a)-2a)$$$$P(0,2a)^2=f(2a)>0$$hence $T(a)^2=1+f(a)-2a$ also let $f(a)=g(a)^2$ clearly $(g(a)-1)^2 \ge f(a)-2a+1$ hence $a \ge g(a)$. which gives $f(1)=1$. Now from $P(a,1)=1+f(a)f(2a)-f(2a)$ is a perfect square. if $f(2a)=1$ then $f(2a)-4a+1 <-1$ so it is not a perfect square. hence : $$(g(a)g(2a)-1)^2 \ge f(a)f(2a)-f(2a)+1$$hence : $$f(2a) \ge 4f(a)$$which gives clearly : $$f(2^n) \ge 4^n$$but we also had $g(a) \le a$ so $f(2^n)=4^n$. now from $P(2^n,b)^2=f(b)+(2^{2n+1})^2-2b.2^{2n+1}$ so we have : $$P(2^n,b)^2+b^2=f(b)+(2^{2n+1} -b)^2$$so $f(b)-b^2$ is the difference of infinitely many perfect squares hence it is $0$. so $f(x)=x^2$ is also a solution. Now if $f(0)=-1$ we have : $$P(a,0)^2=f(a)f(2a)-1$$hence if $q$ is a positive devisor of $f(a)$ for some $a$, then $q=4k+2$ or $q=4k+1$. Now from $P(0,a)^2=f(b)+b+1$ now $f(4k)+1+4k$ is a perfect square. so $f(4k) \in \{4a,4a-1\}$ which is imposible if $f(4k)>0$ so $f(4k)$ should be negative. Now we prove $f(2a) \le 0$ which is trivial since $f(4a)f(2a)-1$ is perfect square hence non negative. assume $f(2a)=0$ then we have $f(b)$ is a perfect square itself so $f(4k)=0$ hence $f(0)=0$ and it is a contradiction. so $f(2a)<0$ now since $f(2a)f(a)-1$ is a perfect square we get that for all integers $n$ we have $f(n) \le 0$ now we have $f(1)+2$ is a perfect square. So $f(1) \in \{-1,-2\}$ if $f(1)=-2$ we have $-2f(2)-1$ is a perfect square. also $f(2)+3$ is a perfect square aswell. which is impossible . Hence $f(1)=-1$ and it also gives $f(2)=-2$ . now from $P(1,1)^2=-1+4$ is a perfect square which is a contradiction. so in this case we have no solutions.
09.06.2021 14:51
Let $P(x,y)$ be the assertion that $f(f(x)-y)+yf(2x)$ is a perfect square for all $x,y \in \mathbb{Z}$. Then, we proceed with some Claims. Claim 1: $f(0)=0$. Proof: Considering $P(0,f(0))$ we obtain that $f^2(0)+f(0)$ is a perfect square, hence $f(0) \in \{-1,0 \}$. Suppose FTSOC that $f(0)=-1$. Then, $P(0,-x-1)$ implies $f(x)+x+1$ is a perfect square. In addition, by $P(x,f(x)$ we obtain that $f(x)f(2x)-1$ is also a perfect square. Now, take a $x \equiv 0 \pmod 4$. Then, $f(x)+x+1 \equiv f(x)+1 \pmod 4$, therefore $f(x) \equiv 0 \, \, \rm or \, \, 3 \pmod 4$. If $f(x) \equiv 0 \pmod 4$, then $f(x)f(2x)-1 \equiv 3 \pmod 4$, which can never be a perfect square. If $f(x) \equiv 3 \pmod 4$, then if $f(x)f(2x)-1=m^2$, we obtain that $f(x) \mid (m^2+1)$, hence if $p \equiv 3 \pmod 4$ is a prime dividing $f(x)$, we obtain $p \mid (m^2+1)$. By Fermat's Christmas Theorem, this gives $p \mid 1$, a contradiction $\blacksquare$ Claim 2: $f(x)$ is a perfect square for all $x$. Proof: Consider $P(0,-x)$ $\blacksquare$ Now, we may let $f(x)=g^2(x)$, with $g: \mathbb{Z} \rightarrow \mathbb{N}$ i.e., $g$ takes only nonnegative values. $P(x,y)$ rewrites as $g^2(g^2(x)-y)+yg^2(2x)$ is a perfect square. Taking $y \rightarrow g^2(x)-y$ and then swapping $x$ and $y$ we obtain that $g^2(x)+(g^2(y)-x)g^2(2x)$ is a perfect square, for all $x,y \in \mathbb{Z}$. Let this be $Q(x,y)$. We distinguish two cases. Case 1: There exists a $k \neq 0$ such that $g(k)=0$. Then, we make the following Claim: Claim 3: $g(2k)=0$. Proof: Suppose not. Then, $g(2k) \neq 0$. If there exists an $\ell >0$ such that $g(\ell)=0$, then $Q(\ell,k)$ implies $-\ell g^2(2k)$ is a perfect square. Since $g(2k) \neq 0$ and $\ell>0$, this expression is $<0$, a contradiction. Therefore, $g(x) >0$, for all $x>0$. Now, take a $x>0$ and consider $Q(k,x)$. This gives that $(g^2(x)-k)g^2(2x)$ is a perfect square. Since $g(2x)>0$ from the above discussion, we obtain that $g^2(x)-k$ is also a perfect square, which implies that $g(x)$ takes finitely many values for all $x>0$ (specifically, $g(x)$ is of the form $\dfrac{d_i+d_j}{2}$ where $d_i,d_j$ are divisors of $k$ such that $d_id_j=k$). Let the maximum value of $g(x)$ for $x>0$ be $S$. Then, fixing $y$ and taking a pretty large $x$, we obtain that $$g^2(x)+(g^2(y)-x)g^2(2y) \leq S^2+g^2(y)g^2(2y)-xg^2(2y)<0,$$a contradiction. Hence, the Claim is proved $\blacksquare$ To the problem, the Claim implies that $g(k)=0 \Rightarrow g(2k)=0 \Rightarrow g(4k)=0 \Rightarrow \ldots g(2^tk)=0$, for all $t>0$. Hence, $Q(2^tk,x)$ implies that $(g^2(x)-2^tk)g(2x)$ is a perfect square. If, for some $x$, $g(2x) \neq 0$, then $g^2(x)>2^tk$ for all $t$, which is an immediate contradiction. Therefore, $g(2x)=0$ for all $x \in \mathbb{Z}$. It is trivial to verify now that any function of the form $ g(x) = \begin{cases} 0 & \text{if} \,\, x \,\, \text{is even} \\ \text{anything} & \text{if} \,\, x \,\, \text{is odd} \end{cases} $ satisfies. Equivalently, we obtain that $ f(x) = \begin{cases} 0 & \text{if} \,\, x \,\, \text{is even} \\ \text{any perfect square} & \text{if} \,\, x \,\, \text{is odd} \end{cases} $ is a solution to the problem. Case 2: $g(x)=0$ only if $x=0$. Then $g(x) >0$ when $x \neq 0$. Considering $Q(2x,x)$ when $x \neq 0$, we obtain that $(g^2(x)-2x+1)g^2(2x)$ is a perfect square, hence $g^2(x)-2x+1$ is also a perfect square $(*)$. Now, we prove a series of Claims. Claim 4: $g(\dfrac{p+1}{2})=\dfrac{p+1}{2}$ for all odd primes $p$. Proof: Taking $x=\dfrac{p+1}{2}$ in $(*)$ we obtain that $g^2(\dfrac{p+1}{2})-p=a^2$, hence $$(g(\dfrac{p+1}{2})-a)(g(\dfrac{p+1}{2})+a)=p,$$implying that $$g(\dfrac{p+1}{2})-a=1, \,\, g(\dfrac{p+1}{2})+a=p,$$which readily gives the desired $\blacksquare$ Claim 5: $g(2x)$ is even for all $x$. Proof: By $(*)$, $g^2(2x)-4x+1$ is a perfect square. If $g(2x)$ is odd, then $g^2(2x)-4x+1 \equiv 2 \pmod 4$, a contradiction $\blacksquare$ Claim 6: $g(2x)=2g(x)$. Proof: Fix a $x$ and let $g(x)=M$ and $g(2x)=N$. Then, by considering $Q(\dfrac{p+1}{2},x)$, we obtain that $$M^2N^2-\dfrac{p+1}{2}N^2+(\dfrac{p+1}{2})^2$$is a perfect square for all odd primes $p$. The latter rewrites as $$(\dfrac{N^2}{2}-\dfrac{p+1}{2})^2+M^2N^2-\dfrac{N^4}{4},$$where the expressions in the brackets and the one outside of them are integers due to Claim 5. If $M^2N^2-\dfrac{N^4}{4} \neq 0$, then by letting $p \rightarrow +\infty$ we obtain a clear contradiction, since then $\dfrac{N^2}{2}-\dfrac{p+1}{2}$ should attain finitely many values, a contradiction. Therefore, $M^2N^2-\dfrac{N^4}{4}=0$, which easily rearranges to $N=2M$, i.e. $g(2x)=2g(x)$, as desired $\blacksquare$ Claim 7: $g^2(x)=x^2$. Proof: Using Claim 6, $Q(x,y)$ rewrites as $g^2(x)+4(g^2(y)-x)g^2(y)$ being a perfect square. Taking in the latter $y=\dfrac{p+1}{2}$ and fixing $x$ and rearranging, we obtain that $$(\dfrac{p+1}{2}-x)^2+g^2(x)-x^2$$is a perfect square, which when $g^2(x)-x^2 \neq 0$ is a contradiction after taking $p \rightarrow +\infty$ $\blacksquare$ Therefore, we conclude that $g^2(x)=x^2$, i.e. $f(x)=x^2$ which is a solution. To conclude, $f(x)=x^2$ and $ f(x) = \begin{cases} 0 & \text{if} \,\, x \,\, \text{is even} \\ \text{any perfect square} & \text{if} \,\, x \,\, \text{is odd} \end{cases} $ are the only solutions to the problem.
09.06.2021 14:55
The only such functions are $f(x) = x^2$ for all $x$ and $f(x) = \begin{cases} 0 & \text{if } 2 \mid x \\ g(x)^2 & \text{otherwise} \end{cases}$ for all $x$, where $g(x)$ is any function from the integers to itself. Let $P(a, b) = f(f(a) - b) + bf(2a)$. First of all, $P(0, 0) = f(0)(f(0) + 1)$ is a square. If $f(0) \neq 0, -1$, then both $|f(0)|$ and $|f(0) + 1|$ are squares since they are relatively prime, but this is only possible when $f(0) = 0/-1$, contradiction. If $f(0) = -1$, then $P(0, -x - 1) = f(x) + x + 1$ and $P(x, 0) = f(f(x))$ are both squares for all $x$. Recall that $n^2 \equiv 0/1 \pmod{4}$ for all $n$, so since $f(2) + 3$ is a square, then $f(2) \equiv 1/2 \pmod{4}$. Also, since $f(f(f(2))) + f(f(2)) + 1$ is a square and all of the terms are squares, then we must have $f(f(f(2))) \equiv f(f(2)) \equiv 0 \pmod{4}$. But then $f(f(2)) + f(2) + 1 \equiv 2/3 \pmod{4}$ is a square, contradiction. So, $f(0) = 0$. Then, $P(0, -x) = f(x)$ is a square for all $x$. Furthermore, $P(x, f(x) - 2x) = f(2x)(f(x) - 2x + 1)$, so either $f(2x) = 0$ or $f(x) - 2x + 1$ is a square. Case 1. $f(2x) = 0$ for infinitely many positive integers $x$. We claim that $f(2x) = 0$ for all $x$. Assume that there exists $t$ such that $f(2t) \neq 0$. For all $k$ with $f(2k) = 0$, $P(t, f(t) - 2k) = (f(t) - 2k)f(2t)$ is a square. However by taking $k$ sufficiently large the value becomes negative (recall that $f(2t)$ is a square), contradiction. Hence, $f(x) = 0$ for all even $x$, while $f(x)$ is a square for all $x$. This is exactly the second solution. Case 2. There exists $N$ such that $f(x) - 2x + 1$ is a square for all $x \geq N$ Suppose $x \geq N$ and $2x - 1$ is a prime, then let $f(x) = a^2$ and $f(x) - 2x + 1 = b^2$ where $a, b \geq 0$. Then $2x - 1 = (a + b)(a - b)$, which implies $a + b = 2x - 1$ and $a - b = 1$, thus $a = x$ and $f(x) = x^2$. This implies there exists infinitely many $x \geq 0$ such that $f(x) = x^2$. Then, for all $a$ and $x \geq 0$ with $f(x) = x^2$, $P(a, f(a) - x) = x^2 - xf(2a) + f(a)f(2a)$ is a square. If $f(2a) = 2k + 1$ for some $k \in \mathbb{Z}$, then notice that $(x - k - 1)^2 < P(a, f(a) - x) < (x - k)^2$ for all $x$ sufficiently large, contradiction. So, $f(2a) = 2k$ and $(x - k - 1)^2 < P(a, f(a) - x) < (x - k + 1)^2$ for all large $x$, which means $x^2 - xf(2a) + f(a)f(2a) = (x - f(2a)/2)^2$ for all large $x$. Comparing coefficients, we get $f(2a) = 4f(a)$. Now, for all $a$ with $f(a) = a^2$, $P(a, f(a) - x) = f(x) - 4a^2x + 4a^4$ is a square. Then for all $a$ sufficiently large, we have $(2a^2 - x - 1)^2 < P(a, f(a) - x) < (2a^2 - x + 1)^2$, so $P(a, f(a) - x) = (2a^2 - x)^2$ for all large $a$, and thus $f(x) = x^2$ for all $x$. Done.
09.06.2021 16:52
Kinda annoying problem ngl. By substituting $x=f(a)-b$, rewrite the original condition as $$f(x)-xf(2a)+f(a)f(2a) \text{ is a perfect square}$$Let $P(x,a)$ denote the above. Also we will use "PS" for perfect square. Claim 1: $f(0)=0$ Proof: $P(0,0)$ $\implies$ $f(0)(f(0)+1)$ is a PS $\implies$ $f(0) =0$ or $-1$. Assume FTSOC that $f(0)=-1$. Then $P(-4,0)$ $\implies$ $f(-4)-3$ is a PS; in particular, $f(-4)>0$. Taking this modulo $4$, we get $f(-4) \equiv 3 \text{ or } 0 \pmod 4$. Now $P(0,-4)$ gives $f(-4)f(-8) =k^2+1$ for some $k \in \mathbb{Z}$. It is well known that all positive factors of a number of the form $k^2+1$ are congruent to $1$ or $2$ modulo $4$, which contradicts the previous congruence. So $f(0)=0$. $\blacksquare$ Claim 2: $f(x)$ is a PS for all integers $x$. Proof: $P(x,0)$. $\blacksquare$ Let $y=\frac{p+1}{2}$ for any odd prime $p$. Then $P(2y,y)$ gives $f(2y)(f(y)-p)$ is a PS. This means either $f(2y)=0$, or $f(y)-p$ is a PS. But it is easy to see that $p$ can be written in a unique way as a difference of two squares - $\left ( \frac{p+1}{2} \right)^2-\left ( \frac{p-1}{2} \right)^2$, so we must have $$f(y)=\left ( \frac{p+1}{2} \right)^2=y^2$$in this case. Using the deep, highly non-trivial, and recently discovered result known as "the infinitude of primes", we can say that either $f(2y)=0$, or $f(2y) \neq 0$ and $f(y)=y^2$ for infinitely many positive integers $y$. Case I: $f(2y)=0$ for infinitely many $y>0$ Fix any arbitrary integer $a$, and choose a $y>f(a)+200000$ satisfying $f(2y)=0$. Then $P(2y,a)$ gives $f(2a)(f(a)-2y)$ is a PS. Since $f(a)-2y<0$, this can only be true if $f(2a)=0$. Thus $f$ is $0$ on even numbers, and using Claim 2, we get the following solution: $$\boxed{f(x) = \left( \frac{1-(-1)^x}{2} \right ) g(x)^2 \ \ \forall x \in \mathbb{Z} }$$for any arbitrary $g: \mathbb{Z} \rightarrow \mathbb{Z}$. Case II $f(2y) \neq 0$ and $f(y)=y^2$ for infinitely many $y>0$ Call all such $y$ good. Claim 3: $f(2y)=4y^2$ for all good $y$. Proof: Fix any arbitrary good $y$, and let $q(t)$ be the polynomial $t^2-tf(2y)+y^2f(2y)$. There exists a positive integer $M$ satisfying $(t-M)^2<q(t)<(t+M)^2$ for all $t>0$ (for instance, you can take $M=(y^2f(2y))^{1000}+1000+y^{999}+99f(2y)^9$). If $t$ is good, then by $P(t,y)$, $q(t)$ is a PS $\implies$ $q(t)=(t+n)^2$ for some integer $n \in [-M,M]$. But since there are infinitely many good $t$, by another deep result known as "pigeonhole principle", there exists an integer $k \in [-M,M]$ such that $q(t)=(t+k)^2$ for infinitely many good $t$. Since this is a polynomial equation with infinitely many roots, we can compare coefficients to get $f(2y)^2=4y^2f(2y)$ $\implies$ $f(2y)=4y^2$ since $f(2y) \neq 0$. $\blacksquare$ Now, let $x \in \mathbb{Z}$ be arbitrary. Then for any good $y$, $P(x,y)$ gives $$f(x)-4xy^2+4y^4=f(x)-x^2+(2y^2-x)^2 \text{ is a PS}$$Assume $f(x)-x^2 = m \neq 0$ for some $x$. Take a large good $y$, then there must be some PS at a distance of $m$ from $(2y^2-x)^2$. Since the nearest perfect square to $(2y^2-x)^2$ is $2(2y^2-x)-1$ away, we must have $m \geq 2(2y^2-x)-1$, which clearly cannot hold for sufficiently large $y$, contradiction! Therefore we get the solution $$\boxed{f(x)=x^2 \ \ \forall x \in \mathbb{Z}}$$$\blacksquare$
09.06.2021 17:08
dame dame
15.06.2021 04:39
Let $\mathbb S=\{x^2\mid x\in\mathbb Z\}$, and let $P(a,b)$ be the assertion $f(f(a)-b)+bf(2a)\in\mathbb S$. $P(0,f(0))\Rightarrow f(0)+f(0)^2=k_1^2$ If $f(0)\ge1$ then $f(0)^2<k_1^2<(f(0)+1)^2$, contradiction. Similarly, if $f(0)\le-2$ then $(f(0)+1)^2<k_1^2<f(0)^2$, another contradiction, so this leaves $f(0)\in\{-1,0\}$. $\textbf{Case 1: }f(0)=-1$ $P(0,-1-f(x))\Rightarrow f(f(x))+f(x)+1\in\mathbb S$, so $f(x)+1$ is a difference of squares since $P(x,0)\Rightarrow f(f(x))\in\mathbb S$. Since squares are always either $0$ or $1\pmod4$, we have that $f(x)+1\not\equiv2\pmod4$, so $f(x)\not\equiv1\pmod4$. Note that if $f(x)\in\mathbb S$ now, we must have $f(x)\equiv0\pmod4$. An example is $P(0,0)\Rightarrow f(-1)\equiv0\pmod4$. However, then we have $P(-1,f(-1))\Rightarrow f(-1)f(-2)-1=k_2^2$, so taking this equation$\pmod4$ gives us $k_2^2\equiv3$, absurd. $\textbf{Case 2: }f(0)=0$ $P(0,-x)\Rightarrow f(x)\in\mathbb S\Rightarrow f(x)\ge0$ $\textbf{Case 2.1: }\exists k>0:f(k)=0$ $P(k,-2k)\Rightarrow(1-2k)f(2k)\ge0$, so $f(2k)\le0$, hence $f(2k)=0$ with $2k>0$. Simple induction gives $f(2^nk)=0$ for all $n\in\mathbb N$. $P(x,f(x)-2^nk)\Rightarrow f(2x)(f(x)-2^nk)\ge0$, but since $f(2x)\ge0$ and $f(x)-2^nk$ is negative for sufficiently large $n$, we must have $f(2x)=0$. Combined with the fact that $f$ is always square, we have the solution $\boxed{f(x)=\left(\frac{1-(-1)^x}2\right)h(x)}$, where $h$ is any function from $2\mathbb Z+1\to\mathbb S$, which works since $P(a,b)$ reduces to $f(f(a)-b)\in\mathbb S$, which is true since $f$ is always a square. $\textbf{Case 2.2: }f(x)>0\forall x>0$ $P(x,f(x)-2x)\Rightarrow f(2x)(f(x)-2x+1)\in\mathbb S$ Choose $x=\frac{p+1}2$ for an odd prime $p$, then $f(p+1)(f(x)-p)\in\mathbb S$, and since $f(p+1)$ is square, either $f(p+1)=0$ or $f(x)-p$ is a square. The latter must be true in this case. Since $f(x)$ and $f(x)-p$ are both square, we get $p=m^2-n^2$ for $m,n$ such that $f(x)=m^2$ and $f(x)-p=n^2$. Then, since $p$ is prime, we require $m=n+1$, so $f(x)=n^2+2n+1=n^2+p$, so $p=2n+1=2x-1$, hence $x=n+1=m$. Then $f(x)=m^2=x^2$. To summarize, $\exists g:\mathbb N\to\mathbb N$ strictly increasing such that $f(g(n))=g(n)^2$ for all $n\in\mathbb N$. Now $P(x,f(x)-2x)\Rightarrow f(x)-2x+1\in\mathbb S\Rightarrow f(x)\le x^2$ $P(g(x),g(x)^2-g(y))\Rightarrow g(y)^2-g(y)f(2g(x))+g(x)^2f(2g(x))\in\mathbb S$, setting $y$ such that $g(y)$ is sufficiently large gives that $f(2x)=4x^2$. Then $P(x,y)$ becomes $Q(x,y):f(f(x)-y)+4x^2y$. $Q(x,f(x)-y)\Rightarrow f(y)+4x^2f(x)-4x^2y\in\mathbb S$, setting $x=g(n)$ large enough gives us that $(2g(n)^2-y)^2+f(y)-y^2\in\mathbb S$, so $\boxed{f(x)=x^2}$, which also works since $f(f(a)-b)+bf(2a)=(a^2+b)^2\in\mathbb S$.
03.06.2022 19:19
Let $P(a,b)$ denote the given assertion and let $\mathcal{T}=\{t^2: t\in \mathbb{Z}\},$ i.e \ the set of squares. $P(0,f(0))$ gives $f(0)+f(0)^2\in \mathcal{T}.$ So $f(0)=0$ or $f(0)=-1.$ Assume the latter, $P(0,a)$ gives $f(a)+a+1 \in \mathcal{T}.$ And $P(a,0)$ gives $f(f(x))\in \mathcal{T}.$ But comparing $P(0,2)$ then $P(0,f(f(2)))$ then $P(0,f(2))$ gives $f(2)\equiv 1\pmod{4}$ and $f(2)\equiv -1$ or $0 \pmod{4},$ absurd. So $f(0)=0.$ And $P(0,-a)$ gives $f(a)\in \mathcal{T}.$ Incomplete...
04.06.2022 14:01
Completing... A. $f(x)=0$ for some $x>0:$ Fix some arbitrary $u$ and let $f(v)=0.$ $P(u,f(u)-v)$ gives $f(2u)(f(u)-v)\in \mathcal{T}.$ Taking large $v$ forces $f(2u)=0.$ So $f(x_{2\mid x})=0$ and $f(x_{2\nmid x})\in \mathcal{T}$ which works. B. $f(x)> 0~~\forall x>0:$ Then let $p$ be a prime. $P(\frac{p+1}{2}, f(\frac{p+1}{2})-p+1)$ yields $(f(\frac{p+1}{2})-p)(f(p+1))\in \mathcal{T}.$ Taking $p\to \infty$ gives $f(p+1)\in \mathcal{T}.$ It follows that $f(\frac{p+1}{2})-p \in \mathcal{T}$ and $f(\frac{p+1}{2})\in \mathcal{T}.$ Let $f(\frac{p+1}{2})=a^2$ and $f(\frac{p+1}{2})-p=b^2.$ Then solving for $p$ gives $a=\frac{p+1}{2}.$ So $f(\frac{p+1}{2})=(\frac{p+1}{2})^2.$ Take fixed $x$ and an arbitrary $y$ such that $f(x)=x^2$ and $f(y)=y^2.$ $P(x,f(x)-y)$ gives $y^2+x^2f(2x)-yf(2x).$ Note that taking $y\to \infty$ (it is not hard) forces $f(2x)=4x^2.$ Now $P(y,f(y)-x)$ gives $f(x)-x^2+(2y^2-x)^2\in \mathcal{T}.$ Again $y\to \infty$ gives $f(x)=x^2,$ which works.
05.03.2023 21:38
Solution is $f(x) = 0$ for all even $x$ and equals any perfect square for all odd $x$. First, notice $f(0)^2 + f(0)$ is a perfect square. So if $x = f(0), y^2 = f(0)^2+f(0)$, then $(2x+1)^2-(2y)^2 = 1$ so $y = 0$ so $x = 0, -1$. If $x = -1$, then plugging $b = f(a)$ gives $f(a)f(2a)-1$ is a perfect square. Plugging $a = 0$ gives $f(x)+x+1$ is a perfect square. Thus $f(4k) \equiv 0, 3 \pmod 4$, but if $4 \mid f(4k)$ then $f(4k)f(8k) - 1 \equiv 3 \pmod 4$ contradiction, so $f(4k) \equiv 3 \pmod 4$ for all $k$. However, $f(4k+2) \equiv 1, 2 \pmod 4$ for all $k$ but if $f(4k + 2) \equiv 1 \pmod 4$ then $f(4k+2)f(8k+4) - 1 \equiv 2 \pmod 4$ contradiction so $f(4k+2) \equiv 2 \pmod 4$ for all $k$. However since with $b = 0$ we have $f(f(a))$ is a perfect square for all $a$, it follows that $f(f(4k+2))$ is a perfect square but is $2 \pmod 4$, which is a contradiction. Thus $x = 0$. Assume there exists $c \neq 0$ such that $f(c) = 0$. With $a = 0$ we get $f(x)$ is a perfect square for all $x$. Now notice plugging $b = f(a) - 2a$ gives $f(2a)(f(a)-2a+1)$ is a perfect square for all $a$. So either $f(2a) = 0$ or $f(a) \geq 2a - 1$. Consider the set $S$ of $a$ such that $f(2a) \neq 0$. If $S$ is infinite then it is unbounded. However plugging in, for $c \neq 0$ such that $f(c) = 0$, $a = f(a) - c$ gives $(f(a)-x)f(2a)$ is a perfect square, so $f(a) - x$ is a perfect square for all $a$ in $S$. However since $f(a)$ and $f(a) - x$ are both perfect squares for fixed $x$, $f(a)$ is bounded. However since $f(a) \geq 2a - 1$ for all $a \in S$, it follows that $S$ is bounded, contradiction. Thus $S$ is finite, so for all $a > N$ for some fixed $N$, we have $f(2a) = 0$. Now suppose $f(2a) \neq 0$ for some $a$. Then plugging in $c = -b$ gives $f(f(a)+c) - cf(2a) \geq 0$. However for large positive $c$ of certain parity, $f(f(a)+c) = 0$, so it follows that $f(2a) = 0$. Contradiction. Thus $f(2a)$ is $0$ for all $a$, giving the desired solution. Finally consider the case where $f(x) \neq 0$ for all $x \neq 0$. Then as before, it follows that $f(a)-2a+1$ is a perfect square for all $a$. So $f(1) = 1, f(2) = 4$ and $f(a) \leq a^2$. Thus $f(x) - 4x+4$ is a perfect square with $a = 1$. It follows for $n = 3$ that $f(3) = 9$, $f(4) = 16$ by size. Thus again we have $f(x) - 16x + 64$ is a perfect square for all $x$. Again by size and $f(a) - 2a + 1$, $f(x) = x^2$ for all $x \leq 8$. It is easy to verify from small cases that $f(9) = 81$ and $f(10) = 100$. Now we strong induct: supposing it is true up to $2a$, we have $f(c) - 4a^2c+4a^4$ is a perfect square, but LHS differs at most $c^2$ from $(2a^2 - c)^2$. Thus for $c = 2a+1$, we have that $f(c) = c^2$, $4a^2+4a+1 \geq 2(2a^2 - 2a - 1) - 1$ (possibly true), or $4a^2+4a+1 \geq 4(2a^2-2a-1)-4 = 8a^2 - 8a-8 \Longleftrightarrow 4a^2-12a-9 \leq 0$ which fails for $a \geq 5$. But in the middle case, it follows that $f(2a+1)^2 = 8a+4$, but then $f(2a+1)-16(2a+1)+64 < 0$ contradiction. Thus $f(2a+1) = (2a+1)^2$. Now for $c = 2a+2$, we have that $f(c) = c^2$, $4a^2+8a+4 \geq 2(2a^2-2a-1)-1$ (possibly true), or $4a^2+8a+4 \geq 4(2a^2-2a-1)-4 = 8a^2-8a-8 \Longleftrightarrow 4a^2-16a-12 \leq 0$ which fails for $a \geq 5$. But in the middle case, it follows that $f(2a+2)^2 = 12a + 7$. This is impossible mod $4$, so it must be that $f(2a+2) = (2a+2)^2$. Now the inductive step is complete, so $f(x) = x^2$ for all positive $x$. Plugging $b = f(a)+c$ for positive $a$ gives $f(-c) + (f(a)+c)f(2a) = f(-c)+ 4a^2c+4a^2$ is a perfect square, so through the analogous argument as above (same rule used), the same conclusion follows through induction.
05.12.2023 02:42
There are two types of solutions: one is $f(x)=x^2$ and the other is $f(x)=0$ for all even $x$ and for all odd $x$ we choose $f(x)$ to be any perfect square (choice may be dependent on $x$). Clearly both types of solutions work. It remains to prove they are the only ones. Plug in $a=0$ and $b=f(0)$. This gives $f(0)+(f(0))^2=f(0)(f(0)+1)$ is a perfect square. Now, observe that the factors are relatively prime; thus either one is $0$ or both are positive perfect squares, but no two positive perfect squares differ by exactly $1$, so either $f(0)=0$ or $f(0)=-1$. Let's deal with $f(0)=-1$: plugging in $b=f(a)$, we get $f(a)f(2a)-1$ is always a perfect square, say $f(a)f(2a)=k^2+1$. Then $f(a)$ must be either $1$ or $2$ mod $4$ for all $a$, but now if we plug in $a=0$ and $b=3$, we get $f(-4)-3$ is a perfect square, so it is $0$ or $1$ mod $4$, but this gives that $f(-4)$ is $0$ or $3$ mod $4$, contradiction. Hence $f(0)=0$. Plugging in $a=0$ we get that the range of $f$ is a subset of the set of perfect squares. Assume that there exists $2c$ such that $f(2c)\ne 0$ (otherwise we are in a solution set we have already identified). Then as $f(c)$ is a perfect square, $f(c)>0$. Plugging in $a=c$, we get $f(f(c)-b)+bf(2c)$ is always a perfect square, and thus $f(f(c)-b)+bf(2c)\ge 0$. Then $f(f(c)-b)\ge -bf(2c)$. Hence, if we send $b$ to $-\infty$, this shows that as $x\to\infty$ we have $f(x)\to\infty$. Suppose for the sake of contradiction that $k\ne 0$ and $f(k)=0$. Then then, letting $b=f(a)-k$ we get that for every $a$ we have $(f(a)-k)f(2a)$ is a perfect square. For sufficiently large (positive) $a$, we have $f(2a)>0$, and of course $f(2a)$ is a perfect square, so this implies that $f(a)-k$ is a perfect square. However, as $a\to\infty$, $f(a)\to\infty$, and $f(a)$ is also a perfect square, so this would imply arbitrarily large perfect squares that are a constant $k$ apart, which is absurd, hence we get our contradiction, and conclude that $f$ is positive besides at $0$. Now, letting $b=f(a)-2a$, we get that $f(2a)(1+f(a)-2a)$ is a perfect square. This means that for $a\ne 0$, $1+f(a)-2a$ is a perfect square (and actually $a=0$ can be checked seperately so this statement just holds for all $a$). Now, suppose $2a-1$. Then let $1+f(a)-2a=A^2$ and $f(a)=B^2$ where $A,B\ge 0$. We then have $2a-1=B^2-A^2=(B-A)(B+A)$, so $B-A=1$ and $B+A=2a-1$, hence $B=a$ so $f(a)=a^2$. Hence, for infinitely many positive $a$, we have $f(a)=a^2$. Now, changing $b$ to $f(a)-b$ in the original equation gives $f(b)-bf(2a)+f(a)f(2a)$ is always a perfect square. Now, letting $a$ range over the infinitely many positive integers for which we have shown $f(a)=a^2$, this becomes $f(b)-4a^2b+4a^4$ is always a perfect square. Now, let $r=f(b)-b^2$, and observe that $b^2-4a^2b+4a^4=(b-2a^2)$ is always a perfect square, and is always $r$ away from $f(b)-4a^2b+4a^4$. As $f(b)-4a^2b+4a^4$ can get arbitrarily large (positive), the only square within $r$ away will be $f(b)-4a^2b+4a^4$ itself, so in fact $r=0$ and hence $f(b)=b^2$ for all $b$. This concludes the proof.
02.03.2024 21:13
The only solutions are $\boxed{f(x) = x^2}$ and $\boxed{ \begin{cases} f(x) = 0 & \text{ if } x \text{ is even } \\ f(x) \text{ is a perfect square } & \text{ if } x \text{ is odd} \\ \end{cases}}$, where the perfect squares can be arbitrarily chosen. It's easy to check that these work. Now we prove they are the only solutions. Let $P(a,b)$ denote the given assertion. $P(a,0): f(f(a))$ is a perfect square. Claim: $f(0) = 0$. Proof: Suppose otherwise. $P(0,f(0)): f(0) + f(0)^2$ is a perfect square. If $f(0)^2 + f(0) = m^2$, then $(2f(0) + 1)^2 = (2m)^2 + 1$, meaning that $(2f(0) + 1 - 2m)(2f(0) + 1 + 2m) = 1$. Since any two integers multiplying to one are equal we have that $2f(0) + 1 - 2m = 2f(0) + 1 + 2m$, so $m = 0$. Since $f(0) \ne 0$, $f(0) = -1$ must hold. $P(0,a): f(-a - 1) - a$ is a perfect square, or in other words $f(a) + a + 1$ is a perfect square. Then $f(f(a)) + f(a) + 1$ and $f(f(a))$ are perfect squares. Since the difference between two squares cannot be $2\pmod 4$, $f(a)$ cannot be $1\pmod 4$ for any $a$. $P(a, f(a)): f(a) f(2a) - 1$ is a perfect square. This implies that if $f(a) \equiv 0\pmod 4$, then there is a perfect square that is $3\pmod 4$, absurd. Hence for each $a$, $f(a) \equiv \{2,3 \}\pmod 4$. Consider $f(3)$. Since $f(3) + 3 + 1$ is a perfect square, $f(3)$ is a quadratic residue mod $4$, so it must be $0$ or $1$ modulo $4$, contradiction. Hence $f(0) = -1$ is impossible, so $f(0) = 0$ must hold. $\square$ $P(0,-a)$ implies that $f(a)$ is a perfect square for each $a$, so also $f(a) \ge 0$ for each $a$. $P(a, f(a) - 2a): f(2a)(f(a) - 2a + 1)$ is a perfect square, so either $f(2a) = 0$ or $f(a) - 2a + 1$ is a perfect square. Case 1: There exists a positive root of $f$. Claim: For any positive integer $k$ with $f(k) = 0$, $f(2k) = 0$ must hold. Proof: We have $f(2k)(f(k) - 2k + 1)$ is a perfect square, meaning that $f(2k)(1 - 2k)$ is a perfect square. If $f(2k) \ne 0$, then $f(2k)(1 - 2k) < 0$ (because $f(2k) \ge 0$), contradiction. $\square$ $P(a, f(a) - k): (f(a) - k) f(2a)$ is a perfect square for any integer $a$. If some integer $a$ satisfied $f(2a) \ne 0$, then $f(a) - k > 0$ must hold. However, by our previous claim, we can replace $k$ with $k \cdot 2^n$ for any positive integer $n$. Choosing $n$ such that $k \cdot 2^n > f(a)$ gives a contradiction. Thus, $f(2a) = 0$ for all integers $a$, so $f(x) = 0$ for all even $x$. Since we had already proven $f(a)$ is a perfect square, this case implies the second solution described in the beginning. Case 2: There does not exist a positive root of $f$. Then for any positive integer $a$, $f(a) - 2a + 1$ is a perfect square. Call positive integers $x$ with $f(x) = x^2$ special. Claim: There are infinitely many special positive integers $x$. Proof: Consider any positive integer $x$ where $2x - 1 = p$ is a prime (clearly infinitely many $x$ exist). Then $f(x) - 2x + 1$ and $f(x)$ are perfect squares with a difference of $2x - 1$. Notice if $m^2 - n^2 = p$ for some prime $p$, then $(m-n)(m+n) = p$ hence $(m-n) + (m+n) = (-1) + (-p)$ or $(m-n) + (m+n) = (1 + p)$, meaning that $m =\pm \frac{p+1}{2}$. Since $f(x) - (f(x) - 2x + 1) = 2x -1$ is a prime, we have $f(x) = \left( \frac{2x - 1 + 1}{2} \right) = x^2$. $\square$ Claim: If $x$ is special, then $2x$ is special. Proof: If $x$ is special, then $f(x^2 - a) + af(2x)$ is always a perfect square and $x^2 + (f(a) - x) f(2a)$ is also a perfect square. If $x^2 -a $ is special then $(x^2 - a) ^2 + a f(2x)$ is a square. Let $f(2x) = 4x^2 + c$. $(2x-1)^2 + c$ is a square We have $x^4 - 2ax^2 + a^2 + 4x^2 a + a\cdot c$ is a square. $x^4 + 2ax^2 + a^2 + a\cdot c = (x^2 + a)^2 + a\cdot c$ is a square for infinitely many (negative) $a$. Hence $P(a) = (a-x^2)^2 - a\cdot c$ is a perfect square for infinitely many positive integers $a> x^2$. We have $P(a) = a^2 - (2x^2 + c) a + x^4$ is a perfect square. If $f(2x)$ was odd, then $f(2x) - 4x + 1\equiv 2\pmod 4$, so it isn't a perfect square, absurd. Hence $f(2x)$ is even, implying that $c$ is also even. Let $c = 2m$. Hence we have $P(a) = a^2 - 2(x^2 + m) a + x^4 = (a - (x^2 + m))^2 - ((x^2 + m)^2 - x^4))$. Therefore, $(a - (x^2 + m))^2 - P(a) = (x^2 + m)^2 - x^4$, so infinitely many distinct squares have a difference of $(x^2 + m)^2 - x^4$, meaning that $(x^2 + m)^2 = x^4$, so $m \in \{-2x^2, 0\}$. If $m = -2x^2$, then $f(2x) = 4x^2 - 2m = 0$, so contradiction since $x$ is a positive integer. Thus, $m = 0$ and $2x$ is also special. $\square$ Now we prove that $f(x) = x^2$ for all integers $x$. Suppose otherwise. Let $k$ be any integer with $f(k) \ne k^2$ and let $f(k) = k^2 + c$. For any special $x$, $P(x, x^2 - k): k^2 + c + 4x^2 (x^2 - k) = (2x^2 - k)^2 + c$ is a perfect square. This implies that infinitely many pairs of two squares have a difference of $c$, so $c=0$, absurd since $f(k) \ne k^2 $. Therefore, all integers $x$ satisfy $f(x) = x^2$ and we are done.