# First order differential equations

## Exact (total) DE

We are going to deal with such types of differential equations which can be seen as a product of exact (total) differential. For example let us have a function

\begin{align} f(x,y) &= \color{red}{3x^2 + 4xy + y}, \hskip2em \text{then} \nonumber \\ df &= \frac{\partial}{\partial x}f(x,y)\ dx + \frac{\partial}{\partial y}f(x,y)\ dy = \nonumber \\ &= (6x + 4y)\ dx + (4x+1)\ dy \nonumber \end{align}

is called total differential of $f(x,y)$ and such observation helps us to solve differential equation

$$\begin{equation} (6x + 4y)\ dx + (4x+1)\ dy = 0. \label{ref:exact1} \end{equation}$$

The first thought to solve $(\ref{ref:exact1})$ is to go back against differentiation, i.e. to integrate both members. But the case is not the simple, since some members repeat:

\begin{align} \int {(6x + 4y)\ dx} &= 3x^2 + \color{red}{4xy} \hskip2em \text{and} \nonumber \\ \int{(4x+1)\ dy} &= \color{red}{4xy} + y. \nonumber \end{align}

So, that was an ilustrative example to outline the kind of DE we are dealing with within this chapter. Now let us talk more in general. We are going to solve DE in standard form of

$$\color{red}{M(x,y) \ dx + N(x,y)\ dy =0}, \hskip2em \text{where} \nonumber \\ M(x,y) = \frac{\partial}{\partial x}f(x,y) \hskip1em \text{and} \hskip1em N(x,y) = \frac{\partial}{\partial y}f(x,y).$$

If the members ${M(x,y) \ dx + N(x,y)\ dy}$ are results of total differential, we can solve DE by finding ${f(x,y)}$ from which members ${M(x,y),\ N(x,y)}$ were derived.

Before we can go after the solution, we have to test whether $\boldsymbol{M(x,y),\ N(x,y)}$ are really products of total differential of ${f(x,y)}$. If the equality

$$\frac{\partial}{\partial y}M(x,y) = \frac{\partial}{\partial x}N(x,y)$$

holds then the differential equation is exact and can be solved as an exact differential equation.

The next step is to find the solution itself. If we integrate $M(x,y)$ and $N(x,y)$ we can reconstruct $f(x,y)$. But as was shown, some members can come twice: once from $\int{M(x,y)\ dx}$, second from $\int{N(x,y)\ dy}$. To solve these troubles, let us integrate $M(x,y)$ first and let it equal to $f(x,y)$, which is what we are looking for:

$$\begin{equation} \color{red}{f(x,y) = \int{M(x,y)\ dx + g(y)} } \label{ref:exact2} \end{equation}$$

We are near the result $f(x,y)$, but we have to evaluate also $g(y)$ which is a constant coming as a product of integration. It comes from definition that if we differentiate $f(x,y)$ with respect to $y$, we obtain $N(x,y)$:

$$N(x,y) = \frac{\partial f(x,y)}{\partial y} = \frac{\partial}{\partial y}\int M(x,y)\ dx + g'(y)$$

Since $N(x,y)$ is given by differential equation and $\frac{\partial}{\partial y}\int M(x,y)\ dx$ is quite easy to evaluate, we can express wanted $g(y)$ as

