求下列函数的值域.

(1) $y=2 \sin \left(2 x+\frac{\pi}{3}\right), x \in\left[-\frac{\pi}{6}, \frac{\pi}{6}\right]$;

(2) $f(x)=1-2 \sin ^{2} x+2 \cos x$.
(1) $\because-\frac{\pi}{6} \leqslant x \leqslant \frac{\pi}{6}, \therefore 0 \leqslant 2 x+\frac{\pi}{3} \leqslant \frac{2 \pi}{3}$,

$\therefore 0 \leqslant \sin \left(2 x+\frac{\pi}{3}\right) \leqslant 1, \quad \therefore 0 \leqslant 2 \sin \left(2 x+\frac{\pi}{3}\right) \leqslant 2$,

$\therefore$ 原函数的值域为 $[0,2]$.

(2)f(x)=1-2sin $\sin ^{2} x+2 \cos x=2 \cos ^{2} x+2 \cos x-1=2\left(\cos x+\frac{1}{2}\right)^{2}-\frac{3}{2}$,

$\therefore$ 当 $\cos x=-\frac{1}{2}$ 时, $f(x)_{\min }=-\frac{3}{2}$,

当 $\cos x=1$ 时, $f(x)_{\text {max }}=3$,

$\therefore$ 该函数值域为 $\left[-\frac{3}{2}, 3\right]$.