9. (i) (Grade 11) Given $\sin \theta+\cos \theta=\frac{\sqrt{2}}{5}$ $\left(\frac{\pi}{2}<\theta<\pi\right)$. Then $\tan \theta-\cot \theta=$ $\qquad$ .
(ii) (Grade 12) The function $f(x)=\frac{1}{\sin ^{2} x}+\frac{2}{\cos ^{2} x}$ $\left(0<x<\frac{\pi}{2}\right)$ has a minimum value of $\qquad$ .
9. (i) $-\frac{8 \sqrt{6}}{23}$.

Squaring the condition $\sin \theta + \cos \theta = \frac{\sqrt{2}}{5}$, we get
$$
1 + 2 \sin \theta \cdot \cos \theta = \frac{2}{25}.
$$

Therefore, $\sin \theta \cdot \cos \theta = -\frac{23}{50}$,
$$
(\sin \theta - \cos \theta)^2 = 1 - 2 \sin \theta \cdot \cos \theta = \frac{48}{25}.
$$

Since $\theta$ is in the second quadrant, $\sin \theta - \cos \theta = \frac{4 \sqrt{3}}{5}$.
Then, $\tan \theta - \cot \theta = \frac{\sin \theta}{\cos \theta} - \frac{\cos \theta}{\sin \theta} = \frac{\sin^2 \theta - \cos^2 \theta}{\sin \theta \cdot \cos \theta}$
$$
= \frac{(\sin \theta + \cos \theta)(\sin \theta - \cos \theta)}{\sin \theta \cdot \cos \theta} = -\frac{8 \sqrt{6}}{23}.
$$
$$
\begin{array}{l}
\text { (ii) } 3 + 2 \sqrt{2}. \\
f(x) = \cot^2 x + 1 + 2 \tan^2 x + 2 \\
= 3 + (2 \tan^2 x + \cot^2 x) \geqslant 3 + 2 \sqrt{2}.
\end{array}
$$

When $2 \tan^2 x = \cot^2 x$, i.e., $\cot x = \sqrt[4]{2}$, the equality holds.