find $f$ such $f(f(x)+y)=2x+f(f(f(y))-x)$ Find all function $f:R\to R$,such for any real number $x,y$ have
$$f(f(x)+y)=2x+f(f(f(y))-x)$$
I have prove this one result:
$$f(f(0))=f(0)$$
proof:let $x=y=0$,then we have
$$f(f(0))=f(f(f(0)))$$
and take $x=f(f(0)),y=0$,we have
$$f(f(f(f(0))))=2f(f(0))+f(0)$$
so we have
$$f(f(0))=-f(0)$$
use this links Ivan Loh methods to prove two reslut:
$f(x)$ is also injective
proof: For convenience, let $P(x, y)$ represent the equation $f(f(x)+y)=2x+f(f(f(y))-x)$.
$P(x, -f(x))$ gives $f(f(-f(f(x)))-x)=f(0)-2x$. Thus $f(x)$ is surjective.
Suppose $f(a)=f(b)$ for some $a, b$. Then $P(x, a)$ and $P(x, b)$ give
$$f(f(x)+a)=2x+f(f(f(a))-x)=2x+f(f(f(b))-x)=f(f(x)+b)$$
Since $f(x)$ is surjective, $f(x+a)=f(x+b) \, \forall x \in \mathbb{R}$.
Now using the above equation and $P(a, y), P(b, y)$ give
\begin{align}
2a=f(f(a)+y)-f(f(f(y))-a) & =f(f(a)+y)-f(f(f(y))-(a+b)+b) \\
&=f(f(a)+y)-f(f(f(y))-(a+b)+a) \\
& =f(f(b)+y)-f(f(f(y))-b) \\
& =2b
\end{align}
Thus $f(x)$ is also injective.
Finally, $P(0, y)$ gives $f(y+f(0))=f(f(f(y)))$, so since $f(x)$ is injective, $$f(f(y))=y+f(0) \, \forall y \in \mathbb{R}$$.
then I can't  continue ,and I think this answer is $f(x)=x$.so How to prove it.and this problem is  from   my teacher to give me exercise .Thanks for you help!
Now when post this post,This site automatically displays a prompt for a similar question to me(But it's different problem) :links
 A: let
$$p(x,y)=f(f(x)+y)-2x=f(f(f(y))-x)$$
we have from $p(x,-f(x))$ that $f$ is surgective. assume $f(a)=f(b)$ then from
$$p(x,a)-p(x,b)$$
We have
$$f(f(x)+a)=f(f(x)+b)$$
so we have if $a-b=t$ then
$$f(x+t)=f(x)$$
because $f$ is surgective.now we have :
$$p(x+t,y)-p(x,y)=0=2t$$
so $t=0$ now we have from
$$p(0,y)=f(f(0)+y)=f(f(f(y)))$$
so we have
$$T(y)=y+f(0)=f(f(y))$$
we have from $T(0)$ that
$$f(0)=f(f(0))$$
so $f(0)=0$ and we rewrite $T(y)$ as
$$y=f(f(y))$$
now rewrite $p(x,y)$ as
$$p(x,y)=f(y+f(x))=2x+f(y-x)$$
let
$$q(x,y)=p(x,y+x)=f(y+f(x)+x)=2x+f(y)$$
from $q(x,0)$ we have
$$f(f(x)+x)=2x$$
so $f(x)+x$ is injective and surgective aswell. so we can just write $q(x,y)$ as
$$q(x,y)=f(x+f(x)+y)=f(x+f(X))+f(y)$$
as $x+f(x)$ is injective and surgective. we can rewrite it as
$$W(x,y)=f(x+y)=f(x)+f(y)$$
so we have that $f$ is additive. remember we had $f(f(x)+x)=2x$ so we have
$$f(f(x))+f(x)=x+f(x)=2x$$
which gives $f(X)=x$ for all real $x$ and we are done
A: A partial answer for $f$ polynomial.
►Clearly $f(x)$ is not constant.
►Test for a linear polynomial $f(x)=ax+b$.
$$f(f(x)+y)=f(ax+b+y)=a(ax+b+y)+b=a^2x+ay+(ab+b)\\2x+f(fof(y)-x)=2x+f(a(ay+b)+b-x)=2x+a(a(ay+b)+b-x)+b\\2x+f(fof(y)-x)=(2-a)x+a^3y+(a^2+1)b$$ It follows
$$a^2=2-a\Rightarrow a=1\text {and } a=-2 $$ and $$\begin{cases}a=a^3\\(a+1)b=(a^2+a+1)b\end{cases}$$ therefore $a=1$ and $2b=3b\Rightarrow b=0$.
Thus the only possible polynomial of degree $1$ is $\boxed{f(x)=x}$
►Test for $f(x)=a_nx^n+\cdots+a_1x+a_0$ where $n\gt1$ ( and $a_n\ne0$ of course)
Since the equality is valid for all $x,y$ we take $y=0$ and look  for a contradiction. $$fof(x)=2x+f(fof(0)-x)\large?$$
We have $$ fof(x)=a_n(a_nx^n+\cdots+a_1x+a_0)^n+\cdots+a_1(a_nx^n+\cdots+a_1x+a_0)+a_0$$ Note that $fof(0)=f(a_0)=a_n(a_0)^n\cdots+a_1(a_0)+a_0$.
$$2x+f(f(a_0)-x)=2x+a_n(f(a_0)-x)^n+\cdots+a_1(f(a_0)-x)+a_0$$ $LHS$ is of  $n^2$ degree while $RHS$ is of $n$ degree which implies that all the coefficients from $x^{n^2}$ until $x^{n+1}$ should be zero. In particular we would have $a_na_n^{n}=0$. Contradiction.
$$**************************************$$
Is $f(x)=x$ the only solution $\large ?$
We have $$f(f(x)+y)=f(f(f(y))-x)+2x$$ for all $x,y$ so it is valid for $x=y=0$; therefore
$$fof(0)=f(fof(0))$$ which means that $fof(0)$ is a fixed point of $f$. Making now $x=0$ we have
$$f(f(0)+y)=f(fof(y))$$ so if $f(0)=0$ then $f(y)=fof(f(y))$ and $f(y)$ is a fixed point of $fof$ for all $y$ so $fof(x)=x$ for all $x$ in the codomain of $f$. It follows that if  $f$ is surjective and $f(0)=0$ then the only function required is the identity $\boxed{f(x)=x}$.
Note that for all fixed $y$ the function $F_y(x)$ defined by $$F_y(x)=f(f(x)+y)-f(f(f(y))-x)=2x$$
is a bijection because $2x$ so is. I stop here. Whoever wants, if desired, can finish the solution following this way.
