We have dxdy+xcoty=2y+y2coty, (y≠0)
It is clear that this ia linear differential equation of the form dxdy+P(y)x=Q(y)
Here, P(y)=coty,Q(y)=2y+y2coty
Integrating factor = e∫cotydy=elogsiny=siny
So, solution is given by, xsiny=∫siny(2y+y2coty)dy
xsiny=∫2ysinydy+∫y2cosydy
xsiny=∫2ysinydy+y2∫cosydy−∫(d(y2)dy∫cosydy)dy
xsiny=∫2ysinydy+y2siny−∫2ysinydy
xsiny=y2siny+C
Given that x = 0, when y=π2, we get 0sinπ2=(π2)2sinπ2+c
Therefore, c=−π24
So, the required solution is: xsiny=y2siny−π24