Example 6 The range of the function $y=x+\sqrt{x^{2}}-3x+2$ is $\qquad$
(2001, National High School Mathematics Competition)
Analysis: From $x^{2}-3 x+2 \geqslant 0$, we get $x \leqslant 1$ or $x \geqslant 2$. Also, $x^{2}-3 x+2=\left(x-\frac{3}{2}\right)^{2}-\frac{1}{4}$. Let $x-\frac{3}{2}=\frac{1}{2} \sec \theta, \theta \in\left[0, \frac{\pi}{2}\right) \cup\left(\frac{\pi}{2}, \pi\right]$, then $y=\frac{3}{2}+\frac{1}{2} \sec \theta+\frac{1}{2}|\tan \theta|$.
When $\theta \in\left[0, \frac{\pi}{2}\right)$,
$y=\frac{3}{2}+\frac{1}{2} \sec \theta+\frac{1}{2} \tan \theta$
$=\frac{3}{2}+\frac{1}{2} \cdot \frac{1+\sin \theta}{\cos \theta}=\frac{3}{2}+\frac{1}{2} \cdot \frac{1-\cos \left(\frac{\pi}{2}+\theta\right)}{\sin \left(\frac{\pi}{2}+\theta\right)}$
$=\frac{3}{2}+\frac{1}{2} \tan \left(\frac{\theta}{2}+\frac{\pi}{4}\right)$.
Also, $\frac{\pi}{4} \leqslant \frac{\theta}{2}+\frac{\pi}{4}<\frac{\pi}{2}$, then
$\tan \left(\frac{\theta}{2}+\frac{\pi}{4}\right) \geqslant 1, y \geqslant 2$.
Similarly, when $\theta \in\left(\frac{\pi}{2}, \pi\right]$, $1 \leqslant y<\frac{3}{2}$.
Therefore, the range of the function is $\left[1, \frac{3}{2}\right) \cup[2,+\infty)$.
Note: For expressions of the form $\sqrt{x^{2}-a^{2}}(|x| \geqslant a)$, the variable $x$ can be replaced using secant (or cosecant) substitution.