Find the maximum value of the function $y=\sec x-\tan x\left(0 \leqslant x<\frac{\pi}{2}\right)$.
Solve $y=\sec x-\tan x=\frac{\sec ^{2} x-\tan ^{2} x}{\sec x+\tan x}=\frac{1}{\sec x+\tan x}\left(0 \leqslant x<\frac{\pi}{2}\right)$,
on $\left[0, \frac{\pi}{2}\right]$, $\sec x+\tan x$ is an increasing function and always greater than 0, so $y=\sec x-\tan x$ is a decreasing function. Therefore, the maximum value must be obtained at $x=0$, which is $y_{\text {max }}=1$.