First order differential equations

DE solved by separating variables

We recognize many types of differential equation. Such recognizing is the key for solving, because then we can apply the proper method, which is able to bring the solution of DE.

We know already how to solve simple DE in the form

$$ \frac{dy}{dx} = g(x). $$

Just integrating both sides gives us the solution:

$$ \begin{align} dy &= g(x)\ dx, \label{ref:separ1} \\ y &= \int g(x)\ dx, \nonumber \\ y &= G(x)+c, \nonumber \end{align} $$

where $G(x)$ is an antiderivative of $g(x)$. Now what if in $(\ref{ref:separ1})$ is on the left side not only $dy$, but a function depending on $y$? The solution would be that simple as well. Just to integrate both left and right side.

That means if we can separate members depending on $\boldsymbol x$ together with $\boldsymbol{dx}$ and at the same time do the same for $\boldsymbol y$, then it is easy to solve DE by integrating both sides. So

$$ \begin{equation} \color{red}{\frac{dy}{dx} = g(x)\ h(y)} \end{equation} $$

would be the general form of DE, which can be solved by separating variables. For example

$y' = xy$$y' = xy \color{red}{+ \sin(x+y)}$
$y' = x/y$$y' = x/y \color{red}{+ \log(x+y)}$
are separableare not separable

Solution without solution (curves, direction field)

In many practical problems a rough geometrical approximation to a solution might be all that is needed. Sometimes we may even be not able to solve the DE symbolically.

We can construct a direction field: a rectangular area with grid points and compute/draw tangent $dy/dx$ for each grid point. See the graphs within this chapter, e.g. the last example for illustration.

Producing direction field by hand might be time consuming. It is handy if one can find so called isoclines, i.e. lines which have the same value of the slope.


Solve DE $x\ dy -y\ dx = 0$. Find particular solution for $y(2)=4$.

There is not much effort needed to reshuffle DE into

$$ \frac 1 y dy - \frac 1 x dx = 0 $$

The variables $x$ are separated from $y$. It is simple task to integrate both sides now.

$$ \begin{align} \log |y| &= \log |x| + c \nonumber \\ y &= e^{\log |x| + c} \nonumber \\ y &= e^{\log|x|} \cdot e^c \nonumber \\ y &= xC \nonumber \end{align} $$

To find the particular solution we have to substitute initial value $y(x=2) = 4$ into solution. Then value $C=2$ is found.

$$ \underline{\underline{y = 2x}} $$
Direction field and the particular solution for given DE. Direction fields are small tangents $(dy/dx)$ evaluated and drawn for grids within the network of grids. These small blue arrows provide idea about all solutions. Also one (particular) solution $y=2x$ is drawn. Note that the solution follows direction field.


Solve DE $yx^2dy -y^3dx = 2x^2dy$.

The DE is somehow more complicated than the previous one. We have to put some effort into separating variables. If we succeed to separate variables, then after integrating we have the solution.

Let us divide by $x^2y^3$ and see what happens

$$ \frac 1 {y^2}dy - \frac{1}{x^2}dx = 2\frac{1}{y^3}dy $$

We separated the variables quite easily. Now all members can be integrated.

$$ \begin{align} -x^{-2}dx &= (2y^{-3}-y^{-2})\ dy \nonumber \\ x^{-1} &= -y^{-2}+y^{-1} + C \nonumber \\ \frac 1 x &= -\frac 1 {y^2} + \frac 1 y + C \hskip2em x\neq 0,\ y\neq 0 \nonumber \\ y^{2} &= -x + xy+xy^2C\nonumber \end{align} $$

We can use quadratic formula or leave the solution in implicit form.

$$ \underline{\underline{ y^2(1-xC) = x(y-1)}} $$

Note: we have lost a solution. The above family of solutions is not the general solution.

During the operations we ruled out $y=0$. If we substitute $y=0$ (and $dy=0$, since $y$ is constant) into given DE, then it is quite clear that the equality holds for any $x$. Thus $y=0$ is also a solution.

