$f:\mathbb{R}\to\mathbb{R},$ such that $f(|f(x)-f(y)|)=f(f(x))-2x^2f(y)+f(y^2)\,\,\forall \, x,y\in\mathbb{R}.$ Find all such $f(x).$
My Working:
Let $P(x,y): f(|f(x)-f(y)|)=f(f(x))-2x^2f(y)+f(y^2)\,\,\forall \, x,y\in\mathbb{R}$
$P(0,0):f(f(0))=0;$ Let $f(0)=a\implies f(a)=0$
$P(a,a): f(|f(a)-f(a)|)=f(f(a))-2a^2f(a)+f(a^2)\implies f(a^2)=0$
$P(0,x):f(|f(0)-f(x)|)=f(x^2)$ ---(1)
$P(x,0): f(|f(x)-f(0)|)=f(f(x))-2ax^2+a$ ---(2)
$P(x, x):a=f(f(x))-2x^2f(x)+f(x^2)$ ---(3)
From (1) and (2), we get $f(f(x))=f(x^2)+2ax^2-a$ ---(4)
$P(x,a): f(|f(x)|)=f(f(x))\text{ and }P(a,x): f(|f(x)|)=a-2a^2f(x)+f(x^2)$
$\implies f(f(x)=a-2a^2f(x)+f(x^2)$ ---(5)
From (4) and (5) we get, $2a^2f(x)=2a(1-x^2)$
$\implies a=0\text{ or } f(x)=\frac1a(1-x^2)$
Considering, $f(x)=\frac1a(1-x^2)\text{ and plugging it in parent we get two solutions, } f(x)=1-x^2,\,\, f(x)=x^2-1$
Now consider $a=0,\text{ i.e. } f(0)=0$
$\implies f(f(x))=f(x^2)=x^2f(x)$
I guessed $f(x)=0,\pm\, x^2$