Example 1. Let $a>0, b>0, 0<x<\pi$, $x \neq \frac{\pi}{2}$. Find the extremum of the function $y=a \operatorname{tg} x+b \operatorname{ctg} x$.
Solve $|y| \geqslant 2 \sqrt{a b}$, when $x=\operatorname{arctg} \sqrt{\frac{b}{a}}$ or $\pi-\operatorname{arctg} \sqrt{\frac{b}{a}}$ the equation holds.
Thus $y_{\max }=-2 \sqrt{a} \bar{b} , y_{\mathrm{m} / \mathrm{a}}=2 \sqrt{ } a b$.