In short
A second-order non-homogeneous ODE has the form ay'' + by' + cy = f(x), where f(x) \neq 0 is an external forcing term. The general solution is the sum of the complementary function (general solution of the homogeneous equation) and a particular integral (any one specific solution of the full equation). Two systematic methods — undetermined coefficients and variation of parameters — find that particular integral.
You push a child on a swing. Left to itself, the swing would oscillate and gradually slow down — that is the homogeneous equation, and you already know how to solve it. But you are pushing — applying a periodic external force. The swing now does something different: it settles into a steady rhythm that matches your push, superimposed on its natural oscillation.
The equation governing this is
The left side is the familiar homogeneous part (spring, friction). The right side — F\cos(\Omega t) — is the push. This right side is what makes the equation non-homogeneous.
You already know how to handle the left side. This article is about the right side: how to find a solution that accounts for the external forcing.
The structure of the solution
Here is the key structural fact. Suppose you have
and you somehow find one particular solution y_p(x) — any function at all that, when plugged into the left side, produces f(x).
Now take any solution y_h(x) of the homogeneous equation ay'' + by' + cy = 0. Then y_p + y_h is also a solution of the non-homogeneous equation, because
The linearity of differentiation makes the two parts separate cleanly.
General solution of a non-homogeneous ODE
The general solution of ay'' + by' + cy = f(x) is
where y_h = c_1 y_1 + c_2 y_2 is the complementary function (general solution of the associated homogeneous equation ay'' + by' + cy = 0) and y_p is any particular integral of the non-homogeneous equation.
The complementary function y_h handles the natural behaviour of the system (oscillation, growth, decay). The particular integral y_p handles the external forcing. Together, they capture everything.
Finding y_h is the subject of the previous article — use the characteristic equation. The new task here is finding y_p. Two methods do this: undetermined coefficients (fast, when it applies) and variation of parameters (always works, but heavier).
Method 1: Undetermined coefficients
The idea is simple: guess the form of y_p based on the form of f(x), with unknown constants, then determine those constants by substituting back into the ODE.
This works when f(x) belongs to a family of functions that reproduce their own form under differentiation — polynomials, exponentials, sines, cosines, and products of these. The table below shows the standard guesses.
| f(x) | Trial y_p |
|---|---|
| ke^{\alpha x} | Ae^{\alpha x} |
| kx^n (polynomial of degree n) | A_0 + A_1 x + \cdots + A_n x^n |
| k\cos\beta x or k\sin\beta x | A\cos\beta x + B\sin\beta x |
| ke^{\alpha x}\cos\beta x | e^{\alpha x}(A\cos\beta x + B\sin\beta x) |
| k x^n e^{\alpha x} | e^{\alpha x}(A_0 + A_1 x + \cdots + A_n x^n) |
There is one important caveat: if your trial y_p is already a solution of the homogeneous equation (i.e., it appears in y_h), it will produce 0 on the left side, not f(x). In that case, multiply the trial by x (or x^2 if the root is repeated). This is called the modification rule.
The method is best shown by example.
Example 1: Undetermined coefficients — y'' − 3y' + 2y = 4e^(5x)
Step 1. Find the complementary function. The characteristic equation is m^2 - 3m + 2 = 0, which factors as (m-1)(m-2) = 0. Roots: m = 1, 2. So y_h = c_1 e^x + c_2 e^{2x}.
Why: you always need y_h first — the general solution is y_h + y_p.
Step 2. Guess the form of y_p. Since f(x) = 4e^{5x}, try y_p = Ae^{5x}. Check: e^{5x} is not part of y_h (m = 5 is not a root of the characteristic equation), so no modification is needed.
Why: the trial mirrors the form of f(x). If 5 had been a root, you would need Axe^{5x} instead.
Step 3. Substitute y_p = Ae^{5x} into the ODE. Compute y_p' = 5Ae^{5x}, y_p'' = 25Ae^{5x}.
Why: after substitution, e^{5x} cancels from both sides (it is never zero), leaving a simple equation in A.
Step 4. Write the particular integral and the general solution:
Why: the general solution is always y_h + y_p.
Result: y = c_1 e^x + c_2 e^{2x} + \frac{1}{3}e^{5x}.
Notice how the particular integral \frac{1}{3}e^{5x} captures the effect of the forcing term 4e^{5x}. The complementary function handles the system's natural exponential behaviour; the particular integral handles the external push.
When the modification rule kicks in
Consider y'' - 3y' + 2y = 5e^{2x}. The complementary function is the same: y_h = c_1 e^x + c_2 e^{2x}. But now f(x) = 5e^{2x}, and e^{2x} already appears in y_h — because m = 2 is a root of the characteristic equation.
If you naively try y_p = Ae^{2x}, substituting gives A(4 - 6 + 2)e^{2x} = 0 for all A — you get 0, not 5e^{2x}. The guess fails.
The fix: multiply by x. Try y_p = Axe^{2x}. Compute:
Substitute: A(4+4x)e^{2x} - 3A(1+2x)e^{2x} + 2A \cdot x e^{2x} = Ae^{2x}(4 + 4x - 3 - 6x + 2x) = Ae^{2x}(1) = 5e^{2x}.
So A = 5, and y_p = 5xe^{2x}.
The rule extends: if m = 2 were a double root, you would need Ax^2 e^{2x}.
Method 2: Variation of parameters
Undetermined coefficients is fast but limited — it only works when f(x) is a polynomial, exponential, sine, cosine, or a product of these. What if f(x) = \tan x, or f(x) = 1/x, or some other function that does not neatly reproduce itself under differentiation?
Variation of parameters handles any f(x), with no restriction on its form.
The idea: start with the complementary function y_h = c_1 y_1 + c_2 y_2, then let the "constants" c_1, c_2 become functions of x — hence "variation of parameters." You look for a particular solution of the form
where u_1 and u_2 are unknown functions to be determined. Substituting into the ODE and imposing a simplifying condition leads to the formulas:
where W = y_1 y_2' - y_2 y_1' is the Wronskian of y_1 and y_2.
The simplifying condition that makes this work is u_1' y_1 + u_2' y_2 = 0 — this is imposed deliberately so that y_p' does not contain u_1'' or u_2'', which would make the system intractable. With this condition, the two equations for u_1' and u_2' are a simple 2 \times 2 linear system, solved by the Wronskian.
Example 2: Variation of parameters — y'' + y = sec x
Step 1. Find the complementary function. The characteristic equation is m^2 + 1 = 0, giving m = \pm i. So y_1 = \cos x, y_2 = \sin x, and y_h = c_1 \cos x + c_2 \sin x.
Why: complex roots \pm i with \alpha = 0 and \beta = 1 give pure oscillation.
Step 2. Compute the Wronskian.
Why: for \cos x and \sin x, the Wronskian simplifies beautifully to 1 via the Pythagorean identity.
Step 3. Find u_1' and u_2'. Here f(x) = \sec x and a = 1.
Why: the Wronskian being 1 makes the formulas especially clean here.
Step 4. Integrate to find u_1 and u_2.
Why: \int \tan x\, dx = -\ln|\cos x|, so u_1 = \ln|\cos x|. The constants of integration are absorbed into y_h.
Step 5. Write the particular integral:
And the general solution:
Why: combining y_h + y_p gives the complete answer.
Result: y = c_1 \cos x + c_2 \sin x + \cos x \ln|\cos x| + x\sin x.
This is a problem where undetermined coefficients would fail — there is no finite table entry for \sec x, since \sec x does not reproduce itself neatly under differentiation. Variation of parameters handles it without special cases.
Choosing between the two methods
The choice is straightforward:
- Undetermined coefficients when f(x) is a polynomial, exponential, sine/cosine, or a product of these. It is faster, less error-prone, and gives cleaner algebra.
- Variation of parameters when f(x) is anything else (\sec x, \tan x, \ln x, 1/x, etc.), or when you want a method that works universally and don't mind the integration.
In practice, most textbook problems use undetermined coefficients. Variation of parameters is the safety net — the method that never refuses a problem.
Handling sums of forcing terms
If f(x) = f_1(x) + f_2(x), you can find particular integrals y_{p_1} and y_{p_2} separately for each piece and add them. This works because the equation is linear:
Adding: a(y_{p_1}+y_{p_2})'' + b(y_{p_1}+y_{p_2})' + c(y_{p_1}+y_{p_2}) = f_1(x) + f_2(x).
So for y'' - 3y' + 2y = 4e^{5x} + 3\sin x, you would find the particular integral for 4e^{5x} (as in Example 1: \frac{1}{3}e^{5x}) and then separately for 3\sin x, and add them.
For 3\sin x, try y_p = A\cos x + B\sin x. Substituting gives
Collecting: (A - 3B)\cos x + (3A + B)\sin x = 3\sin x
So A - 3B = 0 and 3A + B = 3. From the first equation A = 3B; substituting into the second: 9B + B = 3, giving B = 3/10 and A = 9/10.
The combined particular integral is \frac{1}{3}e^{5x} + \frac{9}{10}\cos x + \frac{3}{10}\sin x.
Common confusions
-
"The particular integral must be unique." It is unique up to homogeneous solutions. If y_p is one particular integral, then y_p + c_1 y_1 + c_2 y_2 is another. But the general solution y_h + y_p is the same in both cases — the extra homogeneous terms get absorbed into c_1 and c_2.
-
"I should include the complementary function when testing my trial for undetermined coefficients." The test is simpler: just check whether the trial function satisfies the homogeneous equation. If y_p = Ae^{2x} and e^{2x} is a solution of the homogeneous equation, the trial needs modification. You do not need to consider coefficients.
-
"Variation of parameters requires the equation to be in the form y'' + py' + qy = f(x)." True — the standard formulas assume the coefficient of y'' is 1. If it is not, divide through by a first. This is a common source of errors: if the original equation is 2y'' + y' - y = e^x, divide everything by 2 to get y'' + \frac{1}{2}y' - \frac{1}{2}y = \frac{1}{2}e^x before applying the formulas.
-
"I forgot the modification rule and got 0 = f(x)." This is the classic sign. If your substitution produces 0 on the left regardless of A, it means your trial is already a homogeneous solution. Multiply by x and try again.
-
"For f(x) = \cos x, I only need y_p = A\cos x." You need both: y_p = A\cos x + B\sin x. Differentiation mixes sines and cosines, so both must appear in the trial.
Going deeper
If you can use undetermined coefficients and variation of parameters on standard problems, you have the working tools. The rest is for readers who want to see the formal derivation and the operator-theoretic perspective.
Deriving the variation of parameters formulas
Start with y_p = u_1 y_1 + u_2 y_2. Differentiate:
Impose the condition u_1' y_1 + u_2' y_2 = 0. This is a choice, not a consequence — you are free to impose one condition because you have two unknown functions but only one equation. With this condition:
Differentiate again:
Now substitute y_p, y_p', y_p'' into y'' + py' + qy = f(x) (assuming a = 1):
Regroup:
The bracketed terms vanish because y_1 and y_2 are solutions of the homogeneous equation. What remains is:
Together with the condition u_1' y_1 + u_2' y_2 = 0, you have a 2 \times 2 system in u_1' and u_2':
Solving by Cramer's rule (or elimination):
where W = y_1 y_2' - y_2 y_1' is the Wronskian. These are exactly the formulas used in Example 2.
The operator method (D-operator)
For undetermined coefficients with exponential and polynomial forcing, there is a slick shortcut using the operator D = d/dx. Write the ODE as p(D)y = f(x), where p(D) = aD^2 + bD + c. Then formally,
The symbol 1/p(D) is the inverse operator. It is not a function you can always evaluate directly, but it obeys useful rules:
- \dfrac{1}{p(D)}e^{\alpha x} = \dfrac{e^{\alpha x}}{p(\alpha)} when p(\alpha) \neq 0
- \dfrac{1}{p(D)}\sin\beta x = \dfrac{\sin\beta x}{p(-\beta^2)} (replacing D^2 by -\beta^2 in the polynomial)
These rules reproduce the undetermined coefficients results instantly, without setting up and solving a system. They are widely used in Indian competitive exam preparation.
Where this leads next
With both homogeneous and non-homogeneous second-order equations in hand, you can tackle the physical and geometric problems that motivated differential equations in the first place.
- Applications of DE — growth, decay, cooling, population models, and curves with prescribed slope properties.
- Orthogonal and Isogonal Trajectories — families of curves that cross at specified angles.
- Second Order Homogeneous — the prerequisite: the characteristic equation and the three cases.
- Higher Order Derivatives — the derivatives that appear in these equations.
- Quadratic Equations — the algebra behind every characteristic equation.