15. Linear non-homogeneous second-order ODEs.(Constant Coefficients)
5 min • 10/19/2026
D
Dulasha
In this article, we focus exclusively on constant-coefficient ordinary differential equations, highlighting their significance.
In the previous article, we explored second-order homogeneous ODEs, providing the tools to solve complex problems. In this article, we'll shift our focus to nonhomogeneous equations, delving into them with detailed explanations, questions, and answers.
The general solution of a second-order non-homogeneous linear differential equation with constant coefficients can be expressed as:
y'' + a_1y' + a_2y = f(x)
y = y_c + y_p
where y_p is any specific function that satisfies the non-homogeneous equation, and y_c = C_1y_1 + C_2y_2 is the general solution of the corresponding homogeneous equation: y'' + a_1y' + a_2y = 0.
Here, y_c = C_1y_1 + C_2y_2 is called the complementary solution (or homogeneous solution), and y_p is called the particular solution (or non-homogeneous solution) of the equation
1. Method of Undetermined Coefficients
The particular solution is typically found through substitution, with the form depending on the nature of the differential equation. While these forms are effective in many cases, they may not always be sufficient.
Here are the most common scenarios:
- If f(x) = k (a constant), we try y_p = c.
- If f(x) = kx, we try y_p = ax + b.
- If f(x) = kx^2, we try y_p = ax^2 + bx + c, and so on for higher powers of x.
- If f(x) = k\sin x or k\cos x, we try y_p = a\sin x + b\cos x.
- If f(x) = e^{kx}, we try y_p = ce^{kx}. This method works provided that k is not a root of the homogeneous equation’s characteristic equation. Otherwise, a modified approach is necessary.
1.1. Forcing Functions and Undetermined Coefficients
The method of undetermined coefficients works best when the forcing function (the non-homogeneous term on the right-hand side of a differential equation) belongs to a certain class of functions. These functions are typically of the following types:
For the homogeneous equation y'' + a_1y' + a_2y = 0, the characteristic equation is r^2 + a_1r + a_2 = 0.
2. Find the Roots:
Solve the characteristic equation to find the roots, which determine the nature of the complementary solution y_c.
The reader can refer to the previous article to gain better insight on Linear non-homogeneous second-order ODEs(Constant Coefficients).
There are three possible scenarios based on the roots:
- Distinct real roots: If the roots r_1 and r_2 are real and distinct, the complementary solution is y_c = C_1e^{r_1x} + C_2e^{r_2x}.
- Repeated real root: If the root is repeated, say r_1 = r_2 = r, the complementary solution takes the form y_c = (C_1 + C_2x)e^{rx}.
- Complex conjugate roots: If the roots are complex, say r_1, r_2 = \alpha \pm \beta i, the complementary solution is y_c = e^{\alpha x}(C_1\cos(\beta x) + C_2\sin(\beta x)).
1.3. Particular Solution and Forcing Functions
Once the characteristic roots are determined, the form of the particular solution y_p(x) is influenced by the forcing function f(x). If f(x) contains terms that correspond to solutions of the homogeneous equation, adjustments to the trial solution are required.
For example:
- If f(x) = e^{kx} and k is not a root of the characteristic equation, the trial solution y_p = ce^{kx} works.
- If f(x) = e^{kx} and k is a root, we modify the trial solution to y_p = x^n e^{kx}, where n is the multiplicity of k as a root.
1.4. Problem Solving: Method of Undetermined Coefficients
1. Solve the Complementary Equation:
- Begin by solving the corresponding homogeneous equation. This involves finding the roots of the characteristic equation and writing the general form of the complementary solution y_c(x).
2. Formulate the Particular Solution y_p(x):
- Analyze the form of the non-homogeneous term f(x) and determine an appropriate form for the particular solution y_p(x).
3. Check for Overlap with the Complementary Solution:
- If any part of the proposed particular solution y_p(x) appears in the complementary solution y_c(x), modify the form of y_p(x) by multiplying by powers of x.
4. Determine the Coefficients:
- Substitute the proposed form of y_p(x) into the original differential equation. This results in a system of equations that you can solve to find the unknown coefficients.
5. Write the General Solution:
- Combine the complementary solution y_c(x) and the particular solution y_p(x) to obtain the complete general solution to the non-homogeneous equation.
y'' - y = 0 \quad \Rightarrow \quad m^2 - 1 = 0 \quad \Rightarrow \quad m = \pm 1
Homogeneous solution:
y_c = C_1 e^x + C_2 e^{-x}
2. Particular Solution:
Since f(x) = x^2, y_p = Ax^2 + Bx + C.
Derivatives:
y_p' = 2Ax + B, \quad y_p'' = 2A
Substitute into the equation:
2A - (Ax^2 + Bx + C) = x^2
Simplify:
(-A)x^2 + (-B)x + (2A - C) = x^2
Equate coefficients:
-A = 1, \quad -B = 0, \quad 2A - C = 0
Solve:
A = -1, \quad B = 0, \quad C = -2
y_p = -x^2 - 2
3. General Solution:
y = y_c + y_p = C_1 e^x + C_2 e^{-x} - x^2 - 2
Now we will see how to solve when the special case of overlap happens:
2.3. Example 3: Non-Homogeneous Equation with Multiplicity 1
\frac{d^2y}{dx^2} + y = \sin(x)
1. Solve the Homogeneous Equation:
y'' + y = 0
- Characteristic Equation:
m^2 + 1 = 0
- Roots:
m = \pm i
- General Solution of the Homogeneous Equation:
y_c = C_1 \cos x + C_2 \sin x
2. Formulate a Particular Solution y_p(x):
Since the non-homogeneous term f(x) = \sin x is already part of the complementary solution, we directly adjust our particular solution to account for this overlap by multiplying by x:
y_p = x(A \sin x + B \cos x)
3. Compute Derivatives:
- First derivative:
y_p' = A \sin x + B \cos x + x(A \cos x - B \sin x)
- Second derivative:
y_p'' = 2A \cos x - 2B \sin x - x(A \sin x + B \cos x)
4. Substitute into the Differential Equation:
Substituting y_p and its derivatives into the original differential equation gives: and its derivatives into the original differential equation gives:
(2A \cos x - 2B \sin x - x(A \sin x + B \cos x)) + x(A \sin x + B \cos x) = \sin x
This simplifies to:
2A \cos x - 2B \sin x = \sin x
5. Equate Coefficients:
- Coefficient of \cos x:
2A = 0 \quad \Rightarrow \quad A = 0
- Coefficient of \sin x:
-2B = 1 \quad \Rightarrow \quad B = -\frac{1}{2}
6. Particular Solution:
Thus, the particular solution is:
y_p = -\frac{1}{2} x \cos x
7. Write the General Solution:
Combine the complementary solution and the particular solution:
y = y_c + y_p
The general solution is:
y = C_1 \cos x + C_2 \sin x - \frac{1}{2} x \cos x
2.4. Example 4: Non-Homogeneous Equation with Multiplicity 2
Differential Equation:
y'' + 4y' + 4y = e^{-2x}
First, we solve the associated homogeneous equation:
The non-homogeneous term is e^{-2x}. Since this term is part of the complementary solution (with multiplicity 2), we need to multiply our guess for the particular solution by x^2.
Particular Solution:
Thus, we assume a particular solution of the form.
y_p = Ax^2 e^{-2x}
Derivative:
y_p' = \frac{d}{dx} \left( A x^2 e^{-2x} \right) = A \left( 2x e^{-2x} - 2x^2 e^{-2x} \right) = A \left( 2x - 2x^2 \right) e^{-2x}
The non-homogeneous equation y'' - 4y = x^2 e^{2x} has a complementary solution with multiplicity 1 for e^{2x}.
The non-homogeneous equation y'' + 4y' + 4y = e^{-2x} also has a complementary solution with multiplicity 2 for e^{-2x}.
2.5. Example 5
\frac{d^2y}{dx^2} + 4y = 3\sin(2x)
1. Solve the Homogeneous Equation
\frac{d^2y}{dx^2} + 4y = 0
This is a second-order linear equation with constant coefficients. The characteristic equation is:
m^2 + 4 = 0
Solving for m
m = \pm 2i
This gives a solution for the homogeneous equation:
y_c = C_1 \cos(2x) + C_2 \sin(2x)
2. Find the Particular Solution
Now, for the non-homogeneous equation:
\frac{d^2y}{dx^2} + 4y = 3\sin(2x)
Since the forcing function 3 \sin(2x) is of the same form as the solution to the homogeneous equation, we multiply it by x for the particular solution.
y_p = x(A \cos(2x) + B \sin(2x))
Now, find the first and second derivatives of y_p:
y_p' = A \cos(2x) - 2Ax \sin(2x) + B \sin(2x) + 2Bx \cos(2x)
Thus, the general solution of the homogeneous equation is:
y_c = C_1 e^x + C_2 e^{3x}
2. Particular Solution
Since f(x) = e^{x} is part of the complementary solution, we adjust a particular solution of the form:
y_p = A x e^x
Calculating the derivatives:
y_p' = A e^x + A x e^x
y_p'' = A e^x + A e^x + A x e^x = 2A e^x + A x e^x
Substituting y_p, y_p', and y_p'' into the original equation:
(2A e^x + A x e^x) - 4(A e^x + A x e^x) + 3(A x e^x) = e^x
Simplifying the left-hand side:
(2A e^x + A x e^x) - (4A e^x + 4A x e^x) + 3A x e^x
Combine like terms:
(2A - 4A)e^x + (A - 4A + 3A)x e^x = e^x
(-2A)e^x + 0 \cdot x e^x = e^x
Setting coefficients equal:
-2A = 1 \quad \Rightarrow \quad A = -\frac{1}{2}
Thus, the particular solution is:
y_p = -\frac{1}{2} x e^x
3. General Solution
y = y_c + y_p = C_1 e^x + C_2 e^{3x} - \frac{1}{2} x e^x
2.10. Example 10
y'' + y = e^{3x}
Solution:
1. Solve the Homogeneous Equation:
y'' + y = 0 \quad \Rightarrow \quad m^2 + 1 = 0 \quad \Rightarrow \quad m = \pm i
Complementary solution:
y_c = C_1 \cos x + C_2 \sin x
2. Particular Solution:
Since f(x) = e^{3x}, y_p = A e^{3x}.
Derivatives:
y_p' = 3A e^{3x}, \quad y_p'' = 9A e^{3x}
Substitute into the equation:
9A e^{3x} + A e^{3x} = e^{3x}
Simplify:
10A = 1 \quad \Rightarrow \quad A = \frac{1}{10}
y_p = \frac{1}{10}e^{3x}
3. General Solution:
y = y_c + y_p = C_1 \cos x + C_2 \sin x + \frac{1}{10}e^{3x}
2.11. Example 11
Let’s solve the second-order differential equation correctly:
y'' + 4y = \cos(2x)
Step 1: Solve the Homogeneous Equation
The homogeneous equation is:
y'' + 4y = 0
The characteristic equation is:
m^2 + 4 = 0
Solving for m, we get:
m = \pm 2i
Thus, the solution to the homogeneous equation is:
y_c = C_1 \cos(2x) + C_2 \sin(2x)
Step 2: Find the Particular Solution
Since the non-homogeneous term is \cos(2x), and the homogeneous solution already contains terms involving \cos(2x) and \sin(2x), we need to modify the form of the particular solution by multiplying by x.
Remember, the key to success in ODEs is practice and persistence. The examples and practice problems provided here are just the beginning—keep solving more problems to strengthen your understanding.
Stay tuned as we continue to build on our understanding of differential equations.
15. Linear non-homogeneous second-order ODEs.(Constant Coefficients)