The given differential equation is
xdxdy+y−x+xycotx=0
⇒xdxdy+y+xycotx=x
⇒xdxdy+(1+xcotx)y=x
Dividing every term by x to make the coefficient of
dxdy unity,
dxdy+x1+xcotxy=1
Linear Differential Equation
Comparing with
dxdy+Py=Q,
we have
P=x1+xcotx,Q=1
Integrating Factor
∫Pdx=∫x1+xcotxdx
=∫(x1+cotx)dx
=logx+logsinx=log(xsinx)
I.F.=e∫Pdx=elog(xsinx)=xsinx
General Solution
y(I.F.)=∫Q(I.F.)dx+c
⇒y(xsinx)=∫xsinxdx+c
Applying Integration by Parts
Let
I=x,II=sinx
∫xsinxdx=x(−cosx)−∫1(−cosx)dx
=−xcosx+∫cosxdx
=−xcosx+sinx
Substituting Back
y(xsinx)=−xcosx+sinx+c
Dividing every term by xsinx,
y=−xsinxxcosx+xsinxsinx+xsinxc
⇒y=−cotx+x1+xsinxc
y=−cotx+x1+xsinxc
which is the required general solution.