Answer
$y=\frac{1}{2}\ln (2-\sin x)$
Work Step by Step
We are given:
$$(ye^{xy}+cos x) dx+xe^{xy}dy=0(1)$$
Here,
$M(x,y)=\frac{\partial}{\partial y}(ye^{xy}+\cos x)=e^{xy}+xye^{xy}$
$N(x,y)=\frac{\partial}{\partial x}(xe^{xy})=e^{xy}+xye^{xy}$
$M_y=e^{xy}+xye^{xy} \;\;\;\;,\;\;\;\;N_x=e^{xy}+xye^{xy}$
$M_y=N_x$
$\Rightarrow$ (1) is exact differential equation
Therefore there exists a potential function $\phi$ such that
$\frac{\partial\phi}{\partial x}=(ye^{xy}+\cos x)$ ___(2)
Integrating (2) with respect to $x$ holding $y$ fixed
$\phi =e^{xy}+\sin x+f(y)$ ___(3)
Where $f(y)$ is arbitrary function of $y$
Hence we get:
$\frac{\partial\phi}{\partial y}=xe^{xy}+f'(y)=xe^{xy}$ (4)
We have
$f'(y)=0\rightarrow f(y)=C$
$C$ is constant
The solution is:
$\phi(x,y)= e^{xy}+\sin x+C$
Since $y(\frac{pi}{2})=0$
so:
$0=e^0+\sin (\frac{pi}{2})+C$
$C=2$
We have:
$e^{xy}+\sin x=2 \rightarrow e^{xy}=2-\sin x$
The solution is:
$y=\frac{1}{2}\ln (2-\sin x)$