Skip to main content
Logo image

APEX Calculus: for University of Lethbridge

Section 8.3 First Order Linear Differential Equations

In the previous section, we explored a specific techique to solve a specific type of differential equation called a separable differential equation. In this section, we develop and practice a technique to solve a type of differential equation called a first order linear differential equation.
Recall than a linear algebraic equation in one variable is one that can be written \(ax + b = 0\text{,}\) where \(a\) and \(b\) are real numbers. Notice that the variable \(x\) appears to the first power. The equations \(\sqrt{x}+1=0\) and \(\sin(x)-3x = 0\) are both nonlinear. A linear differential equation is one in which the dependent variable and its derivatives appear only to the first power. We focus on first order equations, which involve first (but not higher order) derivatives of the dependent variable.
Figure 8.3.1. Introduction to Section 8.3, and presentation of Example 8.3.3

Subsection 8.3.1 Solving First Order Linear Equations

Definition 8.3.2. First Order Linear Differential Equation.

A first order linear differential equation is a differential equation that can be written in the form
\begin{equation*} \frac{dy}{dx} + p(x)y = q(x)\text{,} \end{equation*}
where \(p\) and \(q\) are arbitrary functions of the independent variable \(x\text{.}\)

Example 8.3.3. Classifying Differential Equations.

Classify each differential equation as first order linear, separable, both, or neither.
  1. \(\displaystyle \displaystyle \yp = xy\)
  2. \(\displaystyle \displaystyle \yp = e^y + 3x\)
  3. \(\displaystyle \displaystyle \yp - (\cos(x))y = \cos(x)\)
  4. \(\displaystyle \displaystyle y\yp -3xy = 4\ln(x)\)
Solution.
  1. Both. We identify \(p(x) = -x\) and \(q(x) = 0\text{.}\) The separated form of the equation is \(\displaystyle \frac{dy}{y} = x\,dx\text{.}\)
  2. Neither. The \(e^y\) term makes the equation nonlinear. Because of the addition, it is not possible to write the equation in separated form.
  3. First order linear. We identify \(p(x) = -\cos(x)\) and \(q(x) = \cos(x)\text{.}\) The equation cannot be written in separated form.
  4. Neither. Notice that dividing by \(y\) results in the nonlinear term \(\displaystyle \frac{4\ln(x)}{y}\text{.}\) It is not possible to write the equation in separated form.
