Remark. Dear voters, this question is not a duplicate of the following old question. Please refrain from closing it for being a duplicate.

QUESTION: Find all functions $f:\Bbb{N}→\Bbb{N}$ which satisfy $$f(m^2+n^2)=f(m)^2+f(n)^2\,,\forall\space m,n\in\Bbb{N}\,.$$ Here, $\mathbb{N}=\{1,2,3,\ldots\}$.

MY APPROACH: Set $m=n$.. we obtain- $$f(2n^2)=2f(n)^2$$ Studying this equation I found out that $f(x)=\sqrt{\frac{x}2}$ satisfies the condition. But I could not think any further. If my claim is true, how do I prove it? And how do I make sure that there aren't any other functions satisfying the property?

Thank you for your help in advance :)

  • 2
    $\begingroup$ Does your $N$ contains $0$? $\endgroup$ Jul 4, 2020 at 6:54
  • 1
    $\begingroup$ Then why is the second condition even given.Seems weird. $\endgroup$ Jul 4, 2020 at 6:56
  • 1
    $\begingroup$ @Yes it's me yes.. I too didn't get why was the second condition is given.. anyway, do you have any idea how to tackle this? $\endgroup$ Jul 4, 2020 at 6:59
  • 1
    $\begingroup$ Please always state whether $\mathbb{N}=\{1,2,3,\ldots\}$ or $\mathbb{N}=\{0,1,2,3,\ldots\}$. People use different conventions for $\mathbb{N}$. Your clarification of what $\mathbb{N}$ is is necessary. $\endgroup$ Jul 4, 2020 at 7:42
  • 3
    $\begingroup$ I think he means $f:\mathbb N_0\to\mathbb N_0$ as this way, the problem makes more sense. $\endgroup$
    – Anand
    Jul 4, 2020 at 8:17

2 Answers 2


The only such function is $f(n)=n$.

The hard part is to show $f(1)=1$. After that, one just follows the answer to Find all $f$ such that $f\left(m^{2}+n^{2}\right)=f(m)^{2}+f(n)^{2},$ plus some small values of $f(n)=n$ that will be proved below.

Let $f(1)=a$.

The given formula applies directly to any number that is the sum of two squares. Thus \begin{align*} f(2)&=f(1+1)=2a^2\\ f(5)&=f(4+1)=(2a^2)^2+a^2=4a^4+a^2\\ f(8)&=f(4+4)=8a^4\\ f(10)&=f(9+1)=f(3)^2+a^2\\ f(13)&=f(9+4)=f(3)^2+4a^4 \end{align*}

However, some numbers are the sum of two squares in more than one way, and this is the key to the proof.

\begin{align} 7^2+1&=5^2+5^2,&f(7)^2&=2f(5)^2-a^2\\ 2^2+11^2&=5^2+10^2,&f(11)^2&=f(10)^2+f(5)^2-f(2)^2\\ 11^2+7^2&=13^2+1,&f(11)^2&=f(13)^2-f(7)^2+a^2\\ \hline 5^2+14^2&=10^2+11^2,&f(14)^2&=f(10)^2+f(11)^2-f(5)^2\\ 6^2+13^2&=3^2+14^2,&f(6)^2&=f(14)^2+f(3)^2-f(13)^2\\ \end{align}

The first three equations involve the variables $f(3)^2$, $f(7)^2$, $f(11)^2$. Eliminating $f(11)^2$ and $f(7)^2$ gives $$a^2 (4 a^2-1)f(3)^2 = a^2 (2a^2+1)^2(4a^2-1)$$ so $f(3)=2a^2+1$.

We can now use the last two equations to find $f(14)^2$, then $$f(6)^2=2(1+8a^2+17a^4+8a^6-16a^8)$$ This forces $a=1$ since the polynomial takes negative values for $a>1$.

It then follows that $f(n)=n$ for small values of $n$, by substitution, and hence by induction.


