$x^{2} \frac{d y}{d x}=x^{2}-2 y^{2}+x y$
The given differential equation is:
$x^{2} \frac{d y}{d x}=x^{2}-2 y^{2}+x y$
$\frac{d y}{d x}=\frac{x^{2}-2 y^{2}+x y}{x^{2}}$ ...(1)
Let $F(x, y)=\frac{x^{2}-2 y^{2}+x y}{x^{2}}$
$\therefore F(\lambda x, \lambda y)=\frac{(\lambda x)^{2}-2(\lambda y)^{2}+(\lambda x)(\lambda y)}{(\lambda x)^{2}}=\frac{x^{2}-2 y^{2}+x y}{x^{2}}=\lambda^{0} \cdot F(x, y)$
Therefore, the given differential equation is a homogeneous equation.
To solve it, we make the substitution as:
y = vx
$\Rightarrow \frac{d y}{d x}=v+x \frac{d v}{d x}$
Substituting the values of $y$ and $\frac{d y}{d x}$ in equation (1), we get:
$v+x \frac{d v}{d x}=\frac{x^{2}-2(v x)^{2}+x \cdot(v x)}{x^{2}}$
$\Rightarrow v+x \frac{d v}{d x}=1-2 v^{2}+v$
$\Rightarrow x \frac{d v}{d x}=1-2 v^{2}$
$\Rightarrow \frac{d v}{1-2 v^{2}}=\frac{d x}{x}$
$\Rightarrow \frac{1}{2} \cdot \frac{d v}{\frac{1}{2}-v^{2}}=\frac{d x}{x}$
$\Rightarrow \frac{1}{2} \cdot\left[\frac{d v}{\left(\frac{1}{\sqrt{2}}\right)^{2}-v^{2}}\right]=\frac{d x}{x}$
Integrating both sides, we get:
$\frac{1}{2} \cdot \frac{1}{2 \times \frac{1}{\sqrt{2}}} \log \left|\frac{\frac{1}{\sqrt{2}}+v}{\frac{1}{\sqrt{2}}-v}\right|=\log |x|+\mathrm{C}$
$\Rightarrow \frac{1}{2 \sqrt{2}} \log \left|\frac{\frac{1}{\sqrt{2}}+\frac{y}{x}}{\frac{1}{\sqrt{2}}-\frac{y}{x}}\right|=\log |x|+\mathrm{C}$
$\Rightarrow \frac{1}{2 \sqrt{2}} \log \left|\frac{x+\sqrt{2} y}{x-\sqrt{2} y}\right|=\log |x|+\mathrm{C}$
This is the required solution for the given differential equation.