Let $B = \sin(x) + \cos(x) + 2\sin(2x).$ Find the maximum of $B$?
My try:
Let $t = \sin(x) + \cos(x),\ -\sqrt{2}\leqslant t\leqslant\sqrt{2}.$
$\Rightarrow \sin (2x) = t^2 - 1.$
Then we have $$B = \sin(x) + \cos(x) + 2\sin(2x) = 2t^2 + t - 2.$$
Let $f(t) = 2t^2 + t - 2,\ -\sqrt{2}\leqslant t\leqslant\sqrt{2}.$ Then,
$$\max\limits_{[-\sqrt{2};\sqrt{2}]} f(t) = f(\sqrt{2}) = 2 + \sqrt{2}.$$
Thus $\max B = 2 + \sqrt{2}$ if and only if
$\sin(x) + \cos(x) = \sqrt{2}\\ \Leftrightarrow\ \sin\left(x + \dfrac{\pi}{4}\right) = 1\ \Leftrightarrow\ x + \dfrac{\pi}{4} = \dfrac{\pi}{2} + k2\pi\ \Leftrightarrow\ x = \dfrac{\pi}{4} + k2\pi\ (k\in\mathbb Z).$
$B'(x)=\cos(x)-\sin(x)+4\cos(2x)$. We want to find the points $x$ such that $B'(x)=0$, i.e.
$$0=\cos(x)-\sin(x)+4(1-2\sin^2(x))$$ which is equivalent to
$$-\cos(x)=-\sin(x)+4(1-2\sin^2(x))$$
$$\cos^2(x)=(-\sin(x)+4(1-2\sin^2(x)))^2$$
$$1- \sin^2(x)=(-\sin(x)+4(1-2\sin^2(x)))^2$$
Now set $\sin(x)=a$ to obtain the equation
$$-64a^4-16a^3+62a^2+8a-15=0$$
which has $4$ roots - $\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},-\frac{1}{8}-\frac{\sqrt{31}}{8},\frac{\sqrt{31}}{8}-\frac{1}{8}$
Since you know the value of $\sin(x)$ which is an extremum of $B$ you can find the value of the respective $\cos(x)$ and find the maximum of $B$.
The answer is that you want points of the form $2k\pi-\frac{3\pi}{4}$ and your maximum is $2+\sqrt{2}$