Here we shall find all functions $f:\mathbb{Z}_{>0}\to\mathbb{C}$ such that $$f(m^2+n^2)=\big(f(m)\big)^2+\big(f(n)\big)^2$$ for all positive integers $m$ and $n$. Let $S$ denote the subset of $\mathbb{Z}_{>0}$ consisting of every integer that can be written as a sum of two perfect squares of positive integers. We shall prove that all solutions are given by

  • $f(n)=0$ for all $n\in\mathbb{Z}_{> 0}$,
  • $f(n)=\dfrac12\,g(n)$ for all $n\in\mathbb{Z}_{> 0}$ where $g:\mathbb{Z}_{> 0}\to \{-1,+1\}$ is such that $g(s)=1$ for all $s\in S$, and
  • $f(n)=n\,g(n)$ for all $n\in\mathbb{Z}_{> 0}$ where $g:\mathbb{Z}_{> 0}\to \{-1,+1\}$ is such that $g(s)=1$ for all $s\in S$.

As in Chrystomath's answer, if we let $a:=f(1)$, then $$a^2(4a^2-1)\,\big(f(3)\big)^2=a^2(4a^2-1)^2\,(2a^2+1)^2\,.$$ This shows that $a=0$, $a=\pm\dfrac12$, or $f(3)=\pm(2a^2+1)$.

Case I: $a=0$. Then, Chrystomath's answer shows that $f(2)=f(5)=f(7)=f(8)=0$. Let $b:=f(3)$. Then, Chrystomath's answer tells us that $f(10)=b^2$, $f(11)=\pm b^2$, $f(13)=b^2$, $f(14)=\pm\sqrt{2}b^2$, and $f(6)=\pm b\sqrt{b^2+1}$. From $6^2+7^2=85=2^2+9^2$, we see that $$f(9)=\pm\sqrt{\big(f(6)\big)^2+\big(f(7)\big)^2-\big(f(2)\big)^2}=\pm b\sqrt{b^2+1}\,.$$ Now, $4^2+7^2=65=1^2+8^2$ implies that $$f(4)=\pm\sqrt{\big(f(1)\big)^2+\big(f(8)\big)^2-\big(f(7)\big)^2}=0\,.$$ Consequently, $$f(17)=f(4^2+1^2)=\big(f(4)\big)^2+\big(f(1)\big)^2=0\,.$$ Now, $1^2+12^2=145=8^2+9^2$ and $5^2+15^2=250=9^2+13^2$, we conclude as before that $$f(12)=\pm b\sqrt{b^2+1}\text{ and }f(15)=\pm b\sqrt{2b^2+1}\,.$$ Using $1^2+17^2=290=11^2+13^2$, we obtain $$2b^4=\big(f(11)\big)^2+\big(f(13)\big)^2=\big(f(1)\big)^2+\big(f(17)\big)^2=0\,.$$ Therefore, $b=0$. It follows that $f(n)=0$ for $n=1,2,3,\ldots,15$. Following the induction step from this link, we conclude that $f(n)=0$ for every positive integer $n$.

