Non Homogeneous Differential Equation – Definition and Examples

Learning about non-homogeneous differential equations is fundamental, since there are instances when we’re given complex equations with functions on both sides of the equation. Laws of motion, for example, rely on non-homogeneous differential equations, so it is important that we learn how to solve these types of equations.

Non-homogenous differential equations contain functions on their right-hand side of the equations. We can find their solutions by writing down the general solution of the associated homogeneous differential equation and the particular solution of the non-homogeneous term.

Solving non-homogeneous differential equations will still require our knowledge on solving second order homogeneous differential equations, so keep your notes handy on characteristic and second order homogeneous equations. This article covers the fundamentals needed to identify non-homogeneous differential equations and two important methods that will help you find their solutions.

What Is a Non Homogeneous Differential Equation?

Non-homogeneous differential equations are simply differential equations that do not satisfy the conditions for homogeneous equations. In the past, we’ve learned that homogeneous equations are equations that have zero on the right-hand side of the equation.

This means that non-homogenous differential equations are differential equations that have a function on the right-hand side of their equation.

Here are some examples of homogeneous and non-homogenous differential equations. Through these examples, we’ll learn how to identify differential equations based on their form.

Homogeneous Differential Equations

Non-Homogenous Differential Equations

\begin{aligned}y^{\prime \prime} + y^{\prime} – 2y = 0\end{aligned}

\begin{aligned}y^{\prime \prime} + y^{\prime} – 2y = 4x\end{aligned}

\begin{aligned}y^{\prime \prime} -3y^{\prime}  + y = 0\end{aligned}

\begin{aligned}y^{\prime \prime} -3y^{\prime}  + y = -6 – 2x + 3x^2\end{aligned}

\begin{aligned}y^{\prime \prime \prime} +4y^{\prime\prime} + 4y^{\prime} + y = 0\end{aligned}

\begin{aligned}y^{\prime \prime \prime} +4y^{\prime\prime} + 4y^{\prime} + y = 2e^x\end{aligned}

From these three equations alone, we can clearly see that the right-hand side of the equations will determine whether the differential equations are homogeneous or non-homogeneous. We call the equations on the left column the associated homogeneous equations since they share identical expressions with their non-homogeneous counterparts. 

Since we’ve been working on first order and second order non-homogeneous linear differential equations, let us show you their general forms:

\begin{aligned}\textbf{First Order} &: y^{\prime} + P(x)y = f(x)\\\textbf{Second Order} &: y^{\prime} + P(x)y^{\prime} + Q(x)y = g(x)\\ \end{aligned}

In the next section, we’ll show you how to solve these types of equations by applying old techniques and even new methods!

How To Solve Non Homogeneous Differential Equations?

We can solve non-homogeneous linear differential equations by finding the general solution of the associated homogeneous differential equation, $y_h$, and the particular solution of the non-homogeneous equation, $y_p$.

Let’s work on a first order non-homogeneous differential equation to start this section lightly.

\begin{aligned}y^{\prime} + P(x)y = f(x)\end{aligned}

In the past, we’ve learned how to deal with these types of equations. We’ve shown you how to use integrating factors to write the general equation for a first order non-homogeneous differential equation. This process will eventually lead to a general solution shown below.

\begin{aligned}y &= h(x) + p(x) \end{aligned}

For this solution, $g(x)$ represents the general solution, while $h(x)$ represents the particular solution of the first order non-homogeneous differential equation. Since we’ve set a special article for that, our discussion will focus on second order non-homogeneous differential equations and those with higher order as well.


Suppose that we have a second order non-homogeneous linear differential equation shown below.

\begin{aligned}y^{\prime \prime} +ay^{\prime} + by &= g(x)\end{aligned}

For this equation, $a$ and $b$ are constants. When this happens, the nonhomogeneous differential equation with a general solution as shown below.

\begin{aligned}\boldsymbol{y} &= \boldsymbol{y_h + y_p}\\\\y_h&: \text{General Solution}\\y_p&: \text{Particular Solution}\end{aligned}

This can be extended with $n$th-order non-homogeneous linear differential equation. The general solution of this linear differential equation is as shown below.

\begin{aligned}c_1y_1 + c_2\end{aligned}

In previous articles, we have also learned how to find the general solutions for homogeneous differential equations. We’ll apply the same methods and techniques when finding the general solution for our associated homogeneous equation. This means that we’ll be focusing on techniques to find the particular solution for these non-homogeneous equations.

How To Find the Particular Solution of a Non Homogeneous Differential Equation

The two most common methods when finding the particular solution of a non-homogeneous differential equation are: 1) the method of undetermined coefficients and 2) the method of variation of parameters.

Method of Undetermined Coefficients

Let’s first break down the steps for the method of undetermined coefficients and know when it’s best to use this technique. The undetermined coefficient method works best when the right-hand side of our non-homogeneous differential equation is a function that can be written as sum or product of the following functions: $x^n$, $e^{ax}$,$\sin \beta x$, or $\cos \beta x$.