Notice that linearity depends on the dependent variable \(y\text{,}\) not the independent variable \(x\text{.}\) The functions \(p(x)\) and \(q(x)\) need not be linear, as demonstrated in part (c) of Example 8.3.3. Neither \(\cos(x)\) nor \(\sin(x)\) are linear functions of \(x\text{,}\) but the differential equation is still linear.
Before working out a general technique for solving first order linear differential equations, we look at a specific example. Consider the differential equation
\begin{equation*} \frac{d}{dx}\bigl(xy\bigr) = \sin(x) \cos(x)\text{.} \end{equation*}
This is an easy differential equation to solve. On the left, the antiderivative of the derivative is simply the function \(xy\text{.}\) Using the substitution \(u = \sin(x)\) on the right and integrating results in the implicit solution
\begin{equation*} xy = \frac{1}{2}\sin^2 x + C\text{.} \end{equation*}
Solving for \(y\) yields the explicit solution
\begin{equation*} y = \frac{\sin^2 x}{2x} + \frac{C}{x}\text{.} \end{equation*}
Though not obvious, the differential equation above is actually a linear differential equation. Using the product rule and implicit differentiation, we can write \(\displaystyle \frac{d}{dx}\big(xy\big) = x\frac{dy}{dx} + y\text{.}\) Our original differential equation can be written
\begin{equation*} x\frac{dy}{dx} + y = \sin(x) \cos(x)\text{.} \end{equation*}
If we divide by \(x\text{,}\) we have
\begin{equation*} \frac{dy}{dx} + \frac{1}{x} y = \frac{\sin(x) \cos(x)}{x}\text{,} \end{equation*}
which matches the form in Definition 8.3.2. Reversing our steps would lead us back to the original form our our differential equation.
As motivated by the problem we just explored, the basic idea behind solving first order linear differential equations is to multiply both sides of the differential equation by a function, called an integrating factor, that makes the left hand side of the equation look like an expanded Product Rule. We then condense the left hand side into the derivative of a product and integrate both sides. An obvious question is, “How do you find this integrating factor?”
Figure 8.3.4. Using an integrating factor to solve a linear differential equation
Consider the first order linear equation
\begin{equation*} \frac{dy}{dx} + p(x)y = q(x)\text{.} \end{equation*}
Let’s call the integrating factor \(\mu(x)\text{.}\) We multiply both sides of the differential equation by \(\mu(x)\) to get
\begin{equation*} \mu(x) \left( \frac{dy}{dx} + p(x)y \right) = \mu(x)q(x)\text{.} \end{equation*}
Our goal is to choose \(\mu(x)\) so that the left hand side of the differential equation looks like the result of a Product Rule. The left hand side of the equation is
\begin{equation*} \mu(x) \frac{dy}{dx} + \mu(x)p(x)y\text{.} \end{equation*}
Using the Product Rule and Implicit Differentiation,
\begin{equation*} \frac{d}{dx} \bigl( \mu(x) y \bigr) = \frac{d\mu}{dx}y + \mu(x)\frac{dy}{dx}\text{.} \end{equation*}
Equating \(\frac{d}{dx} \big ( \mu(x) y \big )\) and \(\mu(x) \left( \frac{dy}{dx} + p(x)y \right)\) gives
\begin{equation*} \frac{d\mu}{dx}y + \mu(x)\frac{dy}{dx} = \mu(x) \frac{dy}{dx} + \mu(x)p(x)y\text{,} \end{equation*}
which is equivalent to
\begin{equation*} \frac{d\mu}{dx} = \mu(x)p(x)\text{.} \end{equation*}
In order for the integrating factor \(\mu(x)\) to perform its job, it must solve the differential equation above. But that differential equation is separable, so we can solve it. The separated form is
\begin{equation*} \frac{d\mu}{\mu} = p(x)\,dx\text{.} \end{equation*}
Integrating,
\begin{equation*} \ln \mu = \int p(x)\,dx\text{,} \end{equation*}
or
\begin{equation*} \mu(x) = e^{\int p(x)\,dx}\text{.} \end{equation*}
If \(\mu(x)\) is chosen this way, after multiplying by \(\mu(x)\text{,}\) we can always write the differential equation in the form
\begin{equation*} \frac{d}{dx} \bigl( \mu(x)y \bigr) = \mu(x)q(x)\text{.} \end{equation*}
Integrating and solving for \(y\text{,}\) the explicit solution is
\begin{equation*} y = \frac{1}{\mu(x)}\int \bigl( \mu(x)q(x) \bigr)\,dx\text{.} \end{equation*}
Though this formula can be used to write down the solution to a first order linear equation, we shy away from simply memorizing a formula. The process is lost, and it’s easy to forget the formula. Rather, we always always follow the steps outlined in Key Idea 8.3.5 when solving equations of this type.

Key Idea 8.3.5. Solving First Order Linear Equations.

  1. Write the differential equation in the form
    \begin{equation*} \frac{dy}{dx} + p(x)y = q(x)\text{.} \end{equation*}
  2. Compute the integrating factor
    \begin{equation*} \mu(x) = e^{\int p(x)\,dx}\text{.} \end{equation*}
  3. Multiply both sides of the differential equation by \(\mu(x)\text{,}\) and condense the left hand side to get
    \begin{equation*} \frac{d}{dx}\big( \mu(x)y \big) = \mu(x)q(x)\text{.} \end{equation*}
  4. Integrate both sides of the differential equation with respect to \(x\text{,}\) taking care to remember the arbitrary constant.
  5. Solve for \(y\) to find the explicit solution to the differential equation.
Let’s practice the process by solving the two first order linear differential equations from Example 8.3.3.

Example 8.3.6. Solving a First Order Linear Equation.