Case II: $a=\pm\dfrac12$. Then, Chrystomath's answer shows that $$f(2)=f(5)=f(8)=\dfrac12\text{ and }f(7)=\pm\dfrac12\,.$$ Let $b:=f(3)$. Then, as in the previous case, $$f(10)=f(13)=b^2+\dfrac14\text{ and }f(11)=\pm\left(b^2+\dfrac14\right)\,.$$ Furthermore, $$f(14)=\pm\sqrt{2b^4+b^2-\frac18}\,.$$ and $$f(6)=\pm\sqrt{b^4+\frac{3}{2}b^2-\frac{3}{16}}\,.$$ Now, $4^2+7^2=65=1^2+8^2$ implies that $$f(4)=\pm\sqrt{\big(f(1)\big)^2+\big(f(8)\big)^2-\big(f(7)\big)^2}=\pm\frac12\,.$$ Consequently, $$f(17)=f(4^2+1^2)=\big(f(4)\big)^2+\big(f(1)\big)^2=\dfrac12.\,.$$ Using $1^2+17^2=290=11^2+13^2$, we obtain $$2\left(b^2+\dfrac14\right)^2=\big(f(11)\big)^2+\big(f(13)\big)^2=\big(f(1)\big)^2+\big(f(17)\big)^2=\dfrac12\,.\,.$$ Therefore, $b=\pm\dfrac12$ or $b=\pm\dfrac{\sqrt{3}\text{i}}{2}$. Using $4^2+17^2=305=7^2+16^2$, we conclude that $f(16)=\pm\dfrac12$. From $6^2+7^2=85=2^2+9^2$, we obtain $$f(9)=\pm\sqrt{b^4+\frac{3}{2}b^2-\frac{3}{16}}\,.$$ Using $1^2+12^2=145=8^2+9^2$, we conclude that $$f(12)=\pm\sqrt{b^4+\frac{3}{2}b^2-\frac{3}{16}}\,.$$ From $5^2+15^2=250=9^2+13^2$, we get $$f(15)=\pm\sqrt{2b^4+2b^2-\dfrac38}\,.$$

  • If $b=\pm\dfrac12$, then we can see that $f(n)=\pm\dfrac12$ for $n=1,2,3,\ldots,17$. By induction, we obtain $f(n)=\pm\dfrac12$ for all $n\in\mathbb{Z}_{>0}$. Furthermore, $f(n)=\dfrac12$ if $n$ can be written as a sum of two perfect squares of positive integers.

  • If $b=\pm\dfrac{\sqrt{3}\text{i}}{2}$, then that $$f(18)=f(3^2+3^2)=\big(f(3)\big)^2+\big(f(3)\big)^2=-\frac{3}{2}\,.$$ Now, $1^2+18^2=325=6^2+17^2$. This gives $$\big(f(1)\big)^2+\big(f(18)\big)^2=\big(f(6)\big)^2+\big(f(17)\big)^2$$ or $$\frac14+\frac{9}{4}=-\frac34+\frac14\,,$$ which is a contradiction. Therefore, this subcase leads to no solutions.

Case III: $a\notin \left\{0,\pm\dfrac12\right\}$. Then, $f(3)=\pm(2a^2+1)$. As in Chrystomath's answer, we can find $$f(2)=2a^2\,,\,\,f(5)=a^2(4a^2+1)\,,\,\,f(8)=8a^4\,,$$ $$f(10)=4a^4+5a^2+1\,,f(13)=8a^4+4a^2+1\,,$$ $$f(7)=\pm a\sqrt{32a^6+16a^4+2a^2-1}\,,$$ $$f(11)=\pm \sqrt{32a^8+48a^6+30a^4+10a^2+1}\,,$$ $$f(14)=\pm\sqrt{2(16a^8+40a^6+31a^4+10a^2+1)}\,,$$ $$f(6)=\pm\sqrt{2(-16a^8+8a^6+17a^4+8a^2+1)}\,.$$ Using $4^2+7^2=65=1^2+8^2$, we see that $$f(4)=\pm a\sqrt{2(16a^6-8a^4-a^2+1)}\,.$$ This gives $$\begin{align}f(17)&=f(1^2+4^2)=\big(f(1)\big)^2+\big(f(4)\big)^2\\&=a^2(32a^6-16a^4-2a^2+3)\,.\end{align}$$ Because $1^2+17^2=290=11^2+13^2$, we obtain $$(a-1)(a+1)(4a^2+1)^2\left(64a^{10}-32a^8+20a^6+16a^4+3a^2+2\right)=0\,.\tag{*}$$ From $6^2+7^2=85=2^2+9^2$, we have $$f(9)=\pm\sqrt{32a^6+32a^4+15a^2+2}\,.$$ Using $1^2+12^2=145=8^2+9^2$, we obtain $$f(12)=\pm\sqrt{64a^8+32a^6+32a^4+14a^2+2}\,.$$ From $5^2+15^2=250=9^2+13^2$, we get $$f(15)=\pm\sqrt{48a^8+88a^6+63a^4+23a^2+3}\,.$$

