We have,
xdydx+y−x+xycotx=0
Dividing both side by x and we get,
dydx+yx−1+ycotx=0
dydx+y(1x+cotx)−1=0
dydx+(1x+cotx)y=1
Comparing that,
dydx+Py=Q
Then,
P=1x+cotx and Q=1
Now,
I.F.=e∫Pdx
=e∫⎛⎝1x+cotx⎞⎠dx
=e∫1xdx+∫cotxdx
=elogx+logsinx
=elogxsinx
=xsinx(∴elogx=x)
Then solution is.
y×I.F.=∫Q×I.F.dx+C
y(xsinx)=∫xsinxdx+C
=x∫sinxdx−∫[1.∫sinxdx]dx+C
=x(−cosx)+∫(cosx)dx+C
y×I.F.=−xcosx+sinx+C
Put the value of y
Then,
y.xsinx=−xcosx+sinx+C
y=−xcosxxsinx+sinxxsinx+Cxsinx
y=−cotx+1x+C1
WhereC1=Cxsinx
Hence, this is the solution.