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

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.

• The part about the inverse can be skipped by simply noting that $f$ is injective. Then we can already conclude that $f(n) = f(n+2)+2$. Commented Nov 10, 2020 at 11:05
• minor complaint - in the future, please have at least one (non-math) word in your query's title, so that reviewers can right click to open the page. Commented Nov 10, 2020 at 11:07
• @player3236 Ok, so is it in fact the only solution $(1-x)$?
– aman
Commented Nov 10, 2020 at 11:13
• You have shown $(1-x)$ is the only solution by induction pretty nicely. Commented Nov 10, 2020 at 11:17
• Looks good, see also Solving an Olympiad functional equation $f(f(n))=f(f(n+2)+2)=n$ and Proof verification: system of functional equation, well and many more: approach0.xyz/search/… :)
– Sil
Commented Nov 11, 2020 at 20:41