Now, we know $f(n)$ for $n=1,2,3,\ldots,15$. We can use the induction step from this link to determine $f(n)$ for $n=16,17,18,\ldots,26$, and obtain the following list. $$\begin{array}{|c|c|} \hline n&\big(f(n)\big)^2\\ \hline 1& a^2\\ 2& 4a^4\\ 3& 4a^4 + 4a^2 + 1\\ 4& 32a^8 - 16a^6 - 2a^4 + 2a^2\\ 5& 16a^8 + 8a^6 + a^4\\ 6& -32a^8 + 16a^6 + 34a^4 + 16a^2 + 2\\ 7& 32a^8 + 16a^6 + 2a^4 - a^2\\ 8& 64a^8\\ 9& 32a^6 + 32a^4 + 15a^2 + 2\\ 10& 16a^8 + 40a^6 + 33a^4 + 10a^2 + 1\\ 11& 32a^8 + 48a^6 + 30a^4 + 10a^2 + 1\\ 12& 64a^8 + 32a^6 + 32a^4 + 14a^2 + 2\\ 13& 64a^8 + 64a^6 + 32a^4 + 8a^2 + 1\\ 14& 32a^8 + 80a^6 + 62a^4 + 20a^2 + 2\\ 15& 48a^8 + 88a^6 + 63a^4 + 23a^2 + 3\\ 16& 96a^8 + 80a^6 + 58a^4 + 20a^2 + 2\\ 17& 96a^8 + 112a^6 + 62a^4 + 17a^2 + 2\\ 18& 64a^8 + 128a^6 + 96a^4 + 32a^2 + 4\\ 19& 96a^8 + 144a^6 + 90a^4 + 28a^2 + 3\\ 20& 144a^8 + 136a^6 + 89a^4 + 28a^2 + 3\\ 21& 96a^8 + 176a^6 + 122a^4 + 42a^2 + 5\\ 22& 128a^8 + 192a^6 + 124a^4 + 36a^2 + 4\\ 23& 160a^8 + 208a^6 + 122a^4 + 35a^2 + 4\\ 24& 160a^8 + 208a^6 + 150a^4 + 52a^2 + 6\\ 25& 176a^8 + 248a^6 + 151a^4 + 45a^2 + 5\\ 26& 160a^8 + 272a^6 + 182a^4 + 56a^2 + 6\\ 27& 192a^8 + 288a^6 + 184a^4 + 58a^2 + 7\\ 28& 256a^8 + 288a^6 + 180a^4 + 54a^2 + 6\\ 29& 224a^8 + 336a^6 + 210a^4 + 64a^2 + 7\\ 30& 208a^8 + 360a^6 + 245a^4 + 78a^2 + 9\\ \hline \end{array}$$

In particular, this shows that $$\big(f(26)\big)^2=160a^8+272a^6+182a^4+56a^2+6\,.$$ However, $$f(26)=f(1^2+5^2)=\big(f(1)\big)^2+\big(f(5)\big)^2\,,$$ so $$f(26)=a^2+(4a^4+a^2)^2=16a^8+8a^6+a^4+a^2\,.$$ This shows that $$\begin{align}(a-1)(a+1)(2a^2-a+1)&(2a^2+a+1)(4a^2+3)\\&(16a^8+8a^6+13a^4+12a^2+2)=0\,.\tag{#}\end{align}$$ From (*) and (#), we conclude that $a=\pm1$. This means $f(n)=\pm n$ for all positive integers $n$. Furthermore, $f(n)=n$ when $n$ can be written as a sum of two perfect squares of positive integers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.