Second-Order Nonhomogeneous Equations

A homogeneous equation ay'' + by' + cy = 0 asks how a system moves when nobody is pushing it. Switch the right-hand side on — a forcing term g(x) — and you get the nonhomogeneous equation

a y'' + b y' + c y = g(x), \qquad a \neq 0.

This is the workhorse of physics: a mass on a spring being shaken, a circuit driven by a voltage, a building swayed by an earthquake. The remarkable fact is that you never solve it from scratch — you reuse the homogeneous answer and add one extra piece.

Why the answer splits in two

Suppose y_p is any one solution of the full equation — a particular solution — and y_h is the general solution of the matching homogeneous equation. We prove their sum is the general nonhomogeneous solution, using nothing but linearity. Write L[y] = a y'' + b y' + c y for the differential operator; it is linear, so L[u + v] = L[u] + L[v].

Step 1 — add the two pieces and apply the operator. Let y = y_h + y_p. By linearity,

L[y] = L[y_h + y_p] = L[y_h] + L[y_p].

Step 2 — evaluate each term. By assumption y_h solves the homogeneous equation, so L[y_h] = 0; and y_p solves the full equation, so L[y_p] = g(x). Hence

L[y] = 0 + g(x) = g(x),

so every y_h + y_p is indeed a solution.

Step 3 — show nothing is missed. Let Y be any solution of the full equation. Look at the difference Y - y_p and apply the operator:

L[Y - y_p] = L[Y] - L[y_p] = g(x) - g(x) = 0.

So Y - y_p solves the homogeneous equation — it is therefore some y_h — and rearranging gives Y = y_h + y_p. Every solution has this form, and we are done.

For a y'' + b y' + c y = g(x) with a \neq 0:

Worked example: y'' + y = x^2

We build the general solution of y'' + y = x^2 line by line.

Step 1 — solve the homogeneous part. The equation y'' + y = 0 has characteristic equation r^2 + 1 = 0, roots r = \pm i, so

y_h = C_1 \cos x + C_2 \sin x.

Step 2 — guess the form of y_p. The forcing g(x) = x^2 is a degree-2 polynomial, so try the most general degree-2 polynomial (no term of it sits in y_h, so no x-fix is needed):

y_p = Ax^2 + Bx + D.

Step 3 — differentiate the guess.

y_p' = 2Ax + B, \qquad y_p'' = 2A.

Step 4 — substitute into y'' + y = x^2.

y_p'' + y_p = 2A + (Ax^2 + Bx + D) = Ax^2 + Bx + (2A + D).

Step 5 — match coefficients of x^2, x^1, and x^0 with the right-hand side x^2 = 1\cdot x^2 + 0\cdot x + 0:

A = 1, \qquad B = 0, \qquad 2A + D = 0 \;\Rightarrow\; D = -2.

Step 6 — assemble. So y_p = x^2 - 2, and the general solution is the sum:

y = \underbrace{C_1 \cos x + C_2 \sin x}_{y_h} + \underbrace{x^2 - 2}_{y_p}.

Quick sanity check: y_p'' + y_p = 2 + (x^2 - 2) = x^2. It works.

Undetermined coefficients has one trap. Suppose the forcing pushes at the system's own natural frequency — say y'' + y = \cos x. The natural guess y_p = A\cos x + B\sin x is doomed: it already solves the homogeneous equation, so substituting gives L[y_p] = 0, never \cos x. There are no coefficients to find.

The fix is to multiply the trial form by x:

y_p = x\,(A\cos x + B\sin x).

Matching now gives y_p = \tfrac{1}{2}\,x\sin x — an oscillation whose amplitude grows without bound. That growing x-factor is resonance: a forcing tuned to the natural frequency feeds energy in every cycle, and the response climbs forever. It is the maths behind a wine glass shattering at the right note, soldiers breaking step on a bridge, and the Tacoma Narrows collapse. Whenever a trial term overlaps y_h, multiply by x (or x^2 if it overlaps a double root) before matching.

The driven oscillator: watch resonance build

Here is y'' + \omega_0^2\, y = \cos(\omega x) with natural frequency \omega_0 = 1, started from rest. The particular part is the steady-state response; the homogeneous part is the transient that keeps the initial conditions honest. Slide the forcing frequency \omega toward \omega_0 = 1 and watch the amplitude blow up — that spike at \omega = \omega_0 is resonance.