$$ \underline{\underline{y=0}} \hskip2em \text{(singular solution)} $$


Solve DE $y' = e^{\sqrt x}/y$ for initial value $y(1) = 4$.

$$ y\ dy = \color{red}{e^{\sqrt x} dx} $$

When the variables are separated, the left side is easy to integrate, but the right side is more complicated.

We have to solve $\color{red}{\int e^{\sqrt x} dx}$. It contains internal function so we have to use the chain rule backwards. First let us differentiate $e^{\sqrt x}$ and then integrate the product by integration by parts (the product rule backwards): $$ (e^{\sqrt{x}})' = \frac 1 2 e^{\sqrt{x}}x^{-1/2} $$

Now to integrate $1/2\ e^{\sqrt{x}}x^{-1/2}$ we use integration by parts. From $(uv)' = uv' + u'v \implies uv' = (uv)' - u'v$ we have $\color{blue}{\int uv' = uv - \int u'v}$. One member is easy to differentiate ($e^{\sqrt{x}}$) and the second one is easy to integrate ($1/2\ x^{-1/2}$).

$$ \begin{align} e^{\sqrt{x}} &= \int \frac 1 2 e^{\sqrt{x}}x^{-1/2}\ dx = \nonumber \\ &= \int uv'\ dx = \begin{vmatrix} u = e^{\sqrt{x}} & \implies & u' = \frac 1 2 e^{\sqrt{x}}x^{- 1/2} \\ v' = \frac 1 2 x^{- 1/2} & \implies & v = x^{ 1/2 } \end{vmatrix} = \nonumber \\ &= e^{\sqrt{x}} x^{1/2} -\frac 1 2 \int e^{\sqrt x}dx \nonumber\\ \frac 1 2 \int e^{\sqrt x}dx &= e^{\sqrt{x}} x^{1/2} - e^{\sqrt{x}}\nonumber\\ \color{red}{\int e^{\sqrt x}dx} &= 2e^{\sqrt{x}} x^{1/2} - 2e^{\sqrt{x}}\nonumber \end{align} $$

Now we have figured out how to integrate both left and right side, so we can integrate, therefore complete the solution of DE:

$$ \begin{align} \frac 1 2 y^2 = 2e^{\sqrt{x}} x^{1/2} - 2e^{\sqrt{x}} + c. \nonumber \\ y = 2\sqrt{e^{\sqrt{x}} \sqrt x - e^{\sqrt{x}} + C}. \nonumber \end{align} $$

If the initial value $y(x=1) = 4$ is substituted into the general solution, the value of constant is determined as $C = 4$. The particular solution is then

$$ \underline{\underline{y = 2\sqrt{e^{\sqrt{x}} \sqrt{x} - e^{\sqrt{x}} + 4}}}. $$


Solve DE $y' +y = 0$ for initial value $y(1) = 1$.

$$ \begin{align} \frac 1 y dy + dx &= 0 \nonumber\\ \log|y|+x &= c \nonumber\\ \log|y| &= c-x \nonumber\\ y &= e^{c-x} \nonumber \end{align} $$

Substituting initial value $y(x=1) =1$ into solution gives $c=1$

$$ \underline{\underline{y=e^{1-x}}} $$


Solve DE $\sin x \cos 2y\ dx + \cos x \sin 2y\ dy = 0$ for initial value $y(0) = \pi/2$.

$$ \begin{align} \frac{\sin x}{\cos x}\ dx + \frac{\sin 2y}{\cos 2y}\ dy &= 0 \nonumber \\ \tan x\ dx + \tan 2y\ dy &= 0 \nonumber \\ -\log|\cos x|-\frac 1 2 \log|\cos 2y| &= C \nonumber \\ \log|\cos x|+\frac 1 2 \log|\cos 2y| &= D \nonumber \\ \log \sqrt{|\cos 2y|} &= D - \log|\cos x| \nonumber \\ \sqrt {|\cos 2y|} &= e^{D - \log|\cos x|} \nonumber \\ \sqrt {|\cos 2y|} &= \frac{e^D}{\cos x} \nonumber \\ \cos 2y \cdot \cos^2x &= E \nonumber \\ \end{align} $$

