The maximum and minimum values of the expression Here is the question:find the difference between maximum and minimum values of $u^2$ where $$u=\sqrt{a^2\cos^2x+b^2\sin^2x} + \sqrt{a^2\sin^2x+b^2\cos^2x}$$

My try:I have just normally squared the expression  and got
$u^2=a^2\cos^2x+b^2\sin^2x + a^2\sin^2x+b^2\cos^2x +2\sqrt{a^2\cos^2x+b^2\sin^2x} \sqrt{a^2\sin^2x+b^2\cos^2x}$ 
$u^2=a^2+b^2 +2\sqrt{a^2\cos^2x+b^2\sin^2x} .\sqrt{a^2\sin^2x+b^2\cos^2x}$ 
I am not getting how to solve the irrational part,so how should we do it.Is there some general way to solve such questions?

Write 
$$\cos^2x=\frac{1+\cos 2x}{2}$$
and
$$\sin^2x=\frac{1-\cos 2x}{2}$$
Then, we have
$$u=\sqrt{A+B\cos 2x}+\sqrt{A-B\cos 2x}\tag 1$$
where 
$$A=\frac{a^2+b^2}{2}$$
$$B=\frac{a^2-b^2}{2}$$
Taking the derivative of u in $(1)$ and setting the derivative equal to zero reveals 
$$\frac{-B\sin 2x}{\sqrt{A+B\cos 2x}}+\frac{B\sin 2x}{\sqrt{A-B\cos 2x}}=0$$
whereupon solving reveals that either $\sin 2x=0$ or $\cos 2x=0$.  When $\cos 2x=0$, 
$$\bbox[5px,border:2px solid #C0A000]{u=\sqrt{2(a^2+b^2)} \,\,\text{is the maximum}}$$
and when $\sin 2x =0$, 
$$\bbox[5px,border:2px solid #C0A000]{u=|a|+|b|\,\,\,\text{is the minimum}}$$ 
