Finding the range of $f(x)=\cos x\left(\sin x+\sqrt{\smash[b]{\frac12+\sin^2x}}\right)$ 
How do I find the number of integers in the  range of
  $$f(x)= \cos x\left( \sin x + \sqrt{\dfrac 12 +\sin^2 x} \right)?$$

I set the derivative equal to $0$ but the method isn't efficient here because it gives a very complicated trigonometric equation. What's the proper way to do this then? 
 A: hint: Put $u = \cos x, v = \sin x$, then the problem becomes: Find the min/max of the function $f(u,v) = u\left(v+\sqrt{1/2+v^2}\right)$, subject to $u^2+v^2=1$ by Lagrange Multiplier method. I think it is doable this way. Can you try ? It is two variable function but it is much nicer than the original function indeed !
A: Since you are asking about integers in the range, we do not need to fully know the end points of the range, and we don't need calculus.
Clearly the integer $0$ is in the range, considering $x=\pi/2$.
Since $f(\pi/4)=\frac{\sqrt{2}}{2}\left(\frac{\sqrt{2}}{2}+1\right)=\frac{1+\sqrt{2}}{2}>1$, the integer $1$ is in the range as well (by the Intermediate Value Theorem). 
Is $2$ in the range? If so, then $$
\begin{align}
2&=\cos x\left( \sin x + \sqrt{\dfrac 12 +\sin^2 x} \right)\\
2-\sin(x)\cos(x)&=\cos(x)\sqrt{\dfrac 12 +\sin^2 x}\\
4-4\sin(x)\cos(x)+\sin^2(x)\cos^2(x)&=\cos^2(x)\left(\dfrac 12 +\sin^2 x\right)\\
4-4\sin(x)\cos(x)&=\frac{1}{2}\cos^2(x)\\
4-2\sin(2x)&=\frac{1}{2}\cos^2(x)
\end{align}
$$
This has no solutions since the smallest the left side can be is $2$, and the largest the right side can be is $\frac{1}{2}$.
So $2$ is not in $f$'s range. Again using the Intermediate Value Theorem, no integer larger than $2$ is in the range either, or else $2$ would be in the range.
Lastly, note that $x\mapsto\pi-x$ preserves $\left( \sin x + \sqrt{\dfrac 12 +\sin^2 x} \right)$ but negates $\cos(x)$. So $f(\pi-x)=-f(x)$. And this means that $f$ takes negative values just as it takes positive values. That is, $-1$ is in the range, but not $-2$ or anything smaller.
So the integers in the range of $f$ make up the set $\{-1,0,1\}$.
A: Done it! 
Let $f(x)= y$
$\implies y\sec x - \sin x = \sqrt{\sin^2x +\dfrac 12} $
$\implies y^2 \sec^2 x - 2y\sec x \sin x = \dfrac 12 \implies 2y^2(\tan^2x)+ - 4y \tan x + 2y^2 -1 = 0$
For $\tan x $ to be real, $\Delta \ge0$
$\implies 6y^2- 4y^4 \ge 0  \implies -\sqrt{\dfrac 32}\le y \le\sqrt{\dfrac 32} $
Which is the correct range according to the graph as well.
Hence, the number of integers in the range of $f(x)$
 is 3: $0$, $-1$ and $1$
