### Solving linear ordinary differential equations using an integrating factor

A first order linear ordinary differential equation (ODE) is an ODE for a function, call it $x(t)$, that is linear in both $x(t)$ and its first order derivative $\diff{x}{t}(t)$. An example of such a linear ODE is \begin{gather*} \diff{x}{t} + t^3x(t)=\cos t. \end{gather*} Although this ODE is nonlinear in the independent variable $t$, it is still considered a linear ODE, since we only care about the dependence of the equation on $x$ and its derivative. As you will see, we easily handle nonlinearities in $t$. Such nonlinearities may result in integrals that cannot be computed analytically, but we will consider a differential equation “solved” if we can write $x(t)$ as an expression containing just integrals of functions of $t$.

As background, recall one of the simplest types of ODEs mentioned in the introductory page. If we have an equation such as $$\diff{x}{t} = t^2,$$ we can quickly solve it by integration. This equation is so simple because the left hand side is just a derivative with respect to $t$ and the right hand side is just a function of $t$. We can solve by integrating both sides with respect to $t$ to get that $x(t)=\frac{t^3}{3} + C$.

#### An initial example

Let's make the equation slightly more complicated, adding an extra $x$ to make it \begin{gather} \diff{x}{t} + x(t)=t^2. \label{ode1}\tag{1} \end{gather} Adding that little term would seem innocuous, but it ruined the perfect situation we had with the previous equation. The right hand side is still a function of $t$ alone, but the left hand side is no longer a derivative with respect to $t$. We can't just integrate the left hand side, as we don't know how to compute \begin{gather*} \int \left(\diff{x}{t} + x(t)\right)dt. \end{gather*}

If we could somehow return the left hand side into the derivative of an expression with respect to $t$ (while keeping the right hand side a function of $t$ alone), we could restore the perfect situation of the earlier equation and could solve the ODE by integrating with respect to $t$.

The trick is to find a way to manipulate $\diff{x}{t} + x(t)$ into a derivative of some expression. The term $x(t)$ simply is not the derivative of any algebraic function of $x(t)$. However, the product rule is a useful tool in this situation, since in the derivative of a product, each factor is untouched in one of the terms. If we multiply $x(t)$ by some factor $\mu(t)$ and differentiate, we obtain \begin{align*} \diff{}{t}(\mu(t)x(t)) = \mu(t)\diff{x}{t} + \diff{\mu}{t}x(t). \end{align*} That's looking closer to what we need. In fact, if we multiply both sides of the ODE of \eqref{ode1} by $\mu(t)$, the ODE becomes \begin{gather} \mu(t)\diff{x}{t} + \mu(t)x(t)=\mu(t)t^2. \label{multmu1}\tag{2} \end{gather}

We are so close to turning the left hand side into the derivative of a product. If only the coefficient of $x(t)$ were $\diff{\mu}{t}$ rather than $\mu(t)$! Then, the left hand side of equation \eqref{multmu1} would indeed be the derivative of $\mu(t)x(t)$, and we could solve the ODE by integration.

Fortunately, we are free to choose whatever $\mu(t)$ we want. Why not choose $\mu(t)$ to make everything work out perfectly? We could let $\mu(t)$ be a function that lets us switch $\mu(t)$ with $\diff{\mu}{t}$. In other words, we could let $\mu(t)$ be the solution to the ODE \begin{gather} \diff{\mu}{t} = \mu(t). \label{odemu1}\tag{3} \end{gather}

We can easily solve the ODE of \eqref{odemu1} for $\mu$. In fact, it's a special case of the linear ODE of equation (3) from the ODE introduction, with $a=1$ and $b=0$. Using the solution from equation (4) of that page, we calculate that $\mu(t) = C_1e^t,$ where $C_1$ is an arbitrary constant.

For this choice of $\mu$, we can exchange $\mu$ with the equivalent expression $\diff{\mu}{t}$, and the left hand side of equation \eqref{multmu1} is indeed the derivative of $\mu(t)x(t)$. We can rewrite the equation as \begin{gather*} \diff{}{t}(C_1e^tx(t))=C_1e^tt^2. \end{gather*}

It is immediately obvious that we don't care about the integration constant $C_1$, as we can cancel it from both sides of the equation. The reason $C_1$ doesn't matter is that we just need any factor $\mu(t)$ that satisfies equation \eqref{odemu1} in order to make the left hand side of equation \eqref{multmu1} be the derivative of $\mu(t)x(t)$. The expression for $\mu(t)$ is one of the few cases where we can ignore the constant of integration, and we can safely define $$\mu(t)=e^t.$$

The new version of our ODE is \begin{gather*} \diff{}{t}(e^tx(t))=e^tt^2. \label{odederiv1}\tag{4} \end{gather*} Finally we have transformed the ODE of \eqref{ode1} to the simple form we desired. The left hand side of equation \eqref{odederiv1} is a derivative with respect to $t$ and the right hand side is a function of $t$ alone. We can find the solution by integrating with respect to $t$: \begin{align*} \int \diff{}{t}(e^tx(t)) dt &= \int e^tt^2 dt + C\\ e^t x(t) &= e^t (2 - 2 t + t^2) +C. \end{align*}

In this case, the integral $\int e^tt^2 dt$ was simple enough that we could calculate the result analytically by integrating by parts two times to obtain $e^t (2 - 2 t + t^2)$. Even if we ended up with an integral that we couldn't compute, we would still consider the ODE to be solved, leaving the solution in terms of an integral.

Dividing through by $e^t$, we obtain the general form for the solution of \eqref{ode1} \begin{align} x(t) &=2 - 2 t + t^2 +Ce^{-t}, \label{ode1sol}\tag{5} \end{align} where the constant $C$, as usual, must be determined from initial conditions.