Find the general solution to \(\yp = xy\text{.}\)
Solution 1.
We solve by following the steps in Key Idea 8.3.5. Unlike the process for solving separable equations, we need not worry about losing constant solutions. The answer we find will be the general solution to the differential equation. We first write the equation in the form
\begin{equation*} \frac{dy}{dx} - xy = 0\text{.} \end{equation*}
By identifying \(p(x) = -x\text{,}\) we can compute the integrating factor
\begin{equation*} \mu(x) = e^{\int -x\,dx} = e^{-\frac{1}{2}x^2}\text{.} \end{equation*}
Multiplying both side of the differential equation by \(\mu(x)\text{,}\) we have
\begin{equation*} e^{-\frac{1}{2}x^2}\left( \frac{dy}{dx} - xy\right) = 0\text{.} \end{equation*}
The left hand side of the differential equation condenses to yield
\begin{equation*} \frac{d}{dx} \left( e^{-\frac{1}{2}x^2}y\right) = 0\text{.} \end{equation*}
We integrate both sides with respect to \(x\) to find the implicit solution
\begin{equation*} e^{-\frac{1}{2}x^2}y = C\text{,} \end{equation*}
or the explicit solution
\begin{equation*} y = Ce^{\frac{1}{2}x^2}\text{.} \end{equation*}
Solution 2. Video solution

Example 8.3.7. Solving a First Order Linear Equation.

Find the general solution to \(\yp -(\cos(x))y = \cos(x)\text{.}\)
Solution 1.
The differential equation is already in the correct form. The integrating factor is given by
\begin{equation*} \mu(x) = e^{-\int\cos(x)\,dx} = e^{-\sin(x)}\text{.} \end{equation*}
Multiplying both sides of the equation by the integrating factor and condensing,
\begin{equation*} \frac{d}{dx}\left(e^{-\sin(x)}y \right) = (\cos(x)) e^{-\sin(x)} \end{equation*}
Using the substitution \(u = -\sin(x)\text{,}\) we can integrate to find the implicit solution
\begin{equation*} e^{-\sin(x)} y = -e^{-\sin(x)} + C\text{.} \end{equation*}
The explicit form of the general solution is
\begin{equation*} y = -1 + Ce^{\sin(x)}\text{.} \end{equation*}
Solution 2. Video solution
We continue our practice by finding the particular solution to an initial value problem.

Example 8.3.8. Solving a First Order Linear Initial Value Problem.

Solve the initial value problem \(\displaystyle x\yp - y = x^3\ln(x)\text{,}\) with \(y(1)=0\text{.}\)
Solution 1.
We first divide by \(x\) to get
\begin{equation*} \frac{dy}{dx}-\frac{1}{x}y = x^2\ln(x)\text{.} \end{equation*}
The integrating factor is given by
\begin{align*} \mu(x) \amp = e^{\int-\frac{1}{x}\,dx}\\ \amp = e^{-\ln(x)}\\ \amp = e^{\ln(x)^{-1}}\\ \amp = x^{-1}\text{.} \end{align*}
Multiplying both sides of the differential equation by the integrating factor and condensing the left hand side, we have
\begin{equation*} \frac{d}{dx} \left( \frac{y}{x}\right) = x\ln(x)\text{.} \end{equation*}
Using Integrating by Parts to find the antiderivative of \(x\ln(x)\text{,}\) we find the implicit solution
\begin{equation*} \frac{y}{x} = \frac{1}{2}x^2\ln(x) - \frac{1}{4}x^2 + C\text{.} \end{equation*}
Solving for \(y\text{,}\) the explicit solution is
\begin{equation*} y = \frac{1}{2}x^3\ln(x) - \frac{1}{4}x^3 + Cx\text{.} \end{equation*}
The initial condition \(y(1) = 0\) yields \(C = 1/4\text{.}\) The solution to the initial value problem is
\begin{equation*} y = \frac{1}{2}x^3\ln(x) - \frac{1}{4}x^3 + \frac{1}{4}x\text{.} \end{equation*}
Solution 2. Video solution
Differential equations are a valuable tool for exploring various physical problems. This process of using equations to describe real world situations is called mathematical modeling, and is the topic of the next section. The last two examples in this section begin our discussion of mathematical modeling.

Example 8.3.9. A Falling Object Without Air Resistance.