If we use initial value within the solution we get $E=-1$, so the particular solution is

$$ \underline{\underline{\cos 2y \cdot \cos^2x = -1}} \\ $$


Solve DE $dr/d \theta = -\sin \theta$.

$$ dr = -\sin \theta\ d \theta $$

After integrating both sides:

$$ \underline{\underline{r = \cos \theta + C}} $$


Solve DE $dr/ d \theta \cot \theta - r = 2$. (Note that $\cot \theta = \cos \theta / \sin \theta$)

$$ \begin{align} \frac {1}{2+r} dr &= \tan \theta \ d \theta \nonumber \\ \log |2+r| &= \log |\sec \theta| + C \nonumber \\ e^{\log|2+r|} &= e^{\log|\sec \theta |} + C \nonumber \\ \end{align} $$

Note: function $\sec \theta = 1/\cos \theta = \text{hypotenuse}/\text{adjacent}$.

Assuming $\theta \neq \dots,\ \pi/2,\ 3\pi/2,\ \dots$ and $r\neq -2$, the general solution is

$$ \begin{equation} \underline{\underline{2+r = D\sec \theta}} \label{ref:first_order_sol1} \end{equation} $$

A numerical check of solution for correctness

Now we have reached a solution but when solving DE, esp. difficult ones, it is quite possible we could make a mistake. For that reason, we might be interested whether there is a method to check the solution for the correctness.

Well, there is a simple numerical way of checking by using a calculator. Let us choose the constant $D$ of any value, e. g. $D=2$ and take any value for $\theta$, e.g. $\theta=1$ and evaluate $r$ from the solution. Then let us choose any small $d \theta$, e.g. $d \theta = 0.001$.

So, from solution, we have

  • $D=2,\ \theta = 1 \implies r = 1.7016314$
  • $D=2,\ \theta = (1+d\theta) \implies r = 1.7074072 \implies dr = 0.0057758$

We got two points (from the solution), which are close to each other. Not only we can draw the graph of solution, but we can numerically evaluate approximate tangent at a point and note that the tangent is used also within the context of DE (it is $\boldsymbol{y'}$ within DE indeed). If there is no mistake within the solution, we can expect that after substituting prepared numerical values into DE, left and right side have to hold equality (roughly):

$$ \begin{align} \frac{dr}{d \theta} \cot \theta - r &= 2 \nonumber \\ \frac{0.0057758}{0.001} \cot 1 - 1.70741 &= 2 \nonumber \\ 2.0012 &\doteq 2 \nonumber \end{align} $$

Despite all the simplifications we have used, the last line shows that the tangent we got from our solution fits into the DE and that suggests that the solution $(\ref{ref:first_order_sol1})$ is correct.


Solve DE with initial values. Draw direction field and solution on $x = \{-3, -2,-1,0,1,2\} \times y = \{-2,-1,0,1,2\}$

$$ y'=\frac{2x+1}{2y},\hskip2em y(-2) = -1,\hskip2em y\neq 0 $$

After some shuffling and integrating both sides:

$$ y^2 = x^2 + x + c $$

For given initial value then $c=-1$

Now we have implicit solution which can be splitted into two solutions

$$ \begin{align} y & = +\sqrt{x^2 + x -1} \hskip2em \text{and} \nonumber \\ y & = -\sqrt{x^2 + x -1} \nonumber \end{align} $$

The initial value fits only to the second one. For drawing the direction field, let us form a table, things go fast and easy then.

-2 5/4 3/4 1/4 -1/4 -3/4 -5/4 -7/4
-1 5/2 3/2 1/2 -1/2 -3/2 -5/2 -7/2
1 -5/2 -3/2 -1/2 1/2 3/2 5/2 7/2
2 -5/4 -3/4 -1/4 1/4 3/4 5/4 7/4
Note: more grid points are shown within the chart than are computed within the table.

List of chapters