To verify this solution, we differentiate equation \eqref{ode1sol} $$\diff{x}{t} =- 2 + 2t -Ce^{-t}$$ and add $x(t)$ to both sides \begin{align*} \diff{x}{t} +x(t) &=- 2 + 2t -Ce^{-t} + (2- 2 t + t^2 +Ce^{-t})\\ &= t^2. \end{align*} The solution does satisfy equation \eqref{ode1}.

Since multiplying the ODE by the factor $\mu(t)$ allowed us to integrate
the equation, we refer to $\mu(t)$ as an *integrating factor*.

#### General first order linear ODE

We can use an integrating factor $\mu(t)$ to solve any first order linear ODE. Recall that such an ODE is linear in the function and its first derivative. The general form for a first order linear ODE in $x(t)$ is \begin{gather} \diff{x}{t} + p(t)x(t)=q(t). \label{folin}\tag{6} \end{gather} (If an ODE has a function of $t$ multiplying $\diff{x}{t}$, you can divide through by the function to put it into this form, assuming the function is never zero.)

We repeat the above procedure in order to turn the left hand side of equation \eqref{folin} into a derivative of $t$. Multiplying by an integrating factor $\mu(t)$, the ODE becomes \begin{gather} \mu(t)\diff{x}{t} + \mu(t)p(t)x(t)=\mu(t)q(t). \label{folin_multmu}\tag{7} \end{gather} The left hand side of equation \eqref{folin_multmu} would be the derivative of $\mu(t)x(t)$ $$\diff{}{t}(\mu(t)x(t)) = \mu(t)\diff{x}{t} + \diff{\mu}{t}x(t)$$ if we could exchange $\diff{\mu}{t}$ with $\mu(t)p(t)$. The only difference from the first example is the presence of function $p(t)$.

The integrating factor $\mu(t)$ must satisfy the equation \begin{gather} \diff{\mu}{t} = p(t)\mu(t). \label{folin_odemu}\tag{8} \end{gather} This equation is similar to equation (3) from the ODE introduction, except we have a time varying coefficient $p(t)$. It can be solved in a similar manner, as follows.

If we divide equation \eqref{folin_odemu} by $\mu(t)$, the left hand side becomes $\displaystyle\frac{1}{\mu(t)}\diff{\mu}{t} = \diff{}{t} \log |\mu(t)|$. We can transform equation \eqref{folin_odemu} into \begin{gather*} \diff{}{t} \log |\mu(t)| = p(t), \end{gather*} which is easily solved by integrating \begin{align*} \int \diff{}{t} \log |\mu(t)| dt&= \int p(t)dt\\ \log |\mu(t)| &= \int p(t)dt + C_2. \end{align*} Exponentiating both sides and simplifying, we obtain \begin{align*} |\mu(t)| &= e^{\int p(t)dt + C_2}\\ \mu(t) &= \pm e^{C_2} e^{\int p(t)dt}\\ \mu(t) &= C_3 e^{\int p(t)dt}\\ \end{align*} where $C_3=\pm e^{C_2}$ is just another constant. As before, we can ignore the constant $C_3$, or set $C_3=1$, as we just need any integrating factor $\mu(t)$ that satisfies \eqref{folin_odemu}. We let \begin{gather} \mu(t) = e^{\int p(t)dt}. \label{mu_folin}\tag{9} \end{gather}

With the integrating factor in hand, solving the ODE of \eqref{folin} is simply a matter of integrating. If we plug the integrating factor into equation \eqref{folin_multmu}, we have succeeded in transforming the left hand side into the derivative of $\mu(t)x(t)$: \begin{gather} \diff{}{t} \left(e^{\int p(t)dt} x(t)\right) =e^{\int p(t)dt}q(t). \label{folin_presol}\tag{10} \end{gather}

The left hand side of equation \eqref{folin_presol} is a derivative and the right hand side is a function of $t$. There is nothing more to do other than integrating the equation. For completeness, we'll go ahead and do this integration, though it's probably not worthwhile memorizing the resulting equation: \begin{align*} \int \diff{}{t} \left(e^{\int p(t)dt} x(t)\right) dt &=\int e^{\int p(t)dt}q(t) dt + C\\ e^{\int p(t)dt} x(t) &= \int e^{\int p(t)dt}q(t) dt+C\\ x(t) &= \frac{\int e^{\int p(t)dt}q(t) dt +C}{e^{\int p(t)dt}}. \end{align*} The equation looks fairly ugly, though we can make it simpler by writing it in terms of the integrating factor $\mu(t)$ \begin{align} x(t) &= \frac{\int \mu(t)q(t) dt +C}{\mu(t)}\notag\\ \mu(t) &= e^{\int p(t)dt}. \label{folin_sol}\tag{11} \end{align}

Rather than trying to memorize equation \eqref{folin_sol}, you may be better off just memorizing the solution \eqref{mu_folin} for the integrating factor. With $\mu(t)$ in hand and knowledge that multiplying by $\mu(t)$ puts the ode in the nice form of equation \eqref{folin_presol}, you can then integrate equation \eqref{folin_presol} for any specific equation to get the solution.

Of course, for any functions $p(t)$ and $q(t)$, one may not be able to analytically compute the integrals for the solution of the first order linear ordinary differnetial equation \eqref{folin}. Even so, we consider the ODE solved if the solution is just in terms of integrals of $t$.

Some examples may help you better understand how to use integrating factors.

#### Thread navigation

##### Math 5447, Fall 2017

#### Similar pages

- Examples of 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