 ## Exact first order Ordinary Differential Equation

Solve the following ODE: $$x\frac{\mathrm d y}{\mathrm d x} + 5x + y = 0$$
The above equation can be written as $$(5x+y)\ \mathrm d x + x\ \mathrm d y = 0 \tag{1}$$ Equation $$(1)$$ is in the form of $$A(x,y)\ \mathrm d x + B(x,y)\ \mathrm d y = 0 \tag{2}$$ where \begin{align} \\& A(x,y) = 5x + y \\& \\& B(x,y) = x \end{align}
Let us say $$U(x,y) = c \$$ is the solution the equation $$(2), \ c$$ is a constant.
So \begin{align} \\& \mathrm d U = 0 \\& \Rightarrow \frac{\partial U}{\partial x}\ \mathrm d x + \frac{\partial U}{\partial y}\ \mathrm d y = 0 \tag{3} \end{align} Comparing equation $$(2)$$ and equation $$(3)$$ we get \begin{align} \\& A(x,y) = \frac{\partial U}{\partial x} \tag{4} \\& \\& B(x,y) = \frac{\partial U}{\partial y} \tag{5} \end{align} Since $$\frac{\partial^2 U}{\partial x \partial y} = \frac{\partial^2 U}{\partial y \partial x}$$ we therefore require $$\boxed{ \frac{\partial A}{\partial y} = \frac{\partial B}{\partial x} }$$ Which is the required condition for equation $$(2)$$ to be an exact equation.
Now \begin{align} \\& A(x,y) = 5x + y \\& \Rightarrow \frac{\partial A}{\partial y} = 1 \\& \\& B(x,y) = x \\& \Rightarrow \frac{\partial B}{\partial x} = 1 \end{align}
Which satisfies the required condition so equation $$(1)$$ is an exact equation. Now from equation $$(4)$$: \begin{align} \\& \frac{\partial U}{\partial x} = A(x,y) = 5x+y \\& \Rightarrow U(x,y) = \frac{5x^2}{2} + yx + \phi(y) \tag{6} \end{align} Here $$\phi(y)$$ is a function of $$y$$ only. Remember $$U(x,y)$$ is a function of $$x$$ and $$y$$. So we cannot put an ordinary constant there. That is why a function $$\phi(y)$$. If you take the partial derivative of the equation (6) with respect to $$x$$ you will get the previous expression back.
Now take the partial derivative of equation (6) with respect to $$y$$ and equate with the equation (5): \begin{align} \\& U(x,y) = \frac{5x^2}{2} + yx + \phi(y) \\& \Rightarrow \frac{\partial U}{\partial y} = B(x,y) = 0 + x + \frac{\mathrm d \phi}{\mathrm d y} \tag{7} \\& \Rightarrow x+\frac{\mathrm d \phi}{\mathrm d y} = x \\& \Rightarrow \frac{\mathrm d \phi}{\mathrm d y} = 0 \\& \Rightarrow \phi(y) = k \end{align} $$k$$ is a constant. So the complete solution of the equation (1) is \begin{align} \\& U(x,y) = c \\& \Rightarrow \frac{5x^2}{2} + yx + \phi(y) = c \\& \Rightarrow \frac{5x^2}{2} + yx + k = c \\& \Rightarrow \frac{5x^2}{2} + yx = c - k =c_1 \\& \\& \boxed{ \frac{5x^2}{2} + yx = c_1 } \end{align} $$c_1$$ is a constant.