4. The range of the function $y^{\prime}=\frac{\sin 9 x}{\sin x}+\frac{\cos 9 x}{\cos x}$ is
4. $\left[-\frac{5}{2}, 10\right)$.

It is clear that $\sin x \neq 0, \cos x \neq 0$. Thus, $x \neq \frac{k \pi}{2}(k \in \mathbb{Z})$. Therefore, $\cos 4 x \in[-1,1)$.
$$
\begin{array}{l}
\text { Hence } y=\frac{\sin 9 x}{\sin x}+\frac{\cos 9 x}{\cos x} \\
=2 \cos 8 x+\sin 8 x\left(\frac{\cos x}{\sin x}-\frac{\sin x}{\cos x}\right) \\
=2\left(\cos 8 x+\sin 8 x \cdot \frac{\cos 2 x}{\sin 2 x}\right) \\
=2\left(2 \cos ^{2} 4 x-1+4 \cos 4 x \cdot \cos ^{2} 2 x\right) \\
=2\left(4 \cos ^{2} 4 x+2 \cos 4 x-1\right) \\
=8\left(\cos 4 x+\frac{1}{4}\right)^{2}-\frac{5}{2} \in\left[-\frac{5}{2}, 10\right) .
\end{array}
$$