\begin{aligned}y^{\prime \prime} +ay^{\prime} + by &= g(x)\end{aligned}

Once we identify the form of the $g(x)$, use a strategic guess for the particular solution, $y_p$. Let us show you some common examples for a smart guess given an expression for $g(x)$:

Example of $\boldsymbol{g(x)}$

Particular Solution ($\boldsymbol{y_p}$)

\begin{aligned}g(x) = 2x^2\end{aligned}

\begin{aligned}y_p = ax^2 + bx + c\end{aligned}

\begin{aligned}g(x) = 3xe^x\end{aligned}

\begin{aligned}y_p = axe^x + bex^x c\end{aligned}

\begin{aligned}g(x) = x + 4\cos 3x\end{aligned}

\begin{aligned}y_p = (ax + b) + c \sin 3x + d + \cos 3x\end{aligned}

These three equations should give you an idea of how we come up with particular solutions we can use to complete the general solution for our second order homogeneous differential equation. Find the first and second derivatives of $y_p$ and use them inside the equation then solve for the values of the constants.

To understand how this method works, let’s try to solve the non-homogeneous differential equations, $y^{\prime \prime} + 6y^{\prime} + 5y = 4x$. First, let’s find $y_h$, the general solution of the equation’s associated homogeneous equation.

 \begin{aligned}y^{\prime \prime} + 6y^{\prime} + 5y = 0\end{aligned}

This means that the characteristic equation (or auxiliary equation) is a quadratic equation, $r^2 + 6r + 5= 0$. The roots of this equation are $r_1 = -1$ and $r_2 = -5$, so the general form of $y_h$ is equal to the equation shown below.

\begin{aligned}y_h = C_1 e^{-x} + C_2 e^{-5x} \end{aligned}

Since our equation’s right-hand side is equal to $g(x) = 4x$, the general form of our particular solution would be equivalent to $y_p = ax + b$. This means that $y_p^{\prime  } = a$ and $y_p^{\prime  } = 0$. We’ve learned in the past that the particular solution should be a solution to the differential equation, so substitute these expressions and solve for $a$ and $b$.

\begin{aligned}y^{\prime \prime}_p + 6y^{\prime}_p + 5y_p &= 4x\\0 + 6a + 5(ax +b) &= 4x\\5ax + (6a +b) &= 4x\\\\5a= 4, 6a &+b =0\\a = \dfrac{4}{5} ,b =& -\dfrac{24}{5}\end{aligned}

This means that $y_p = \dfrac{4}{5}x – \dfrac{24}{5}$.  Now that we have both components, $y_h$ and $y_p$, let’s complete the general solution of our second order non-homogeneous differential equation is:

\begin{aligned}y_h&= C_1 e^{-x} + C_2 e^{-5x} \\y_p&=\dfrac{4}{5}x – \dfrac{24}{5}\\\\ \boldsymbol{y(x)} &\boldsymbol{=} \boldsymbol{C_1 e^{-x} + C_2 e^{-5x}+\dfrac{4}{5}x – \dfrac{24}{5}} \end{aligned}

We’ve now shown you how the first method works, so let’s move on to our second technique: the method of variation of parameters.

Method of Variation Parameters

For more complex expressions for $g(x)$, it may be difficult to come up with a particular solution that we can easily use. When that happens, it is much better for us to apply the method of variation parameters, where we assume that the general and particular solution components have the same forms. Below are the guidelines to remember when using this method:

  • Find the expression for $y_h = C_1y_1 + C_2y_2$, using previous techniques.
  • Write down the particular solution, $y_p = ay_1 + by_2$, based on the form of $y_h$.
  • Set up the system of equations to solve for $a^{\prime}$ and $b^{\prime}$.

\begin{aligned}a^{\prime}y_1 + b^{\prime}y_2 &= 0\\a^{\prime}y_1^{\prime} + b^{\prime}y_2^{\prime} &= g(x) \end{aligned}

  • Integrate the resulting expressions for $a^{\prime}$ and $b^{\prime}$ to find $a$ and $b$.
  • Write down the general solution for the non-homogeneous differential equation: $y = y_h + y_p$.

These steps are straightforward but can be complex depending on the resulting expressions. Just apply the appropriate techniques learned in the past to find the solutions using variation of parameters. Our first example below shows how we can use this method to solve more interesting non-homogeneous differential equations.

Example 1

Find the general solution of the non-homogeneous differential equation, $y^{\prime\prime} +y = \tan x$.


Since we don’t have a guiding rule for $g(x) = \tan x$, we can’t use the method of undetermined coefficients. We can instead use the second method beginning with finding the general solution for the associated homogeneous equations. This means that the characteristic equation is equal to $r^2 + 1= 0 \rightarrow r = \pm i$, so the homogeneous solution is equal to

\begin{aligned}y_h = C_1\cos x + C_2 \sin x\end{aligned}

Using the form of $y_h$, let’s use the particular solution, $y_p = a\cos x +b\sin x$. Write down the system of linear equations:

