Example 20 Given that $a, b$ are unequal positive numbers, find the range of the function $f(x)=\sqrt{a \cos ^{2} x+b \sin ^{2} x}+$ $\sqrt{a \sin ^{2} x+b \cos ^{2} x}$.
Given that $\left(\sqrt{a \cos ^{2} x+b \sin ^{2} x}\right)^{2}+\left(\sqrt{a \sin ^{2} x+b \cos ^{2} x}\right)^{2} = (\sqrt{a+b})^{2}$, we can construct a circle with diameter $AC = \sqrt{a+b}$, and take $AB = \sqrt{a \cos ^{2} x+b \sin ^{2} x}$, $BC = \sqrt{a \sin ^{2} x+b \cos ^{2} x}$. As shown in Figure 3-24, take the midpoint $D$ on the other half of the circle, then $CD = AD = \sqrt{\frac{a+b}{2}}$. Applying Ptolemy's theorem to quadrilateral $ABCD$, we have
$$
f(x) = \sqrt{\frac{2}{a+b}}(AB \cdot CD + BC \cdot AD) = \sqrt{\frac{2}{a+b}} \cdot AC \cdot BD = \sqrt{2} BD.
$$

Assume $a > b$, then $\sqrt{b} \leq \sqrt{a \cos ^{2} x+b \sin ^{2} x} = \sqrt{(a-b) \cos ^{2} x+b} \leq \sqrt{a}$, i.e., $\sqrt{b} \leq AB \leq \sqrt{a}$. And $\sqrt{b} < \sqrt{\frac{a+b}{2}} < \sqrt{a}$, thus
when $AB = CD = \sqrt{\frac{a+b}{2}}$, $f(x)_{\text{max}} = \sqrt{2(a+b)}$.
When $\sqrt{b} \leq AB \leq \sqrt{\frac{a+b}{2}}$, $f(x)$ is a monotonically increasing function of $AB$,
$$
f(x)_{\text{min}} = \sqrt{\frac{2}{a+b}}\left(\sqrt{b} \cdot \sqrt{\frac{a+b}{2}} + \sqrt{a} \cdot \sqrt{\frac{a+b}{2}}\right) = \sqrt{a} + \sqrt{b}.
$$

When $\sqrt{\frac{a+b}{2}} \leq AB \leq \sqrt{a}$, $f(x)$ is a monotonically decreasing function of $AB$, thus when $AB = \sqrt{a}$, $BC = \sqrt{b}$, $f(x)_{\min} = \sqrt{\frac{2}{a+b}}\left(\sqrt{a} \cdot \sqrt{\frac{a+b}{2}} + \sqrt{b} \cdot \sqrt{\frac{a+b}{2}}\right) = \sqrt{a} + \sqrt{b}$.

Therefore, in the domain of $f(x)$, $f(x)_{\min} = \sqrt{a} + \sqrt{b}$, so the range of $f(x)$ is $[\sqrt{a} + \sqrt{b}, \sqrt{2(a+b)}]$.

Note: For a general function $f(x) = a \cdot A(x) + b \cdot B(x)$, as long as $A^2(x) + B^2(x) = \text{constant}$, a cyclic quadrilateral can be constructed, and Ptolemy's theorem can be flexibly applied to find its extremum or range.