Example 19 Find the range of real number $a$ such that for any real number $x$ and any $\theta \in\left[0, \frac{\pi}{2}\right]$, the following inequality always holds: $(x+3+2 \sin \theta \cos \theta)^{2}+(x+a \sin \theta+a \cos \theta)^{2} \geqslant \frac{1}{8}$.
Let $t=\sin \alpha+\cos \alpha$, then $t \in[1, \sqrt{2}]$, the original inequality becomes
$$
\left(x+2+t^{2}\right)^{2}+(x+a t)^{2} \geqslant \frac{1}{8} .
$$

According to the problem, $2 x^{2}+2\left(2+t^{2}+a t\right) x+\left(2+t^{2}\right)^{2}+$ $(a t)^{2}-\frac{1}{8} \geqslant 0$, for any $x \in \mathbf{R}$.
$$
\therefore \Delta=4\left(2+t^{2}+a t\right)^{2}-8\left(2+t^{2}\right)^{2}-8(a t)^{2}
$$
$+1 \leqslant 0$ for any $t \in[1, \sqrt{2}]$.
Simplifying, we get $4\left(2+t^{2}-a t\right)^{2}-1 \geqslant 0$ for any $t \in[1, \sqrt{2}]$.
$\therefore t^{2}-a t+\frac{3}{2} \geqslant 0$ or $t^{2}-a t+\frac{5}{2} \leqslant 0$ for any $t \in[1, \sqrt{2}]$.
Solving, we get $a \leqslant t+\frac{3}{2 t}$
(1) or $a \geqslant t+\frac{5}{2 t}$
(2) for any $t \in[1, \sqrt{2}]$.

For (1) $\because t+\frac{3}{2 t} \geqslant 2 \sqrt{t \cdot \frac{3}{2 t}}=\sqrt{6}$, with equality if and only if $t=\frac{3}{2 t}$, i.e., $t=\frac{\sqrt{6}}{2}$.
$$
\therefore a \leqslant\left(t+\frac{3}{2 t}\right)_{\text {min }}=\sqrt{6} \text {. }
$$

For (2) it is easy to prove that $y=t+\frac{5}{2 t}$ is monotonically decreasing on $t \in[1, \sqrt{2}]$, $\therefore t=1$ when, $y_{\text {max }}=\frac{7}{2}$,
$$
\therefore a \geqslant\left(t+\frac{5}{2 t}\right)_{\max }=\frac{7}{2} \text {. }
$$
$\therefore a$'s range of values is $a \leqslant \sqrt{6}$ or $\geqslant \frac{7}{2}$.