Find all functions $f:\mathbb{R} \to \mathbb{R}$ such that $f(x^2 + y + f(y)) = 2y + (f(x))^2$ 
Find all functions $f:\mathbb{R} \to \mathbb{R}$ such that $$f(x^2 + y + f(y)) = 2y + (f(x))^2$$

I tried something like this but that inner $f(y)$ makes things worse to my opinion. Any help is appreciated.
 A: *

*Replacing $x$ with $-x$ in the original equation, we get $f(-x)^2 = f(x)^2$ for any $x$. Equivalently, $f(x)^2 = f(|x|)^2$ holds for all $x$.


*We have $f(x^2 + y + f(y)) \geq 2y$. For any $y$, if $f(y) \leq 0$, then putting $x = \sqrt{-f(y)}$ in the inequality gives $f(y) \geq 2y$, hence $y \leq 0$.
In other words, if $y > 0$, then $f(y) > 0$.


*For any $y \neq 0$, we have $f(y)^2 = f(|y|)^2 \neq 0$ by 1 and 2. That is, if $f(y) = 0$, then $y = 0$.


*Putting $y = -f(x)^2 / 2$ in the original equation, we get $f(\frac{x^2}2 + f(-\frac{x^2}2)) = 0$, which implies $f(-\frac{x^2}2) = -\frac{x^2}2$ by 3. Since $x$ is arbitrary, we see that $f(x) = x$ for any $x \leq 0$.


*Combining 4 with 1 and 2, we get $f(x) = x$ for all $x$.
A: Here's my solution:
We claim that the only solution to the functional equation is $f(x)=x$, indeed it is easy to see that it is a solution. Now, we prove that it is the only one.
Let $P(x,y)$ denote the given assertion, by comparing $P(x,y)$ and $P(-x,y)$ we see that $f(x)^2=f(-x)^2$.
Then, we claim that $f$ is surjective, indeed, $$P(0,x): f(x+f(x))=2x+f(f(0))^2$$ and take any $k \in \mathbb{R}$, let $x=\frac{k-f(f(0))^2}{2}$, we get $f\left(\frac{k-f(f(0))^2}{2}+f\left(\frac{k-f(f(0))^2}{2}\right)\right)=k$.
Let $a\in \mathbb{R}$ such that $f(a)=a$, from $f(x)^2=f(-x)^2$, by letting $x=a$, we see that $f(-a)=0$. Moreover, we have $$P(0,a): 0=f(a+f(a))=2a+f(f(0))^2$$ $$P(0,-a): 0=f(-a+f(-a))=-2a+f(f(0))^2$$ subtracting both equation yields $a=0$. Therefore, we also have $f(x+f(x))=2x$ and $P(x,0) : f(x^2)=f(x)^2\ge 0$.
We now prove that $f$ is odd, notice that since $$P\left(x,-\frac{f(x)^2}{2}\right): f\left(x^2-\frac{f(x)^2}{2}+f\left(-\frac{f(x)^2}{2}\right)\right)=0$$ by the fact above that if $f(a)=0$, then $a=0$, we have $$-\frac{f(x)^2}{2}+f\left(-\frac{f(x)^2}{2}\right)=-x^2 \implies f\left(-\frac{f(x)^2}{2}+f\left(-\frac{f(x)^2}{2}\right)\right)=f(-x^2).$$ On the other hand, we have $$P\left(0,-\frac{f(x)^2}{2}\right): f\left(-\frac{f(x)^2}{2}+f\left(-\frac{f(x)^2}{2}\right)\right)=-f(x)^2$$ which means that $f(-x^2)=-f(x^2)=-f(x)^2 \le 0$. Therefore, we can see that $f(x)=-f(-x)$.
Now, there are two ways to proceed:
1st way: We show that $f$ is injective, denote $Q(x,y)$ by the new assertion $$P(\sqrt{x},y): f(x+y+f(y))=2y+f(\sqrt{x})^2=2y+f(x) \ \forall x\ge 0$$ if $x\le 0$, then use $P(\sqrt{-x},y)$. (Or just use the fact that $f$ is odd.) Then, by comparing $Q(x,y)$ and $Q(y,x)$, if $f(s)=f(t)$, then $s=t$. So, $f$ is bijective.
Next, since $f$ is bijective, so as $x+f(x)$. Thus, $f$ is additive! As $$f(x^2+y+f(y))=2y+f(x)^2=f(x^2)+f(y+f(y)).$$ And so, since $f$ is also positive on the positive reals, it is linear, by checking, $f\equiv x$.
2nd way: As we have shown that $f(x)=-f(-x)$, $$P(x,-x^2): -f(f(x)^2)=f(f(-x^2))=-2x^2+f(x)^2$$ also since $x^2-\frac{f(x)^2}{2}+f\left(-\frac{f(x)^2}{2}\right)=0 \implies -2x^2+f(x)^2=2f\left(-\frac{f(x)^2}{2}\right)=-2f\left(\frac{f(x)^2}{2}\right)$, we have $$f(f(x)^2)=2f\left(\frac{f(x)^2}{2}\right)\implies f(x)=2f\left(\frac{x}{2}\right) \ \forall x\ge 0$$ by surjectivity.
Next, as $f(x+f(x))=2x$, by replacing $x$ with $f(x)$ gives $$f(f(x)+f(f(x)))=2f(x)=f(2x) \implies f(x)+f(f(x))=2x \ \forall x\ge 0.$$ Since $f$ is positive on the positive reals, we use recurrence relation to solve for $f$, let $x_n=f^n(x)$, where $f$ is iterated $n$ times and define $x_0=x$ for a arbitrary real positive number, then this yields the following recurrence relation $$x_{n+1}+x_n-2x_{n-1}=0$$ which $x_n=\lambda_1\cdot (1)^n+\lambda_2 \cdot (-2)^n$ and $x_0=\lambda_1-\lambda_2$, $x_1=\lambda_1-2\lambda_2$ since $a_n\ge 0$, we must have $\lambda_2 =0$ otherwise $a_n$ would be negative for some arbitrary large, so we have $f(x_0)=x_1=\lambda_1=x_0$. Hence, as $x_0$ is arbitrary, we have $f(x)=x$ for all positive reals and since $f$ is odd $f\equiv x$.