Suppose an object with mass \(m\) is dropped from an airplane. Find and solve a differential equation describing the vertical velocity of the object assuming no air resistance.
Solution.
The basic physical law at play is Newton’s second law,
\begin{equation*} \text{ mass } \times \text{ acceleration } = \text{ the sum of the forces }\text{.} \end{equation*}
Using the fact that acceleration is the derivative of velocity, mass × acceleration can be writting \(mv'\text{.}\) In the absence of air resistance, the only force of interest is the force due to gravity. This force is approximately constant, and is given by \(mg\text{,}\) where \(g\) is the gravitational constant. The word equation above can be written as the differential equation
\begin{equation*} m\frac{dv}{dt} = mg\text{.} \end{equation*}
Because \(g\) is constant, this differential equation is simply an integration problem, and we find
\begin{equation*} v = gt + C\text{.} \end{equation*}
Since \(v = C\) with \(t=0\text{,}\) we see that the arbitrary constant here corresponds to the initial vertical velocity of the object.
The process of mathematical modeling does not stop simply because we have found an answer. We must examine the answer to see how well it can describe real world observations. In the previous example, the answer may be somewhat useful for short times, but intuition tells us that something is missing. Our answer says that a falling object’s velocity will increase linearly as a function of time, but we know that a falling object does not speed up indefinitely. In order to more fully describe real world behavior, our mathematical model must be revised.
Figure 8.3.10. Video presentation of Examples 8.3.9–8.3.11

Example 8.3.11. A Falling Object with Air Resistance.

Suppose an object with mass \(m\) is dropped from an airplane. Find and solve a differential equation describing the vertical velocity of the object, taking air resistance into account.
Solution.
We still begin with Newon’s second law, but now we assume that the forces in the object come both from gravity and from air resistance. The gravitational force is still given by \(mg\text{.}\) For air resistance, we assume the force is related to the velocity of the object. A simple way to describe this assumption might be \(kv^{p}\text{,}\) where \(k\) is a proportionality constant and \(p\) is a positive real number. The value \(k\) depends on various factors such as the density of the object, surface area of the object, and density of the air. The value \(p\) affects how changes in the velocity affect the force. Taken together, a function of the form \(kv^{p}\) is often called a power law. The differential equation for the velocity is given by
\begin{equation*} m\frac{dv}{dt} = mg - kv^{p}\text{.} \end{equation*}
(Notice that the force from air resistance opposes motion, and points in the opposite direction as the force from gravity.) This differential equation is separable, and can be written in the separated form
\begin{equation*} \frac{m}{mg - kv^{p}}\,dv = dt\text{.} \end{equation*}
For arbitrary positive \(p\text{,}\) the integration is difficult, making this problem hard to solve analytically. In the case that \(p=1\text{,}\) the differential equation becomes linear, and is easy to solve either using either separation of variables or integrating factor techniques. We assume \(p=1\text{,}\) and proceed with an integrating factor so we can continue practicing the process. Writing
\begin{equation*} \frac{dv}{dt} + \frac{k}{m}v = g\text{,} \end{equation*}
we identify the integrating factor
\begin{equation*} \mu(t) = e^{\int \frac{k}{m}\,dt} = e^{\frac{k}{m}t}\text{.} \end{equation*}
Then
\begin{equation*} \frac{d}{dt}\left(e^{\frac{k}{m}t}v \right) = ge^{\frac{k}{m}t}\text{,} \end{equation*}
so
\begin{equation*} e^{\frac{k}{m}t}v = \frac{mg}{k}e^{\frac{k}{m}t} + C\text{,} \end{equation*}
or
\begin{equation*} v = \frac{mg}{k}+ Ce^{-\frac{k}{m}t}\text{.} \end{equation*}
The velocity functions from the previous examples.
The horizontal axis represents time and the vertical axis represents the velocity, both axes are drawn from \(0\) to \(10\text{.}\) The graph has assumptions that \(v(0)=0 \text{,}\) \(g =9.8\text{,}\) \(m=1\) and \(k=1\text{.}\) The velocity of a falling object without air resistance is a straight line that is very close to the vertical axis. The velocity function of a falling object with air resistance is along the previous velocity till \(v=3\) after which it diverges away, gets a bend at \(y=10\) and then runs parallel to the \(x\) axis after \(x=4\text{.}\)
Figure 8.3.12. The velocity functions from Examples 8.3.9 (dashed) and 8.3.11 (solid) under the assumption that \(v(0)=0\text{,}\) with \(g=9.8, m=1\text{,}\) and \(k=1\)
In the solution above, the exponential term decays as time increases, causing the velocity to approach the constant value \(mg/k\) in the limit as \(t\) approaches infinity. This value is called the terminal velocity. If we assume a zero initial velocity (the object is dropped, not thrown from the plane), the velocities from Examples 8.3.9 and 8.3.11 are given by \(v = gt\) and \(v = \displaystyle \frac{mg}{k}\left(1 - e^{-\frac{k}{m}t}\right)\text{,}\) respectively. These two functions are shown in Figure 8.3.12, with \(g = 9.8, m=1\text{,}\) and \(k=1\text{.}\) Notice that the two curves agree well for short times, but have dramatically different behaviors as \(t\) increases. Part of the art in mathematical modeling is deciding on the level of detail required to answer the question of interest. If we are only interested in the initial behavior of the falling object, the simple model in Example 8.3.9 may be sufficient. If we are interested in the longer term behavior of the object, the simple model is not sufficient, and we should consider a more complicated model.

Exercises 8.3.2 Exercises

Problems

Exercise Group.
In the following exercises, Find the general solution to the first order linear differential equation.
1.
\(\displaystyle \yp = 2y - 3\)
2.
\(\displaystyle x^2\yp + xy = 1\)
3.
\(\displaystyle x^2\yp - xy = 1\)
4.
\(\displaystyle x\yp +4y = x^3-x\)
5.
\(\displaystyle (\cos^2 x \sin(x))\yp + (\cos^3 x)y = 1\)
6.
\(\displaystyle \frac{\yp}{x} = 1-2y\)
7.
\(\displaystyle x^3\yp-3x^3y=x^4e^{2x}\)
8.
\(\displaystyle \yp + y = 5\sin(2x)\)
Exercise Group.
In the following exercises, Find the particular solution to the initial value problem.
9.
\(\displaystyle \yp = y + 2xe^x\text{,}\) \(y(0) = 2\)
10.
\(\displaystyle x\yp + 2y = x^2 - x + 1\text{,}\) \(y(1) = 1\)
11.
\(\displaystyle x\yp + (x+2)y = x\text{,}\) \(y(1) = 0\)
12.
\(\displaystyle \yp + 2y = 0\text{,}\) \(y(0) = 3\)
13.
\(\displaystyle (x+1)\yp + (x+2)y = 2xe^{-x}\text{,}\) \(y(0) = 1\)
14.
\(\displaystyle (\cos(x))\yp + (\sin(x))y = 1\text{,}\) \(y(0) = -3\)
15.
\(\displaystyle (x^2-1)\yp + 2y = (x+1)^2\text{,}\) \(y(0) = 2\)
16.
\(\displaystyle x\yp-2y = \frac{x^3}{1+x^2}\text{,}\) \(y(1) = 0\)
Exercise Group.
In the following exercises, classify the differential equation as separable, first order linear, or both, and solve the initial value problem using an appropriate method.
17.
\(\displaystyle \yp = y + yx^2\text{,}\) \(y(0) = -5\)
18.
\(\displaystyle xe^y \yp = x^2\sin(x)\text{,}\) \(y(0) = 0\)
19.
\(\displaystyle (x-1)\yp+y = x^2-1\text{,}\) \(y(0) = 2\)
20.
\(\displaystyle \yp = y^2+y-2\text{,}\) \(y(0) = 1\)
Exercise Group.
In the following exercises, draw a slope field for the differential equation. Use the slope field to predict the behavior of the solution to the initial value problem for large \(x\) values. Solve the initial value problem, and verify your prediction.
21.
\(\displaystyle \yp = x-y\text{,}\) \(y(0) = 0\)
22.
\(\displaystyle (X+1)\yp + y = \frac{1}{x+1}\text{,}\) \(y(0) = 2\)