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

y'' + 2\gamma y' + \omega^2 y = F\cos(\Omega t)

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

ay'' + by' + cy = f(x)

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

a(y_p + y_h)'' + b(y_p + y_h)' + c(y_p + y_h) = \underbrace{(ay_p'' + by_p' + cy_p)}_{= f(x)} + \underbrace{(ay_h'' + by_h' + cy_h)}_{= 0} = f(x)

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

y = y_h + y_p

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}.

25Ae^{5x} - 3(5Ae^{5x}) + 2(Ae^{5x}) = 4e^{5x}
(25A - 15A + 2A)e^{5x} = 4e^{5x}
12A = 4 \implies A = \frac{1}{3}

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:

y_p = \frac{1}{3}e^{5x}
y = c_1 e^x + c_2 e^{2x} + \frac{1}{3}e^{5x}

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}.

The dashed curves are the complementary function's components $e^x$ and $e^{2x}$. The dotted curve is the particular integral $\frac{1}{3}e^{5x}$. The solid red curve is one specific solution with $c_1 = 1, c_2 = -1$ — the particular integral eventually dominates because $e^{5x}$ grows fastest.

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:

y_p' = A(1 + 2x)e^{2x}, \quad y_p'' = A(4 + 4x)e^{2x}

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

y_p = u_1(x)\,y_1(x) + u_2(x)\,y_2(x)

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:

u_1' = -\frac{y_2 \cdot f(x)}{a \cdot W}, \qquad u_2' = \frac{y_1 \cdot f(x)}{a \cdot W}

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.

W = y_1 y_2' - y_2 y_1' = \cos x \cdot \cos x - \sin x \cdot (-\sin x) = \cos^2 x + \sin^2 x = 1

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.

u_1' = -\frac{\sin x \cdot \sec x}{1} = -\frac{\sin x}{\cos x} = -\tan x
u_2' = \frac{\cos x \cdot \sec x}{1} = \frac{\cos x}{\cos x} = 1

Why: the Wronskian being 1 makes the formulas especially clean here.

Step 4. Integrate to find u_1 and u_2.

u_1 = -\int \tan x\, dx = \ln|\cos x|
u_2 = \int 1\, dx = x

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:

y_p = \cos x \cdot \ln|\cos x| + x\sin x

And the general solution:

y = c_1 \cos x + c_2 \sin x + \cos x \cdot \ln|\cos x| + x\sin x

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.

The dashed curves are $\cos x$ and $\sin x$ (the complementary function's components). The solid red curve is the particular integral $\cos x \ln|\cos x| + x\sin x$. Notice how the $x\sin x$ term causes the amplitude to grow linearly — the system's response to $\sec x$ forcing is not bounded.

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:

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:

ay_{p_1}'' + by_{p_1}' + cy_{p_1} = f_1(x)
ay_{p_2}'' + by_{p_2}' + cy_{p_2} = f_2(x)

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

-A\cos x - B\sin x - 3(-A\sin x + B\cos x) + 2(A\cos x + B\sin x) = 3\sin x

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

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:

y_p' = u_1' y_1 + u_1 y_1' + u_2' y_2 + u_2 y_2'

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:

y_p' = u_1 y_1' + u_2 y_2'

Differentiate again:

y_p'' = u_1' y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2''

Now substitute y_p, y_p', y_p'' into y'' + py' + qy = f(x) (assuming a = 1):

u_1'y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2'' + p(u_1 y_1' + u_2 y_2') + q(u_1 y_1 + u_2 y_2) = f(x)

Regroup:

u_1(\underbrace{y_1'' + py_1' + qy_1}_{= 0}) + u_2(\underbrace{y_2'' + py_2' + qy_2}_{= 0}) + u_1' y_1' + u_2' y_2' = f(x)

The bracketed terms vanish because y_1 and y_2 are solutions of the homogeneous equation. What remains is:

u_1' y_1' + u_2' y_2' = f(x)

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':

\begin{cases} u_1' y_1 + u_2' y_2 = 0 \\ u_1' y_1' + u_2' y_2' = f(x) \end{cases}

Solving by Cramer's rule (or elimination):

u_1' = \frac{-y_2 f(x)}{W}, \qquad u_2' = \frac{y_1 f(x)}{W}

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,

y_p = \frac{1}{p(D)}f(x)

The symbol 1/p(D) is the inverse operator. It is not a function you can always evaluate directly, but it obeys useful rules:

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.