Problem: Solve the following initial value problem
\[
\left( 2x^2 + y \right) \ \mathrm{d} x + \left( x^2 y - x \right) \ \mathrm{d} y = 0, \quad y(1) = 2.
\]
Check the exactness of the equation. If it is exact, find the solution directly, if not find the integrating factor.
The integrating factor can be found using
\[
\mu(x,y) = \exp \left( \int \left( \frac{\frac{\partial M}{\partial y} - \frac{\partial N}{\partial x}}{N} \right) \right).
\]
Solution: The given equation is
\begin{equation}\label{eq:04Apr2025-1}
\left( 2x^2 + y \right) \ \mathrm{d} x + \left( x^2 y - x \right) \ \mathrm{d} y = 0.
\end{equation}
Let
\[
M(x,y) = 2x^2 + y \quad \text{ and } \quad N(x,y) = x^2 y - x.
\]
Note that the equation is not exact as
\[
\frac{\partial M}{\partial y} = 1 \quad \text{ and } \quad \frac{\partial N}{\partial x} = 2xy - 1
\]
are not equal. Thus, we need to find an integrating factor. We have
\begin{align*}
\frac{\partial M}{\partial y} -\frac{\partial N}{\partial x} & = (1 - 2xy + 1) = 2 - 2xy.
\end{align*}
Note that,
\begin{align*}
\mu (x,y) & = \frac{\frac{\partial M}{\partial y} -\frac{\partial N}{\partial x}}{N} = \frac{2 - 2xy}{x^2 y - x} \\[1ex]
& = \frac{2(1 - xy)}{x(xy - 1)} = -\frac{2}{x}.
\end{align*}
Thus, the integrating factor will be
\begin{align*}
e^{-\int \frac{2}{x}\ \mathrm{d} x} & = \frac{1}{x^2}.
\end{align*}
Multiplying the given equation \eqref{eq:04Apr2025-1} by the integrating factor, we get
\[
\frac{1}{x^2} \left( 2x^2 + y \right) \ \mathrm{d} x + \frac{1}{x^2} \left( x^2 y - x \right) \ \mathrm{d} y = 0.
\]
Let the solution be $u(x,y)$. Since the equation is exact, we have
\begin{align*}
\frac{\partial u}{\partial x} = \frac{M}{x^2} \quad \text{ and } \quad \frac{\partial u}{\partial y} = \frac{N}{x^2}.
\end{align*}
Thus, we have
\begin{align*}
\frac{\partial u}{\partial x} = 2x^2 + y \implies u(x,y) & = \int \left( 2 + \frac{y}{x^2} \right) \ \mathrm{d} x + g(y) \\
& = 2x - \frac{y}{x} + g(y).
\end{align*}
Now we also have
\begin{align*}
\frac{\partial u}{\partial y} = y - \frac{1}{x} & \implies - \frac{1}{x} + g'(y) = y - \frac{1}{x} \\
& \implies g'(y) = y \implies g(y) = \frac{y^2}{2}+ c.
\end{align*}
Thus, the solution will be
\begin{align*}
2x - \frac{y}{x} + \frac{y^2}{2} + c = 0.
\end{align*}
We will now use the condition $y(1) = 2$ to find the constant $c$.
\begin{align*}
2 - \frac{2}{1} + \frac{2^2}{2} + c = 0 \implies c = -2.
\end{align*}
Thus, the solution to the given initial value problem is
\[
\textcolor{blue}{
\boxed{
2x - \frac{y}{x} + \frac{y^2}{2} - 2 = 0.
}
}
\]