A Step-by-Step Tutorial on Linear Differential Equations with Examples and Solutions
Linear differential equations appear throughout mathematics, physics, engineering, economics, and many real-world modeling problems. In this guide, you will learn how to solve Linear differential equations with examples and solutions.
In this tutorial, you will learn what a linear differential equation is, how initial conditions work, and how to solve them using integrating factors. This article also includes multiple step-by-step examples and solutions so you can see how they are solved in practice.
What Is a Linear Differential Equation?
Before learning how to solve linear differential equations, it is important to understand what they are and how they are structured. A differential equation is an equation that contains an unknown function together with one or more of its derivatives. A linear differential equation is a special type of differential equation in which the dependent variable and its derivatives appear only to the first power and are not multiplied together.
If you need a review of derivatives, please refer to the article How to Differentiate a Function Step by Step: A Beginner’s Guide before continuing.
A first-order linear differential equation has the form
$$\frac{dy}{dx} + p(x)y = g(x)$$
Where \( y \) is the unknown function.
Initial Conditions
Differential equations have infinitely many solutions because integration introduces an arbitrary constant, as discussed in the article Basic Integration Problems for Beginners.
To determine a particular solution, we need additional information, called initial conditions, which specify the value of the unknown function at a particular point.
A differential equation together with an appropriate number of initial conditions is called an initial value problem.
Derivation
Consider the linear differential equation
$$\frac{dy}{dx} + p(x)y= g(x).$$
Our goal is to manipulate the left-hand side so that it becomes the derivative of a single expression. To accomplish this, we multiply the entire equation by an unknown function \( \mu(x) \), called the integrating factor. This gives
$$\mu(x)\frac{dy}{dx} + \mu(x)p(x)y = \mu(x)g(x).$$
At this point, we do not yet know what \( \mu(x) \) should be. Note that we want the left-hand side to reduce to
$$(\mu(x)y)’$$
Applying the product rule gives
$$\mu(x)\frac{dy}{dx} + \mu'(x)y.$$
So we want the integrating factor to satisfy
$$\mu'(x) = \mu(x)p(x).$$
Hence,
$$\frac{\mu'(x)}{\mu(x)} = p(x).$$
Note that
$$\frac{\mu'(x)}{\mu(x)} = (\ln{(\mu(x))})’,$$
So
$$(\ln{(\mu(x))})’ = p(x).$$
Integrating both sides, we get
$$\int(\ln{(\mu(x))})’dx = \int p(x)dx.$$
Not worrying about the constant of integration at this time, this is
$$\ln{(\mu(x))} = \int p(x)dx.$$
Converting to exponential form then gives
$$\mu(x) = e^{\int p(x)dx}.$$
Substituting into the differential equation, we get
$$e^{\int p(x)dx}\frac{dy}{dx} + e^{\int p(x)dx}p(x)y = e^{\int p(x)dx}g(x).$$
Recall that this reduces to
$$(e^{\int p(x)dx}y)’ = e^{\int p(x)dx}g(x).$$
Integrating both sides, we get
$$\int(e^{\int p(x)dx}y)’ dx = \int e^{\int p(x)dx}g(x) dx.$$
Integrating while introducing a constant of integration on the right-hand side, this is
$$e^{\int p(x)dx}y = \int e^{\int p(x)dx}g(x) dx + C.$$
Solving for y, we obtain the solution
$$y = \frac{\int e^{\int p(x)dx}g(x) dx + C}{ e^{\int p(x)dx}}.$$
Although this derivation may seem lengthy, the actual solution process follows a predictable sequence of steps. Once you become familiar with the integrating factor, solving linear differential equations is more straightforward.
Steps to Solve Linear Differential Equations
After deriving the integrating factor method, we can now turn the theory into a practical procedure. The good news is that every linear differential equation can be solved using the same sequence of steps. Once you become comfortable with this process, solving linear differential equations becomes more systematic.
Step 1: Write the Equation in Standard Form
The first step is to ensure that the differential equation is written as
$$\frac{dy}{dx} + p(x)y = g(x).$$
Sometimes the equation is already in standard form. Other times, you may need to rearrange terms or divide by a coefficient.
Step 2: Compute the Integrating Factor
The integrating factor is given by
$$\mu(x) = e^{\int p(x)\,dx}.$$
Do not worry about the constant of integration for now.
Step 3: Multiply Both Sides of the Equation by the Integrating Factor
Multiply every term of the differential equation by \( \mu(x) \). The left-hand side of the equation can then be reduced using the product rule.
Step 4: Integrate Both Sides
Integrate both sides with respect to \( x \), introducing a constant of integration on the right-hand side.
Step 5: Solve for \( y \)
Divide both sides of the equation by the integrating factor.
Step 6: Apply the Initial Condition (If Given)
If an initial condition is provided, substitute it into the general solution to determine the constant \( C \).
Worked Out Examples
The best way to learn how to solve linear differential equations is by working through several examples. In this section, we will apply the step-by-step procedure developed earlier to four different problems.
Example 1: Solve \( \frac{dy}{dx}+2y = e^{-2x} \).
Solution: The equation is already in standard form. The integrating factor is
$$\mu(x) = e^{\int 2 dx}.$$
Integrating we get
$$\mu(x) = e^{2x}.$$
Multiplying each term of the equation by the integrating factor, we obtain
$$e^{2x}\frac{dy}{dx} + 2e^{2x}y = e^{2x}e^{-2x}.$$
Using exponential properties, we find
$$e^{2x}\frac{dy}{dx} + 2e^{2x}y = e^{2x – 2x}.$$
Simplifying this is equivalent to
$$e^{2x}\frac{dy}{dx} + 2e^{2x}y = e^{0}.$$
Hence,
$$e^{2x}\frac{dy}{dx} + 2e^{2x}y = 1.$$
Rewriting the left-hand side as a product rule, this becomes
$$\frac{d}{dx}(e^{2x}y) = 1.$$
Integrating both sides, we find
$$\int \frac{d}{dx}(e^{2x}y) dx = \int 1 dx.$$
Therefore,
$$e^{2x}y = x + C.$$
Our final solution is then
$$y = xe^{-2x} + Ce^{-2x}.$$
The next example requires the substitution rule, so you may wish to review the article The Ultimate Step-by-Step Guide to Solving Integrals Using Substitution for a refresher.
Example 2: Solve \( \frac{dy}{dx} + 2xy = 2x \).
Solution: The equation is already in standard form. The integrating factor is
$$\mu(x) = e^{\int 2x dx}.$$
Integrating we get
$$\mu(x) = e^{x^2}.$$
Multiplying each term of the equation by the integrating factor, we obtain
$$e^{x^2}\frac{dy}{dx} + 2xe^{x^2}y = 2xe^{x^2}.$$
Rewriting the left-hand side as a product rule, this becomes
$$\frac{d}{dx}(e^{x^2}y) = 2xe^{x^2}.$$
Integrating both sides, we find
$$\int \frac{d}{dx}(e^{x^2}y) dx = \int 2xe^{x^2} dx.$$
To evaluate the integral on the right-hand side, let \( u = x^2 \). Computing the differential gives \( u = 2x dx \). Substituting these into the integral, we arrive at
$$\int \frac{d}{dx}(e^{x^2}y) dx = \int e^{u} du.$$
Integrating, we obtain
$$e^{x^2}y = e^{u} + C.$$
Therefore,
$$e^{x^2}y = e^{x^2} + C.$$
Multiplying both sides of the equation by \( e^{-x^2} \) we obtain
$$e^{x^2}e^{-x^2}y = e^{x^2}e^{-x^2} + Ce^{-x^2}.$$
Using exponential properties, we find
$$e^{x^2 – x^2}y = e^{x^2 – x^2} + Ce^{-x^2}.$$
Simplifying this is equivalent to
$$e^{0}y = e^{0} + Ce^{-x^2}.$$
Hence,
$$1y = 1 + Ce^{-x^2}.$$
Our final solution is then
$$y = 1 + Ce^{-x^2}.$$
The next example requires integration by parts, so you may wish to review the article Integration by Parts Explained with Examples: A Step-by-Step Guide for a refresher.
Example 3: Solve \( \frac{dy}{dx} + y = x \), \( y(0) = 0 \).
Solution: The equation is already in standard form. The integrating factor is
$$\mu(x) = e^{\int dx}.$$
Integrating we get
$$\mu(x) = e^x.$$
Multiplying each term of the equation by the integrating factor, we obtain
$$e^x\frac{dy}{dx} + e^xy = xe^x.$$
Rewriting the left-hand side as a product rule, this becomes
$$\frac{d}{dx}(e^xy) = xe^x.$$
Integrating both sides, we find
$$\int \frac{d}{dx}(e^xy) dx = \int xe^x dx.$$
To evaluate the integral on the right-hand side, choose \( u = x \) and \( dv = e^xdx \), then \( du = dx \) and \( v = e^x \). Applying the integration by parts formula then gives
$$\int \frac{d}{dx}(e^xy) dx = xe^x – \int e^x dx.$$
Therefore,
$$e^xy = xe^x – e^x + C.$$
Multiplying both sides of the equation by \( e^{-x} \) we obtain
$$e^xe^{-x}y = xe^xe^{-x} – e^xe^{-x} + Ce^{-x}.$$
Using exponential properties, we find
$$e^{x – x}y = xe^{x – x} – e^{x – x} + Ce^{-x}.$$
Simplifying this is equivalent to
$$e^0y = xe^0 – e^0 + Ce^{-x}.$$
Hence,
$$1y = 1x – 1 + Ce^{-x}.$$
Our solution is then
$$y = x – 1 + Ce^{-x}.$$
Applying the initial condition, we get
$$y(0) = 0 – 1 + Ce^{-0}.$$
Multiplying then gives
$$y(0) = 0 – 1 + Ce^0.$$
This is equivalent to
$$y(0) = 0 – 1 + 1C.$$
Hence,
$$y(0) = 0 – 1 + C.$$
Simplifying, we find
$$y(0) = -1 + C.$$
By the initial condition, this is equivalent to
$$0 = -1 + C.$$
Which implies
$$1 = C.$$
Substituting into the solution then gives
$$y = x – 1 + 1e^{-x}.$$
Our final solution is then
$$y = x – 1 + e^{-x}.$$
The next example involves integrating products of trigonometric functions, so you may wish to review the article How to Integrate Products of Trigonometric Functions: Techniques and Tricks for a refresher.
Example 4: Solve $$\sin(x)\frac{dy}{dx} + \cos(x)y = \sin(x)\cos(x).$$
Solution: The equation is not in standard form. However, notice that
$$\frac{d}{dx}(\sin(x)y) = \sin(x)\frac{dy}{dx} + \cos(x)y.$$
Rewriting the left-hand side of our differential equation, it becomes
$$\frac{d}{dx}(\sin(x)y) = \sin(x)\cos(x).$$
Integrating both sides, we find
$$\int \frac{d}{dx}(\sin(x)y) dx = \int \sin(x)\cos(x) dx.$$
To evaluate the integral on the right-hand side, let \( u = \sin(x) \). Computing the differential gives \( u = \cos(x) dx \). Substituting these into the integral, we arrive at
$$\int \frac{d}{dx}(\sin(x)y) dx = \int u du.$$
Integrating, we obtain
$$\sin(x)y = \frac{1}{2}u^2 + C.$$
Therefore,
$$\sin(x)y = \frac{1}{2}\sin^2(x) + C.$$
Dividing both sides of the equation by \( \sin(x) \) we obtain
$$y = \frac{1}{2}\frac{\sin^2(x)}{\sin(x)} + C\frac{1}{\sin(x)}.$$
Using exponential properties and reciprocal identities, we find
$$y = \frac{1}{2}\sin^{2 – 1}(x) + C\csc(x).$$
Simplifying this is equivalent to
$$y = \frac{1}{2}\sin^{1}(x) + C\csc(x).$$
Our final solution is then
$$y = \frac{1}{2}\sin(x) + C\csc(x).$$
These examples demonstrate how the integrating factor method naturally combines with many of the integration techniques encountered in calculus.
Conclusion
In this guide, we began by defining linear differential equations with examples and solutions. We then derived the integrating factor method from the product rule, showing why the technique works rather than simply presenting it as a formula to memorize. After that, we developed a step-by-step procedure that can be applied systematically to any linear differential equation.
The examples demonstrated how solving linear differential equations often requires integration techniques from calculus. Depending on the problem, you may encounter straightforward algebraic integrals, substitution, integration by parts, trigonometric identities, or combinations of several methods. As a result, success with differential equations depends not only on understanding the integrating factor method but also on developing strong integration skills.
Further Reading
A Comprehensive Beginner’s Guide to Partial Fraction Decomposition – Partial fraction decomposition shows up frequently in the study of differential equations, including when evaluating rational integrals and taking inverse Laplace transforms.
