Evaluate the following integrals:
$\int(a \tan x+b \cot x)^{2} d x$
Let $\mathrm{I}=\int(\mathrm{a} \tan \mathrm{x}+\mathrm{b} \cot \mathrm{x})^{2} \mathrm{dx}$
We know $(a+b)^{2}=a^{2}+2 a b+b^{2}$
Therefore, we can write the integral as
$\mathrm{I}=\int\left[(\mathrm{a} \tan \mathrm{x})^{2}+2(\mathrm{a} \tan \mathrm{x})(\mathrm{b} \cot \mathrm{x})+(\mathrm{b} \cot \mathrm{x})^{2}\right] \mathrm{dx}$
$\Rightarrow \mathrm{I}=\int\left(\mathrm{a}^{2} \tan ^{2} \mathrm{x}+2 \mathrm{ab} \tan \mathrm{x} \cot \mathrm{x}+\mathrm{b}^{2} \cot ^{2} \mathrm{x}\right) \mathrm{dx}$
$\Rightarrow \mathrm{I}=\int\left(\mathrm{a}^{2} \tan ^{2} \mathrm{x}+2 \mathrm{ab}+\mathrm{b}^{2} \cot ^{2} \mathrm{x}\right) \mathrm{dx}\left[\because \cot \theta=\frac{1}{\tan \theta}\right]$
We have $\sec ^{2} \theta-\tan ^{2} \theta=\operatorname{cosec}^{2} \theta-\cot ^{2} \theta=1$
$\Rightarrow I=\int\left[a^{2}\left(\sec ^{2} x-1\right)+2 a b+b^{2}\left(\operatorname{cosec}^{2} x-1\right)\right] d x$
$\Rightarrow I=\int\left(a^{2} \sec ^{2} x-a^{2}+2 a b+b^{2} \operatorname{cosec}^{2} x-b^{2}\right) d x$
$\Rightarrow I=\int\left(a^{2} \sec ^{2} x+b^{2} \operatorname{cosec}^{2} x-a^{2}+2 a b-b^{2}\right) d x$
$\Rightarrow I=\int\left(a^{2} \sec ^{2} x+b^{2} \operatorname{cosec}^{2} x-\left(a^{2}-2 a b+b^{2}\right)\right) d x$
$\Rightarrow I=\int\left(a^{2} \sec ^{2} x+b^{2} \operatorname{cosec}^{2} x-(a-b)^{2}\right) d x$
$\Rightarrow I=\int a^{2} \sec ^{2} x d x+\int b^{2} \operatorname{cosec}^{2} x d x-\int(a-b)^{2} d x$
$\Rightarrow I=a^{2} \int \sec ^{2} x d x+b^{2} \int \operatorname{cosec}^{2} x d x-(a-b)^{2} \int d x$
Recall $\int \sec ^{2} x d x=\tan x+c$ and $\int d x=x+c$
We also have $\int \operatorname{cosec}^{2} x d x=-\cot x+c$
$\Rightarrow 1=a^{2} \tan x+b^{2}(-\cot x)-(a-b)^{2} \times x+c$
$\therefore I=a^{2} \tan x-b^{2} \cot x-(a-b)^{2} x+c$]
Thus, $\int(a \tan x+b \cot x)^{2} d x=a^{2} \tan x-b^{2} \cot x-(a-b)^{2} x+c$