TITLE: Correct result for this integral $\int \frac{\sqrt{\sqrt{\sqrt{2 \cos \left(5 \sqrt{x}+4\right)+2}+2}+2}}{\sqrt{x}}\, dx$
QUESTION [6 upvotes]: Wolfram|Alpha and its CAS, Wolfram Mathematica are, as far as I know, the only website and software that give the correct solution to this integral,
$$ f(x) = \frac{\sqrt{\sqrt{\sqrt{2 \cos \left(5 \sqrt{x}+4\right)+2}+2}+2}}{\sqrt{x}} $$
$$ F(x) = \int f(x)\, dx$$
because deriving the function given as result and using the FullSimplify function of Mathematica we get to the original function that we wanted to integrate.
This is the solution:
$$ F(x) = \frac{1}{5} (-8) \sqrt{2} \sqrt{\cos \left(5 \sqrt{x}+4\right)+1} \sqrt{\sqrt{2} \sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+2} \left(\sqrt{\sqrt{2} \sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+2}-2\right) \sqrt{\sqrt{\sqrt{2} \sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+2}+2} \csc \left(5 \sqrt{x}+4\right) + C $$
Fricas finds another expression for the integral that I'm curious about:
$$ F(x) = \frac{1}{5} (-8) \sqrt{2} \sqrt{\sqrt[4]{2} \sqrt{\sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+\sqrt{2}}+2} \left(\sqrt{2} \cos \left(5 \sqrt{x}+4\right)-2 \sqrt{\sqrt{2} \sqrt{\cos \left(5 \sqrt{x}+4\right)+1} \left(\sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+\sqrt{2}\right)+2 \sqrt{\cos \left(5 \sqrt{x}+4\right)+1}+\sqrt{2}}\right) \csc \left(5 \sqrt{x}+4\right) + C$$
However, in this video, an incorrect result is given although the integration process seems correct. As above, you know that the result is incorrect since deriving the resulting function doesn't result in the original function we wanted to integrate.
Is the expression given by Fricas equivalent to the one given by Wolfram|Alpha and Mathematica?
Final update: According to Mathematica, the expression given by FriCAS is not equal to the correct solution given by Mathematica and Wolfram|Alpha. This means it is not the solution to this problem.

REPLY [2 votes]: $$f(x)=\dfrac1{\sqrt x}\sqrt{2+\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}
=\dfrac1{\sqrt x}\,\dfrac{\sqrt{2-\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}}$$
$$=\dfrac1{\sqrt x}\,\dfrac{\sqrt{2-2\cos(5\sqrt x+4)\large\mathstrut}}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}$$
$$=\dfrac1{\sqrt x}\,\dfrac{\sqrt{4-4\cos^2(5\sqrt x+4)\large\mathstrut}}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}$$
$$=\dfrac25\,\dfrac{2\cdot\dfrac5{2\sqrt x}\,|\sin(5\sqrt x+4)|}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}$$
$$=-\dfrac{4}5\,\dfrac{\operatorname{sign}(\sin(5\sqrt x+4))\cdot(2+2\cos(5\sqrt x+4))'}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}\;2\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}$$
$$=-\dfrac{8}5\,\dfrac{\operatorname{sign}(\sin(5\sqrt x+4))\cdot\left(2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}\right)'}{\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\;2\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}$$
$$=\dfrac{16}5\,\dfrac{\operatorname{sign}(\sin(5\sqrt x+4))\cdot\left(2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}\right)'}{2\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}}$$
$$=\dfrac{16}5\,\operatorname{sign}(\sin(5\sqrt x+4))\cdot\left(\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}\right)'.$$
Easily to check, that the function
$$F_0(x)=\dfrac{16}5\,\operatorname{sign}(\sin(5\sqrt x+4))\cdot\sqrt{2-\sqrt{2+\sqrt{2+2\cos(5\sqrt x+4)\large\mathstrut}}}$$
corresponds to the given one in the OP and presents the antiderivative in the aparted intervals (a blue line in the WA plot below).
At the same time, eliminating of the negative gaps allows to obtain continuous antiderivative in the form of
$$F(x)=F_0(x)+\dfrac{32}5\sqrt{2-\sqrt2}\genfrac\lfloor\rfloor{}{}{-\pi+4+5\sqrt x}{2\pi}$$
(a violet line).