Proving equality of two functions

Let $f(2n) = 2n; f(2n+1) = f(2n+2); g(2n) = 2n+1; g(2n+1)= 2n+1$. (i.e. $f$ takes $n$ to the first even number equal or larger than $n$. $g$ takes $n$ to the first odd number equal or larger than $n$.

Then $f(g(2n)) = f(2n+1) = 2n+2 = 2n + 1 + 1 = g(2n) + 1$

$f(g(2n+1)) = f(2n+1) = 2n+2 = 2n+1 + 1 = g(2n+1) + 1$

$g(f(2n)) = g(2n)=2n+1 = f(2n) + 1$

$g(f(2n+1)) = g(2n+2) = 2n + 3 = 2n+2 + 1 = f(2n+1) + 1$.

So the statement isn't true. But is true for all $n \in Im(f) \cap Im(g)$


Let $Deg(f(n)) = a$ and $Deg(g(n))=b$ such that $Deg(f)$ is the biggest power in the polynomial $f$.

For example : $Deg(2n^3+7n-5)=3$ and $Deg(-7n^5+3n^2+n)=5$.

Now it easy to see that $Deg(f(g(n))) - Deg(g(n)) = 0$ and $Deg(g(f(n)))-Deg(f(n))=0$, and since $Deg(f(g(n)),Deg(g(f(n)))= a b$.

We have few cases :

$a,b>1$ then $a b> a,b$ which means no polynomials of degree higher than $1$ can satisfy your condition.

$a=1, b>1$ then $a b = b$ but $a b \not= a$, also the same conclusion(without loss of generality).

$a=0,b>1$ then $a b =a$ but $a b \not= b$, also the same conclusion(without loss of generality).

$a=1,b=1$ then the only functions satisfy this are the functions $f(n)=n+1,g(n)=n+1$ and in this case $f(n)=g(n)$.

$a=0,b=1$ then $a b=a \not =b$ also the same conclusion(without loss of generality).

$a=0,b=0$ then $ab=a=b$ which means that you can not discard this situation using this method but setting $f(n)=c_0$ and $g(n)=c_1$ gives that there is no such constant polynomials.

In conclusion : if for any two polynomials $f(n),g(n)$ if $f(g(n))=g(n)+1$ and $g(f(n))=f(n)+1$ then $f(n)=g(n)$ and to be explicit $f(n)=g(n)=n+1$

Note : this answer is only about polynomial(not necessarily from integers to integers) but does not prove the general question about other kind of functions.