$\left(1+x^{2}\right) d y+2 x y d x=\cot x d x(x \neq 0)$
$\left(1+x^{2}\right) d y+2 x y d x=\cot x d x$
$\Rightarrow \frac{d y}{d x}+\frac{2 x y}{1+x^{2}}=\frac{\cot x}{1+x^{2}}$
This equation is a linear differential equation of the form:
$\frac{d y}{d x}+p y=Q\left(\right.$ where $p=\frac{2 x}{1+x^{2}}$ and $\left.Q=\frac{\cot x}{1+x^{2}}\right)$
Now, I.F $=e^{\int p d x}=e^{\int \frac{2 x}{1+x^{2}} d x}=e^{\log \left(1+x^{2}\right)}=1+x^{2}$
The general solution of the given differential equation is given by the relation,
$y(\mathrm{I} . \mathrm{F} .)=\int(\mathrm{Q} \times \mathrm{I} . \mathrm{F} .) d x+\mathrm{C}$
$\Rightarrow y\left(1+x^{2}\right)=\int\left[\frac{\cot x}{1+x^{2}} \times\left(1+x^{2}\right)\right] d x+\mathrm{C}$
$\Rightarrow y\left(1+x^{2}\right)=\int \cot x d x+\mathrm{C}$
$\Rightarrow y\left(1+x^{2}\right)=\log |\sin x|+\mathrm{C}$