\begin{aligned}a^{\prime}\cos x+ b^{\prime}\sin x &= 0\\-a^{\prime}\sin x+ b^{\prime}\cos x &= \tan x \end{aligned}

Apply the elimination method by multiplying appropriate factors then find $a$.

\begin{aligned}{\color{blue}\sin x}(a^{\prime}\cos x+ b^{\prime}\sin x) &= {\color{blue}\sin x}(0)\\ {\color{blue}\cos x}(-a^{\prime}\sin x+ b^{\prime}\cos x ) &= {\color{blue}\cos x}(\tan x)\\\\a^{\prime}\sin x\cos x + b^{\prime}\sin^2x&= 0\\-a^{\prime}\sin x\cos x + b^{\prime}\cos^2x&= \sin x \end{aligned}

Simplify the equation further and you should come up with $b^{\prime} = \cos x – \sec x $. This eventually leads to $a^{\prime} = -\dfrac{\sin^2 x}{\cos x} = \cos x – \sec x$. Integrate the expressions to find the constants for $y_p$.

\begin{aligned}\boldsymbol{a^{\prime} = \cos x – \sec x }\end{aligned}

\begin{aligned}\boldsymbol{\sin x}\end{aligned}

\begin{aligned} a^{\prime}  &= \int (\cos x – \sec x ) \phantom{x}dx\\&= \sin x – \ln |\sec x +\tan x|\end{aligned}

\begin{aligned} b^{\prime}  &= \int \sin x \phantom{x}dx\\&= -\cos x\end{aligned}

\begin{aligned} y_p &= a\cos x +b\sin x\\&= \cos x(\sin x – \ln |\sec x +\tan x|) + \sin x(-\cos x)\\&= -\cos x \ln |\sec x +\tan x|\end{aligned}

Combining the expressions for $y_h$ and $y_p$, we have $y = y_h + y_p = C_1\cos x + C_2 \sin x -\cos x \ln |\sec x +\tan x|$.

Example 2

Find the general solution of the non-homogeneous differential equation, $y^{\prime\prime\prime} + 6y^{\prime\prime} + 12y^{\prime} +8y = 4x$.


Our right-hand side this time is $g(x) = 4x$, so we can use the first method: undetermined coefficients. We begin by finding the general solution for the associated homogeneous equations, $ y^{\prime\prime\prime} + 6y^{\prime\prime} + 12y^{\prime} +8y = 0$. This type of third-order differential equation will have a general solution of $y_h=C_1e^{r_1x}+ C_2xe^{r_2x}+ C_3x^2e^{r_3x}$, where $\{r_1, r_2, r_3\}$ are roots of the characteristic equation.

\begin{aligned} y_h= C_1e^{-2x}+ C_2xe^{-2x}+ C_3x^2e^{-2x}\end{aligned}

Since the right-hand side of the equation is equal to $4x$, the particular solution, $y_p$ will have a general form of $ax + b$. This means that $y_p^{\prime} =a$ and $y_p^{\prime \prime} =0$.

\begin{aligned} y^{\prime\prime\prime} + 6y^{\prime\prime} + 12y^{\prime} + 8y &= 4x\\0 + 6(0) + 12a + 8(ax +b) &= 4x\\8ax + (12a +8b) &= 4x\\\\8a= 4 &\rightarrow a = \dfrac{1}{2}\\6+8b =0 &\rightarrow b=-\dfrac{3}{4}\end{aligned}

This means that we have the particular solution, $y_p = \dfrac{1}{2}x – \dfrac{3}{4}$. Combine the two components of our equation to find the general equation of the third order non-homogeneous differential equation.

\begin{aligned}y&= y_h + y_p\\&= C_1e^{-2x}+ C_2xe^{-2x}+ C_3x^2e^{-2x} +\dfrac{1}{2}x – \dfrac{3}{4}\end{aligned}

Practice Questions

1. Find the general solution of the non-homogeneous differential equation, $y^{\prime\prime} +y^{\prime}-6 = x^3$.
2. Find the general solution of the non-homogeneous differential equation, $y^{\prime\prime} -2y^{\prime} = \dfrac{e^x}{4x}$.
3. Find the general solution of the non-homogeneous differential equation, $ y^{\prime\prime\prime}+3y^{\prime\prime}+3y^{\prime} +y = 2x $.

Answer Key

1. $ y=C_1+C_2e^{-x}+ \dfrac{x^4}{4} -x^3+3x^2$
2.$ y= C_1e^x+C_2xe^x+ \dfrac{-e^xx+e^xx\ln \left(x\right)}{4}$
3.$ y=C_1e^{-x}+C_2xe^{-x}+C_3x^2e^{-x}+2x-6$

5/5 - (17 votes)
Previous Lesson

Second Order Homogeneous Differential Equation – Forms and Examples

Next Lesson

Homogeneous Differential Equation – Definition, Solutions, and Examples

We Create New Version

Coming Soon...