5. If there exists a real number $x$, such that $\sin \left(x+\frac{\pi}{4}\right)-\sin 2 x=a$, then the range of values for the real number $a$ is . $\qquad$
5. $-2 \leqslant a \leqslant \frac{9}{8}$.

Let $\sin \left(x+\frac{\pi}{4}\right)=\frac{\sqrt{2}}{2}(\sin x+\cos x)=t$, then $t \in[-1,1], 2 t^{2}-1=\sin 2 x . f(t)=t-$ $\left[2 t^{2}-1\right]=-2 t^{2}+t+1=-2\left(t-\frac{1}{4}\right)^{2}+\frac{9}{8}$, when $t=\frac{1}{4}$, $f(t)$ reaches its maximum value of $\frac{9}{8}$; when $t=-1$, $f(t)$ reaches its minimum value of -2. Therefore, $-2 \leqslant a \leqslant \frac{9}{8}$.