Given differential equation :
xdydx+y−x+xy cot x=0
dydx+yx−1+y cot x=0
dydx+y(1x+cot x)−1=0
dydx+(1x+cot x)y=1
Given differential equation is of the form
dydx+Py=Q
By comparing both the equations, we get
P=(1x+cot x) and Q=1
The general solution of the given differential equation is
y(I.F)=∫(Q×I.F.)dx+c ....(i)
Firstly, we need to find I.F.
I.F.=e∫pdx
I.F.=e∫⎛⎝1x+cot x⎞⎠dx
I.F.=elog x+log sin x
I.F.=elog(x sin x) (∵log a+log b=log ab)
I.F.=x sin x (∵elog x=x)
Substituting the value of I.F in (i), we get
y.x sin x=∫1.x sin x dx+c
Using Integration by parts :
∫f(x)g(x)dx=f(x)∫g(x)dx−f[f′(x)∫g(x)dx]dx
Taking f(x)=x and g(x)=sin x
y x sin x=x∫sin x dx−∫[1.∫sin x.dx]dx+c
y x sin x=x(−cos x)−∫1.(−cos x)dx+c
y x sin x=−x cos x+∫cos x dx+c
y x sin x=−x cos x+sin x+c
y=−x cos xx sin x+sin xx sin x+cx sin x
y=−cot x+1x+cx sin x
Hence, the required general solution is
y=−cot x+1x+cx sin x
∴y=(1+x2)−1log |sin x|+c(1+x2)−1