Find $f$ so that $f(f(n))=f(f(n+2)+2)=n$

494 Views Asked by At

Find all functions $f$ such that: $$f(f(n))=f(f(n+2)+2)=n, f(0)=1$$

I used the following logic: if $f(k)=f(l)$ then $f(f(k))=f(f(l))$ so $k=l$.

And, for all numbers $m$ there exists a number $p=f(m)$ such that $f(p)=m$.

So, each number has an inverse through $f$ and this inverse must be unique.

Let $g$ be a function mapping a number to its inverse through $f$, i.e. $g(m)=p$ is the unique number such that $f(p)=m$.

Then we can apply $g(f(x))=x$.

Taking $g$ on both sides of the original equation, we get: $f(n)=f(n+2)+2$. By induction backwards and forwards, we see that $f(2k)=-2k+1$ for all $k$.

We also see $f(0)=1\implies f(f(0))=f(1)\implies f(1)=0$ so $f(2k+1)=-2k$ for all $k$ by induction.

So, $f(x)=1-x$.

Does this logic work? It seems that defining an inverse is a bit of a complicated way to solve, but it seems to come logically.