<s>[INST] finding the max of $f(x)=\sqrt{(x^2-4)^2+(x-5)^2}-\sqrt{(x^2-2)^2+(x-1)^2}$ I need to find the max of $$f(x)=\sqrt{(x^2-4)^2+(x-5)^2}-\sqrt{(x^2-2)^2+(x-1)^2}$$
When $x$ is a real number.
What i did is to simplify: $$f(x)=\sqrt{x^4-7x^2-10x+41}-\sqrt{x^4-3x^2-2x+5}$$.
Then i compute: $$f'(x)=\frac{-5-7x+2x^3}{\sqrt{41-10 x-7 x^2+x^4}}+\frac{1+3x-2x^3}{\sqrt{5-2 x-3 x^2+x^4}}$$.
But failed to solve $f'(x)=0$ for finding $f(x)_{max}$.
I would be glad for your help.
Thanks.
 [/INST] You have $\frac{-5-7x+2x^3}{\sqrt{41-10x-7x^3+x^4}}+\frac{1+3x-2x^3}{\sqrt{5-2x-3x^2+x^4}}=0$ so 
$\frac{-5-7x+2x^3}{\sqrt{41-10x-7x^3+x^4}}=-\frac{1+3x-2x^3}{\sqrt{5-2x-3x^2+x^4}}$ then 
$\frac{(-5-7x+2x^3)^2}{41-10x-7x^3+x^4}=\frac{(1+3x-2x^3)^2}{5-2x-3x^2+x^4}$ and finally $(5-2x-3x^2+x^4)(-5-7x+2x^3)^2=(41-10x-7x^3+x^4)(1+3x-2x^3)^2$
Its a large polynomial but you have to find the 10 roots (removing the strange roost that made $41-10x-7x^3+x^4<0$ or $5-2x-3x^2+x^4<0$) and check which of them is the max or if the max is in $-\infty$ or $\infty$. It will be a long way if you want to made it by your own...
Well you can remove $(x+1)^2$ by common factor in both sides so $x=-1$ are 2 roots and remain 8:
$(2x^2-2x-5)^2(x^4-3x^2-2x+5)=(2x^2-2x-1)^2(x^4-7x^3-10x+41)$
And by expanding you can get
$28x^7-84x^6+72x^5-108x^4+267x^3-155x^2-104x+84=0$ and dividing by $(x-1)$ (and therefore $x=1$ is another root)
$28x^6-56x^5+16x^4-92x^3+172x^2+20x-81=0$
only 6 roots remain and you can use methods to approach them to $x\approx-0.614946$ and $x\approx0.886814$
</s>