### Examples of solving linear ordinary differential equations using an integrating factor

#### Example 1

Solve the ODE \begin{gather} \diff{x}{t} -\cos(t)x(t)=\cos(t) \label{example1} \end{gather} for the initial conditions $x(0)=0$.

**Solution**: Since this is a first order linear ODE, we can solve it
by finding an integrating factor $\mu(t)$. If we choose $\mu(t)$ to be
\begin{align*}
\mu(t) = e^{-\int \cos(t)} = e^{-\sin(t)},
\end{align*}
and multiply both sides of the ODE by $\mu$, we can rewrite the ODE as
\begin{align*}
\diff{}{t}(e^{-\sin(t)}x(t)) &= e^{-\sin(t)}\cos(t).
\end{align*}
Integrating with respect to $t$, we obtain
\begin{align*}
e^{-\sin(t)}x(t) &= \int e^{-\sin(t)}\cos(t) dt +C\\
&= -e^{-\sin(t)} + C,
\end{align*}
where we used the $u$-subtitution $u=\sin(t)$ to compute the integral.
Dividing through by $e^{-\sin(t)}$, we calculate that the the general form of the solution to equation \eqref{example1}
is
\begin{gather*}
x(t) = -1 + Ce^{\sin(t)}.
\end{gather*}

We verify that we have a solution to equation \eqref{example1}. Since $$\diff{x}{t} = Ce^{\sin(t)}\cos(t)$$ we calculate that $$\diff{x}{t} - \cos(t)x(t) = Ce^{\sin(t)}\cos(t)-\cos(t)(-1 + Ce^{\sin(t)}) = \cos(t),$$ demonstrating that we have found the general solution to the ODE.

We determine the integration constant $C$ by the condition $0=x(0)=-1+Ce^0 = -1+C$, so that $C=1$. Our specific solution to the ODE of \eqref{example1} is \begin{gather*} x(t) = -1 + e^{\sin(t)}. \end{gather*}

#### Example 2

Solve the ODE \begin{gather} \diff{x}{t} = \frac{1}{\tau}(-x + I(t)) \label{example2} \end{gather} with initial condition $x(t_0)=x_0$.

**Solution**: Rewrite the equation in the form
\begin{gather*}
\diff{x}{t} + \frac{x}{\tau}= \frac{I(t)}{\tau}.
\end{gather*}
In this case, our integrating factor is $\mu(t) = e^{\int (1/\tau) dt} = e^{t/\tau}$. Multiplying through by $\mu(t)$, we can rewrite our ODE as
\begin{gather*}
\diff{}{t}\left(e^{t/\tau}x(t)\right)= \frac{I(t)}{\tau}e^{t/\tau}.
\end{gather*}

For this example, let's integrate from $t_0$ to $t$, rather than calculate the indefinite integral as in previous examples. \begin{align*} \int_{t_0}^t \diff{}{t'}\left(e^{t'/\tau}x(t')\right)dt' &= \int_{t_0}^t \frac{I(t')}{\tau}e^{t'/\tau}dt'\\ e^{t/\tau}x(t) - e^{t_0/\tau}x(t_0) &= \frac{1}{\tau}\int_{t_0}^t e^{t'/\tau}I(t')dt' \end{align*} Dividing through by $e^{t/\tau}$ and using the initial conditions $x(t_0)=x_0$, the solution to the ODE of \eqref{example2} is \begin{gather} x(t) = e^{-(t-t_0)/\tau}x_0 + \frac{1}{\tau}\int_{t_0}^t e^{-(t-t')/\tau}I(t')dt'. \label{example2sol} \end{gather}

To verify this solution, we differentiate equation \eqref{example2sol} with respect to $t$, obtaining three terms (two from the exponentials and one from the upper integration limit), \begin{align*} \diff{x}{t} &= -\frac{1}{\tau} e^{-(t-t_0)/\tau}x_0 -\frac{1}{\tau} \frac{1}{\tau}\int_{t_0}^t e^{-(t-t')/\tau}I(t')dt' + \frac{1}{\tau} e^{-0/\tau}I(t) \\ &= -\frac{1}{\tau} \left(e^{-(t-t_0)/\tau}x_0 +\frac{1}{\tau}\int_{t_0}^t e^{-(t-t')/\tau}I(t')dt'\right) + \frac{1}{\tau} I(t) \\ &=-\frac{1}{\tau}x(t) + \frac{1}{\tau}I(t). \end{align*} Indeed $x(t)$ satisfies equation \eqref{example2}. If we plug $t=t_0$ into equation \eqref{example2sol}, the integral is from $t_0$ to $t_0$, so is zero. The exponential of the first term is $e^0=1$, and we confirm that $x(t_0)=x_0$.

#### Example 3

Solve the ODE \begin{align} \diff{x}{t} + e^{t}x(t) = t^2 \cos(t) \label{example3} \end{align} with the initial condition $x(0)=5$.

**Solution**: The first step is to find the integrating factor
\begin{gather*}
\mu(t) = e^{\int e^t dt} = e^{e^t} = \exp(e^t),
\end{gather*}
where $\exp(x)$ is another way of writing $e^x$. Multiplying
equation \eqref{example3} by $\mu(t)$, then the left hand side is the derivative
of $\mu(t)x(t)$. We can write it as
\begin{align*}
\diff{}{t}\left( \exp(e^t) x(t)\right) = t^2 \cos(t) \exp(e^t).
\end{align*}

To solve the ODE in terms of the initial conditions $x(0)$, we integrate from $0$ to $t$, obtaining \begin{align*} \int_0^t \diff{}{s}\left( \exp(e^{s}) x(s)\right)ds &= \int_0^t {s}^2 \cos(s) \exp(e^{s})ds\\ \exp(e^{t}) x(t) - \exp(e^{0}) x(0) &= \int_0^t {s}^2 \cos(s) \exp(e^{s})ds. \end{align*} Even though we cannot compute the integral analytically, we still consider the ODE solved. Plugging in the initial conditions $x(0)=5$, we can write the solution of the ODE \eqref{example3} as \begin{align*} x(t) &= 5\exp(1-e^t)+ \int_0^t {s}^2 \cos(s) \exp(e^{s}-e^{t})ds. \end{align*}

You can easily check that $x(t)$ satisfies the ODE \eqref{example3} and the initial conditions $x(0)=5$.

#### Thread navigation

##### Math 5447, Fall 2020

- Previous: Solving linear ordinary differential equations using an integrating factor
- Next: Online quiz: Scalar linear equation problems

##### Math 5447, Fall 2022

#### Similar pages

- Solving linear ordinary differential equations using an integrating factor
- An introduction to ordinary differential equations
- Ordinary differential equation examples
- Exponential growth and decay: a differential equation
- Another differential equation: projectile motion
- Solving single autonomous differential equations using graphical methods
- Spruce budworm outbreak model
- Single autonomous differential equation problems
- Introduction to visualizing differential equation solutions in the phase plane
- Two dimensional autonomous differential equation problems
- More similar pages