9. Given the function $f(x)=a \sin x-\frac{1}{2} \cos 2 x+a-\frac{3}{a}+\frac{1}{2}, a \in \mathbf{R}, a \neq 0$.
(1) If for any $x \in \mathbf{R}$, we have $f(x) \leqslant 0$, find the range of values for $a$;
(2) If $a \geqslant 2$, and there exists $x \in \mathbf{R}$ such that $f(x) \leqslant 0$, find the range of values for $a$.
(1) $f(x)=a \sin x+\frac{1}{2}(1-\cos 2 x)+a-\frac{3}{a}=\sin ^{2} x+a \sin x+a-\frac{3}{a} \leqslant 0$. Let $g(t)=t^{2}+a t+a-\frac{3}{a} \leqslant 0, t \in[-1,1] \Rightarrow\left\{\begin{array}{l}g(-1)=1-\frac{3}{a} \leqslant 0, \\ g(1)=1+2 a-\frac{3}{a} \leqslant 0\end{array}\right.$ $\Rightarrow\left\{\begin{array}{l}a \in(0,3], \\ a \in\left(-\infty,-\frac{3}{2}\right] \cup(0,1]\end{array} \Rightarrow a \in(0,1]\right.$. Therefore, the range of $a$ is $(0,1]$.
(2) From (1), the axis of symmetry of the function $g(t)$ is $x=-\frac{a}{2} \leqslant-1 \Rightarrow g(t)$ is monotonically increasing on $[-1,1]$ $\Rightarrow g(t)_{\min }=g(-1)=1-\frac{3}{a} \leqslant 0 \Rightarrow a \in(0,3] \Rightarrow a \in[2,3]$. Therefore, the range of $a$ is $[2,3]$.