$\left(x^{2}+x y\right) d y=\left(x^{2}+y^{2}\right) d x$
The given differential equation i.e., $\left(x^{2}+x y\right) d y=\left(x^{2}+y^{2}\right) d x$ can be written as:
$\frac{d y}{d x}=\frac{x^{2}+y^{2}}{x^{2}+x y}$ ...(1)
Let $F(x, y)=\frac{x^{2}+y^{2}}{x^{2}+x y}$
Now, $F(\lambda x, \lambda y)=\frac{(\lambda x)^{2}+(\lambda y)^{2}}{(\lambda x)^{2}+(\lambda x)(\lambda y)}=\frac{x^{2}+y^{2}}{x^{2}+x y}=\lambda^{0} \cdot F(x, y)$
This shows that equation (1) is a homogeneous equation.
To solve it, we make the substitution as:
y = vx
Differentiating both sides with respect to x, we get:
$\frac{d y}{d x}=v+x \frac{d v}{d x}$
Substituting the values of $v$ and $\frac{d y}{d x}$ in equation (1), we get:
$v+x \frac{d v}{d x}=\frac{x^{2}+(v x)^{2}}{x^{2}+x(v x)}$
$\Rightarrow v+x \frac{d v}{d x}=\frac{1+v^{2}}{1+v}$
$\Rightarrow x \frac{d v}{d x}=\frac{1+v^{2}}{1+v}-v=\frac{\left(1+v^{2}\right)-v(1+v)}{1+v}$
$\Rightarrow x \frac{d v}{d x}=\frac{1-v}{1+v}$
$\Rightarrow\left(\frac{1+v}{1-v}\right)=d v=\frac{d x}{x}$
$\Rightarrow\left(\frac{2-1+v}{1-v}\right) d v=\frac{d x}{x}$
$\Rightarrow\left(\frac{2}{1-v}-1\right) d v=\frac{d x}{x}$
Integrating both sides, we get:
$-2 \log (1-v)-v=\log x-\log k$
$\Rightarrow v=-2 \log (1-v)-\log x+\log k$
$\Rightarrow v=\log \left[\frac{k}{x(1-v)^{2}}\right]$
$\Rightarrow \frac{y}{x}=\log \left[\frac{k}{x\left(1-\frac{y}{x}\right)^{2}}\right]$
$\Rightarrow \frac{y}{x}=\log \left[\frac{k x}{(x-y)^{2}}\right]$
$\Rightarrow \frac{k x}{(x-y)^{2}}=e^{\frac{y}{x}}$
$\Rightarrow(x-y)^{2}=k x e^{-\frac{y}{x}}$
This is the required solution of the given differential equation.