Math 519 review—first order differential equations
In calculus (math 222 in Madison) we learn how to “solve” two kinds
of differential equations of the form
\begin{equation}
\frac{dy}{dx} = f(x, y)
\label{eq:mother-of-all-ode}
\end{equation}
By definition a separable differential equation is a diffeq of the form
\begin{equation}
\label{eq:separable-2}
y'(x) = F(x) G(y(x)),\quad\text{or}\quad \frac{d y}{d x} = F(x)G(y).
\end{equation}
Thus the function $f(x,y)$ on the right hand side in
\eqref{eq:mother-of-all-ode} has the special form
\[
f(x,y) = F(x)\, G(y).
\]
For example, the differential equation
\[
\frac{d y}{d x} = \sin(x) \bigl(1+y^2\bigr)
\]
is separable, and one has $F(x) = \sin x$ and $G(y) = 1+y^2$.
On the other hand, the differential equation
\[
\frac{d y}{d x} = x+y
\]
is not separable.
Solution method for separable equations
To solve this equation divide by $G(y(x))$ to get
\begin{equation}
\label{eq:separated}
\frac{1}{ G(y(x))} \frac{d y}{d x} = F(x).
\end{equation}
Next find a function $H(y)$ whose derivative with respect to $y$ is
\begin{equation}\label{eq:separable-3}
H'(y) = \frac{1}{G(y)}
\quad\left(\text{solution: } H(y) = \int {\frac{dy}{G(y)}}.\right)
\end{equation}
Then the chain rule implies that the left hand side in (\ref{eq:separated}) can be written as
\[
\frac{1}{ G(y(x))} \frac{d y}{d x} = H'(y(x)) \frac{d y}{d x} =
\frac{d H(y(x))}{d x}.
\]
Thus \eqref{eq:separated} is equivalent with
\[
\frac{d H(y(x))}{d x} = F(x).
\]
In words: $H(y(x))$ is an antiderivative of $F(x)$, which means we can find $H(y(x))$
by integrating $F(x)$:
\begin{equation}
\label{eq:separable-solution}
H(y(x)) = \int F(x) dx +C.
\end{equation}
Once we have found the integral of $F(x)$ this gives us $y(x)$ in implicit form: the
equation (\ref{eq:separable-solution}) gives us $y(x)$ as an implicit
function of $x$. To get $y(x)$ itself we must solve the equation
(\ref{eq:separable-solution}) for $y(x)$.
Determining the constant. The solution we get from the above
procedure contains an arbitrary constant $C$. If the value of the solution is
specified at some given $x_0$, i.e. if $y(x_0)$ is known then we can express $C$ in
terms of $y(x_0)$ by using \eqref{eq:separable-solution}.
A snag
We have to divide by $G(y)$ which is
problematic when $G(y)=0$. This has as consequence that in addition to the
solutions we found with the above procedure, there are at least a few more
solutions: the zeroes of $G(y)$ (see the example
below). In addition to the zeroes of $G(y)$ there sometimes can be more
solutions
Example
We solve
\[
\frac{d z}{d t} = (1+z^2)\cos t.
\]
Separate variables and integrate
\[
\int\frac{d z}{1+z^2} = \int\cos t\,d t,
\]
to get
\[
\arctan z = \sin t +C.
\]
Finally solve for $z$ and we find the general solution
\[
z(t) = \tan \bigl (\sin (t) +C\bigr).
\]
Example: the snag in action
If we apply the method to $y'(x)=y$, we get
\[
y(x) = e^{x+C}.
\]
No matter how we choose $C$ we never get the function $y(x)=0$, even though $y(x)=0$
satisfies the equation. This is because here $G(y)= y$, and $G(y)$ vanishes for
$y=0$.
Differential equations of the form equation
\begin{equation}
\frac{d y}{d x}+a(x)y = k(x)
\label{eq:inhomogeneous-linear}
\end{equation}
are called first order linear.
The Integrating Factor
Linear equations can always be solved by multiplying both sides of the equation
with a specially chosen function $m(x)$ called the integrating factor. It is
defined by
\begin{equation}
m (x) = e^{A (x)},\text{ where } A (x) = \int a(x)\,d x.
\label{eq:integrating-factor-defined}
\end{equation}
If we multiply the equation \eqref{eq:inhomogeneous-linear} with the integrating
factor $m(x)$ we get
\[
m(x)\frac{d y}{d x}+a(x)m(x)y = m(x)k(x).
\]
By the chain rule the integrating factor satisfies
\[
\frac{d m(x)}{d x} = \frac{d\,
e^{A(x)}} {d x}
= \underbrace{A'(x)}_{=a(x)} ~\underbrace{e^{A(x)}_{}}_{=m(x)}
= a(x)m(x).
\]
Therefore one has
\begin{align*}
\frac{d m(x)y}{d x}
&= m(x)\frac{d y}{d x}+a(x)m(x)y \\
&= m(x)\Bigl\{\frac{d y}{d x}+a(x)y \Bigr\}\\
&= m(x)k(x).
\end{align*}
Integrating and then dividing by the integrating factor gives the solution
\[
y=\frac1{m(x)}\left(\int m(x)k(x)\,d x+C\right).
\]
In this derivation we have to divide by $m(x)$, but since $m(x)=e^{A (x)}$ and since
exponentials never vanish we know that $m (x)\neq0$, so we can always divide by $m
(x)$.
An example
Find the general solution to the differential equation
\[
\frac{d y} {d x} = y + x.
\]
Then find the solution that satisfies
\begin{equation}
y(2)=0.
\label{eq:example-linear-initial-condition}
\end{equation}
Solution.
We first write the equation in the standard linear form
\begin{equation}
\label{eq:diffeq-linear-example}
\frac{d y} {d x} - y = x,
\end{equation}
and then multiply with the integrating factor $m(x)$. We could of course memorize
the formulas \eqref{eq:integrating-factor-defined} that lead to the integrating
factor, but a safer approach is to remember the following procedure, which will
always give us the integrating factor.
Assuming that $m(x)$ is as yet unknown we multiply the differential
equation \eqref{eq:diffeq-linear-example} with $m$,
\begin{equation}
m(x)\frac{d y} {d x} - m(x) y = m(x)x.
\label{eq:example-multiplied-with-m}
\end{equation}
If $m(x)$ is such that
\begin{equation}
-m(x) = \frac{d m(x)} {d x},
\label{eq:integrating-factor-condition}
\end{equation}
then equation \eqref{eq:example-multiplied-with-m} implies
\[
m(x)\frac{d y} {d x} + \frac{d m(x)} {d x} y = m(x)x.
\]
The expression on the left is exactly what comes out of the product rule -- this is
the point of multiplying with $m(x)$ and then insisting
on \eqref{eq:integrating-factor-condition}. So, if $m(x)$
satisfies \eqref{eq:integrating-factor-condition}, then the differential equation for
$y$ is equivalent with
\[
\frac{d m(x) y} {d x} = m(x) x.
\]
We can integrate this equation,
\[
m(x) y = \int m(x) x \;d x,
\]
and thus find the solution
\begin{equation}
y(x) = \frac{1} {m(x)} \int m(x) x \;d x.
\label{eq:example-linear-almost-solved}
\end{equation}
All we have to do is find the integrating factor $m$. This factor can be any
function that satisfies \eqref{eq:integrating-factor-condition}.
Equation \eqref{eq:integrating-factor-condition} is a differential equation for $m$,
but it is separable, and we can easily solve it:
\[
\frac{d m} {d x} = -m \iff
\frac{d m} {m} = -d x \iff
\ln|m| = -x +C.
\]
Since \textit{we only need one integrating factor} $m$ we are not interested in
finding all solutions of \eqref{eq:integrating-factor-condition}, and therefore we
can choose the constant $C$. The simplest choice is $C=0$, which leads to
\[
\ln |m| = -x \iff |m| = e^{-x} \iff m = \pm e^{-x}.
\]
Again, we only need one integrating factor, so we may choose the $\pm$ sign: the simplest
choice for $m$ here is
\[
m(x) = e^{-x}.
\]
With this choice of integrating factor we can now complete the calculation that led
to \eqref{eq:example-linear-almost-solved}. The solution to the differential
equation is
\begin{align*}
y(x)
&= \frac{1} {m(x)} \int m(x) x \;d x \\
&= \frac{1} {e^{-x}} \int e^{-x}x \;d x \\
&= e^{x} \Bigl\{-e^{-x}x - e^{-x} + C\Bigr\} \\
&= -x-1+Ce^x.
\end{align*}
This is the general solution.
To find the solution that satisfies not just the differential equation, but also
the “initial
condition” \eqref{eq:example-linear-initial-condition},
i.e. $y(2)=0$, we compute $y(2)$ for the general solution,
\[
y(2) = -2-1+Ce^2 = -3 + Ce^2.
\]
The requirement $y(2) = 0$ then tells us that $C=3e^{-2}$. The solution of the
differential equation that satisfies the prescribed initial condition is therefore
\[
y(x) = -x-1+3e^{x-2}.
\]