6. The maximum value of the function $y=\sin x+\sqrt{3} \cos x-2 \sin 3 x$ is $\qquad$
6. $\frac{16 \sqrt{3}}{9}$.

Notice,
$$
\begin{aligned}
y & =2 \sin \left(x+\frac{\pi}{3}\right)+2 \sin (3 x+\pi) \\
& =2 \sin \alpha+2 \sin 3 \alpha,
\end{aligned}
$$

where, $\alpha=x+\frac{\pi}{3}$.
$$
\begin{array}{l}
\text { By } \sin \alpha+\sin 3 \alpha=4 \sin \alpha-4 \sin ^{3} \alpha \\
=4 \sin \alpha \cdot\left(1-\sin ^{2} \alpha\right) \\
=2 \sqrt{2} \sqrt{2 \sin ^{2} \alpha \cdot\left(1-\sin ^{2} \alpha\right)\left(1-\sin ^{2} \alpha\right)} \\
\leqslant 2 \sqrt{2} \sqrt{\left(\frac{2}{3}\right)^{3}}=\frac{8 \sqrt{3}}{9},
\end{array}
$$

When $\sin ^{2} \alpha=\frac{1}{3}$, the equality holds.
Therefore, $y_{\text {max }}=\frac{16 \sqrt{3}}{9}$.