$$\begin{equation} \color{red}{g'(y) = N(x,y) - \frac{\partial}{\partial y} \int {M(x,y)\ dx}} \label{ref:exact3} \end{equation}$$

The task remains to integrate $g'(y)$ obtained from $(\ref{ref:exact3})$ and substitute $g(y)$ to $(\ref{ref:exact2})$. Then the solution sums $\int M(x,y)\ dx$ (in $(\ref{ref:exact2})$) and $\int N(x,y)\ dy$ (from $(\ref{ref:exact3})$) as was anticipated from the beginning. And since some members would appear twice, we have to evaluate and subtract them: these come from $\int {M(x,y)\ dx}$ differentiated with respect to $y$ in $(\ref{ref:exact3})$.

Note: above is the formal solution. The intuitive solution is just to integrate both $\boldsymbol{M(x,y)}$ and $\boldsymbol{N(x,y)}$ and involve repeating members only once.

### Example

Solve $2xy-9x^2 + (2y x^2+1)dy/dx$ = 0.

First let us bring equation into standard form in order to locate $\color{red}{M(x,y)},\ \color{blue}{N(x,y)}$.

$$\color{red}{(2xy -9x^2)}\ dx + \color{blue}{(2y+x^2+1)}\ dy = 0$$

Test, whether it is exact DE:

$$\frac{\partial M}{\partial y} = \frac{\partial}{\partial y}(2xy -9x^2) = 2x,\hskip2em \frac{\partial N}{ \partial x} = \frac{\partial }{ \partial x}(2y+x^2+1)= 2x.$$

The test has confirmed we can solve as an exact DE.

\begin{align} \int {M(x,y)\ dx} &= \int {(2xy-9x^2)\ dx} = x^2y - 3x^3 + g(y) \nonumber \\ g'(y) &= N(x,y) - \frac{\partial}{\partial y} \int{M(x,y)\ dx} = (2y+x^2+1) - \frac{\partial}{\partial y}(x^2 y - 3x^3) = 2y+1 \nonumber \\ g(y) &= y^2+ y \nonumber \\ \end{align}

Then the solution is

$$\underline{\underline{f(x,y) = (x^2y-3x^3) +(y^2 + y) = C }}.$$

Alternative solution by intuition:

\begin{align} \int M(x,y)\ dx &= \int (2xy - 9x^2)\ dx = \color{red}{x^2y} -3x^3 + C_1\nonumber \\ \int N(x,y)\ dy &= \int (2y+x^2+1)\ dy = y^2 + \color{red}{x^2y} + y + C_2 \nonumber \end{align}

The product $x^2y$ comes twice from both $\int M\ dx$ and $\int N\ dy$. We locate such members and include them to solution only once:

$$\underline{\underline{f(x,y) = x^2y-3x^3 +y^2 + y = C }}.$$

### Example

Solve $2xy^2 + 4 = 2(3-x^2y)y',\ y(-1) = 8$.

First let us bring equation into standard form in order to locate $\color{red}{M(x,y)},\ \color{blue}{N(x,y)}$.

\begin{align} 2xy^2 + 4 &= 2(3-x^2y) \frac{dy}{dx} \nonumber \\ \color{red}{(2xy^2 +4)}\ dx + \color{blue}{2(x^2y-3)}\ dy &= 0 \nonumber \\ \end{align}

First test whether it is exact DE:

$$\frac{\partial M}{\partial y} = 4xy,\hskip2em \frac{\partial N}{\partial x} = 4xy.$$

Now we can solve as exact DE.

\begin{align} \int M(x,y)\ dx &= \color{red}{x^2y^2} + 4x + C_1\nonumber \\ \int N(x,y)\ dy &= -6y+\color{red}{x^2y^2} + C_2\nonumber \end{align}

DE has the solution

$$x^2y^2 + 4x-6y = C.$$

Initial values $y(-1) = 8$:

$$(-1)^2\cdot 8^2 + 4(-1) -6\cdot 8 = C \implies C = 12$$

Particular solution is then

$$\underline{\underline{x^2y^2+4x-6y = 12}}.$$

### Example

Solve $\frac{2ty}{t^2+1} -2t -(2-\log(t^2+1))\frac{dy}{dt} = 0,\ y(5) = 0$.

First let us bring equation into standard form in order to locate $\color{red}{M(t,y)},\ \color{blue}{N(t,y)}$.

\begin{align} \frac{2ty}{t^2+1}dt -2t\ dt -(2-\log(t^2+1))\ {dy} = 0 \nonumber \\ dt\ \color{red}{\big(\frac{2ty}{t^2 + 1} - 2t\big)} + dy\ \color{blue}{(\log(t^2+1)-2)} = 0 \nonumber \end{align}

The test for exactness says that

$$\frac{\partial M}{ \partial y} = \frac{\partial{N}}{\partial t} = \frac{2t}{t^2 +1}.$$

The DE is exact so we can continue with integrating.

\begin{align} \int M(t,y) \ dt &= \int \big(\frac{2ty}{t^2 +1} - 2t\big)\ dt = 2 \int \big(y\frac{t}{t^2 + 1} -t\big)\ dt = \nonumber \\ & = \color{red}{y\log(t^2+1)} - t^2 + h(y) \nonumber \\ \int N(t,y) \ dy &= \int (\log(t^2+1) -2)\ dy = \color{red}{y\log(t^2+1)} - 2y +g(t) \\ \end{align}

The implicit solution is

$$f(t,y) = y\log(t^2+1) -t^2-2y=c.$$

For initial value of $t=5,\ y=0 \implies c=25$.

$$\underline{\underline{y\log(t^2+1)-t^2-2y=-25}}$$

is particular solution for $y(5)=0$.

### Example

Solve $(x-2xy+e^y)\ dx + (y-x^2+xe^y)\ dy = 0$.

The test for exactness says that

$$\frac{\partial M(x,y)}{ \partial y} = \frac{\partial{N(x,y)}}{\partial x} = -2x+e^y.$$

We can solve as an exact DE:

\begin{align} \int M(x,y)\ dx &= \frac{x^2}{2}-x^2y+xe^y + g(y) \nonumber \\ g'(y) &= N(x,y) - \frac{\partial}{\partial y}\int M(x,y)\ dx = (y \color{silver}{ - x^2 + xe^y}) \color{silver}{-(-x^2+xe^y)} = y\nonumber \\ g(y) &= \frac 1 2 y^2 \nonumber\\ \end{align}

The general solution is

$$\underline{\underline{f(x,y) = \frac{x^2}{2} - x^2y + xe^y + \frac{y^2}{2}+ C}}.$$

### Example

Solve $\cos y\ dx - (x\sin y - y^2)\ dy = 0$.

The test for exactness says that

$$\frac{\partial M(x,y)}{ \partial y} = \frac{\partial{N(x,y)}}{\partial x} = -\sin y.$$

We can solve as an exact DE:

\begin{align} \int M(x,y)\ dx &= \int \cos y \ dx = \cos y\cdot x + g(y) \nonumber \\ g'(y) &= N(x,y) - \frac{\partial}{\partial y}\int M(x,y)\ dx = -x\sin y +y^2 - (-\sin y\cdot x) = y^2 \nonumber \\ g(y) &= \frac{1}{3}y^3 \nonumber \end{align}

The general solution is

$$\underline{\underline{\cos y\cdot x +\frac{1}{3}y^3 = c}}.$$

### Example

Solve $(4x^3 - \sin x + y^3)\ dx - (y^2+1-3xy^2)\ dy = 0$.

The test for exactness says that

$$\frac{\partial M(x,y)}{ \partial y} = \frac{\partial{N(x,y)}}{\partial x} = 3y^2.$$

We can solve as an exact DE:

\begin{align} \int M(x,y)\ dx &= \int (4x^3 - \sin x + y^3)\ dx = x^4 + \cos x + \color{red}{xy^3 } \nonumber \\ \int N(x,y)\ dy &= -\int (y^2+1-3xy^2)\ dy = -\frac 1 3y^3 - y + \color{red}{xy^3} \nonumber \end{align}

The general solution is

$$\underline{\underline{0 = x^4+\cos x -\frac{1}{3}y^3 - y + xy^3 + c}}.$$

List of chapters