Nonhomogeneous equations and particular integrals

A homogeneous linear ODE only ever settles to zero on its right-hand side. The moment a real driving term f(x)f(x) — a polynomial force, an exponential input, a sinusoidal forcing — sits on the right, the complementary function ycy_c alone can no longer satisfy the equation, and a second ingredient, the particular integral (PI) ypy_p, must be added on top of it. This article picks up exactly where second-order constant-coefficient ODEs leave off. You already know how to find ycy_c from the auxiliary equation. Here the tool is the method of undetermined coefficients: guess a trial form matching f(x)f(x), substitute it into the ODE, and match coefficients — with one crucial twist, the resonance modification, whenever the trial form collides with ycy_c.

The core insight

For any(n)+⋯+a0y=f(x)a_ny^{(n)}+\cdots+a_0y=f(x), guess a trial ypy_p matching the type of f(x)f(x), multiply it by xx (or x2x^2) if it duplicates a term of ycy_c, then substitute and match coefficients to pin down ypy_p, so that y=yc+ypy=y_c+y_p solves the full equation.

The core idea

For a linear constant-coefficient ODE

any(n)+⋯+a1y′+a0y=f(x),a_n y^{(n)} + \cdots + a_1 y' + a_0 y = f(x),

the general solution splits into two pieces added together,

y=yc+yp,y = y_c + y_p,

where: ycy_c is the complementary function, the general solution of the associated homogeneous equation L[y]=0L[y]=0, and ypy_p is any single particular integral, one solution of the full nonhomogeneous equation L[y]=f(x)L[y]=f(x). This split works because the operator L[y]=any(n)+⋯+a0yL[y]=a_ny^{(n)}+\cdots+a_0y is linear, so L[yc+yp]=L[yc]+L[yp]=0+f(x)=f(x)L[y_c+y_p]=L[y_c]+L[y_p]=0+f(x)=f(x).

Choosing the trial form. For f(x)f(x) built from polynomials, exponentials ekxe^{kx}, or sin⁡kx\sin kx/cos⁡kx\cos kx (and products of these), the trial ypy_p has the same "shape" as f(x)f(x), with unknown coefficients to be found:

  • polynomial of degree kk →\to trial polynomial of degree kk (every lower-degree term included, even if f(x)f(x) is a pure power)
  • ekxe^{kx} →\to trial AekxAe^{kx}
  • sin⁡kx\sin kx or cos⁡kx\cos kx →\to trial Acos⁡kx+Bsin⁡kxA\cos kx + B\sin kx (both terms, even if only one appears in f(x)f(x))
  • epxsin⁡qxe^{px}\sin qx or epxcos⁡qxe^{px}\cos qx →\to trial epx(Acos⁡qx+Bsin⁡qx)e^{px}(A\cos qx + B\sin qx)

The resonance modification. If any term of the naive trial already appears in ycy_c — i.e. it duplicates a root of the auxiliary equation — substituting the naive trial gives an impossible equation (00 equals a nonzero constant). The fix is to multiply the entire trial by xx (or by x2x^2 if a single multiplication still duplicates ycy_c) before solving for coefficients. This is the one place students lose the most marks, and it is the subject of the derivation below.

Figure
Flowchart from a driving term f of x through trial selection resonance check and coefficient matching to the particular integral
Undetermined coefficients — the four-step recipe f(x) given pick matching trial y_p duplicates a term in y_c ? check the auxiliary roots yes: resonance multiply trial by x (or x^2) no: keep trial as is proceed directly substitute, match coefficients solve for y_p Final answer: y = y_c + y_p, complementary function plus particular integral, always added together.
Derivation AWhy a duplicate trial term forces multiplication by x

The goal is to show, with nothing beyond substitution and algebra, why a trial yp=Aekxy_p=Ae^{kx} fails whenever ekxe^{kx} already solves the homogeneous equation, and why multiplying the trial by xx repairs it — this is the resonance modification used every time the driving term f(x)f(x) shares a root with the auxiliary equation, and it is the step students forget most often.

Step 1. Set up the resonance case concretely. Take L[y]=y′′−4y=e2xL[y]=y''-4y=e^{2x}. The auxiliary equation is m2−4=0m^2-4=0, giving roots m=2,−2m=2,-2, so yc=C1e2x+C2e−2xy_c=C_1e^{2x}+C_2e^{-2x}. The driving term e2xe^{2x} matches the root m=2m=2 exactly — this is what "duplicates ycy_c" means.

Step 2. Try the naive trial and watch it collapse. If yp=Ae2xy_p=Ae^{2x}, then yp′′=4Ae2xy_p''=4Ae^{2x}, so L[yp]=yp′′−4yp=4Ae2x−4Ae2x=0L[y_p]=y_p''-4y_p=4Ae^{2x}-4Ae^{2x}=0 for every value of AA. Substituting into L[yp]=e2xL[y_p]=e^{2x} demands 0=e2x0=e^{2x}, an equation with no solution — the naive trial can never match the right-hand side, no matter how AA is chosen, because Ae2xAe^{2x} already solves the homogeneous equation and LL annihilates it.

Step 3. Multiply the trial by xx and retry. Let yp=Axe2xy_p=Axe^{2x}. Differentiating, yp′=Ae2x+2Axe2xy_p'=Ae^{2x}+2Axe^{2x} and yp′′=4Ae2x+4Axe2xy_p''=4Ae^{2x}+4Axe^{2x}. Then L[yp]=yp′′−4yp=(4Ae2x+4Axe2x)−4(Axe2x)=4Ae2xL[y_p]=y_p''-4y_p=(4Ae^{2x}+4Axe^{2x})-4(Axe^{2x})=4Ae^{2x}. The xe2xxe^{2x} terms have cancelled, leaving a clean nonzero multiple of e2xe^{2x} — exactly the shape needed to match the right-hand side.

Step 4. Match coefficients and read off the general pattern. Setting 4Ae2x=e2x4Ae^{2x}=e^{2x} gives A=14A=\tfrac14, so yp=14xe2xy_p=\tfrac14 xe^{2x} solves the equation exactly. The mechanism is general: multiplying by xx shifts the trial out of the null space of LL (the space of solutions of L[y]=0L[y]=0), so LL no longer annihilates it, and a genuine coefficient equation appears. If a single multiplication by xx still lands back in that null space (a repeated root duplicated twice), multiply by x2x^2 instead, for the same reason.

Worked example

Find the general solution of y′′−y′−2y=4x2y'' - y' - 2y = 4x^2, then use initial conditions y(0)=0y(0)=0, y′(0)=1y'(0)=1 to pin down a unique solution.

Step 1. Find the complementary function. The auxiliary equation is m2−m−2=0m^2-m-2=0, which factors as (m−2)(m+1)=0(m-2)(m+1)=0, giving m=2,−1m=2,-1. So yc=C1e2x+C2e−xy_c=C_1e^{2x}+C_2e^{-x}.

Step 2. Choose the trial PI. Since f(x)=4x2f(x)=4x^2 is a degree-2 polynomial, and no term of a polynomial trial duplicates ycy_c (which is built from exponentials), try yp=Ax2+Bx+Cy_p=Ax^2+Bx+C — all three terms, not just the leading one.

Step 3. Differentiate and substitute. With yp′=2Ax+By_p'=2Ax+B and yp′′=2Ay_p''=2A,

yp′′−yp′−2yp=2A−(2Ax+B)−2(Ax2+Bx+C)=−2Ax2+(−2A−2B)x+(2A−B−2C).y_p''-y_p'-2y_p = 2A-(2Ax+B)-2(Ax^2+Bx+C) = -2Ax^2+(-2A-2B)x+(2A-B-2C).

Step 4. Match coefficients against 4x2+0⋅x+04x^2+0\cdot x+0. From x2x^2: −2A=4⇒A=−2-2A=4\Rightarrow A=-2. From x1x^1: −2A−2B=0⇒4−2B=0⇒B=2-2A-2B=0\Rightarrow 4-2B=0\Rightarrow B=2. From x0x^0: 2A−B−2C=0⇒−4−2−2C=0⇒C=−32A-B-2C=0\Rightarrow -4-2-2C=0\Rightarrow C=-3. So yp=−2x2+2x−3y_p=-2x^2+2x-3, and the general solution is

y=C1e2x+C2e−x−2x2+2x−3.y = C_1e^{2x}+C_2e^{-x}-2x^2+2x-3.

Step 5. Apply the initial conditions to find C1,C2C_1,C_2. Differentiating, y′=2C1e2x−C2e−x−4x+2y'=2C_1e^{2x}-C_2e^{-x}-4x+2. At x=0x=0: y(0)=C1+C2−3=0⇒C1+C2=3y(0)=C_1+C_2-3=0\Rightarrow C_1+C_2=3, and y′(0)=2C1−C2+2=1⇒2C1−C2=−1y'(0)=2C_1-C_2+2=1\Rightarrow 2C_1-C_2=-1. Adding the two equations eliminates C2C_2: 3C1=2⇒C1=233C_1=2\Rightarrow C_1=\tfrac23, so C2=3−23=73C_2=3-\tfrac23=\tfrac73.

The particular solution is y=23e2x+73e−x−2x2+2x−3y=\dfrac{2}{3}e^{2x}+\dfrac{7}{3}e^{-x}-2x^2+2x-3.

Competitive stretch

Check the answer quickly at x=0x=0 without re-expanding: y(0)=23+73−3=93−3=0y(0)=\tfrac23+\tfrac73-3=\tfrac93-3=0 matches the given condition, confirming the algebra before trusting the full expression.

Common traps

  • Forgetting the resonance modification. If a trial term duplicates ycy_c, undetermined coefficients gives an impossible equation (0=0= nonzero) unless the trial is multiplied by xx (or x2x^2 for a doubly repeated root).
  • Using an incomplete trial polynomial. For f(x)f(x) a degree-kk polynomial, the trial must include every lower-degree term, Axk+⋯+CAx^k+\cdots+C, not just the leading power.
  • Dropping sine or cosine. When f(x)f(x) contains only sin⁡kx\sin kx (or only cos⁡kx\cos kx), the trial must still carry both Acos⁡kxA\cos kx and Bsin⁡kxB\sin kx, since differentiating one produces the other.
  • Losing ycy_c at the end. The final general solution is always y=yc+ypy=y_c+y_p; adding ycy_c into the trial itself, or forgetting to re-attach it, throws away the arbitrary constants the problem needs.

Ask the tutor: Not sure which trial form fits a mixed right-hand side like xe3xcos⁡2xxe^{3x}\cos 2x, or want your resonance check verified before you substitute? Ask the AI tutor to walk through the trial selection with you.

Why does multiplying the trial by x fix resonance instead of, say, adding a constant?

Multiplying by xx works because the trouble is that the original trial already satisfies the homogeneous equation, so the differential operator sends it straight to zero and it can never match a nonzero right-hand side. Multiplying by xx moves the trial outside that set of homogeneous solutions while keeping the same exponential or trigonometric "flavour," so the operator applied to it no longer vanishes identically — it leaves behind exactly the kind of term needed to match f(x)f(x). Adding a constant would not fix this, since constants (or other unrelated terms) do not track the structure of f(x)f(x) and would not survive coefficient matching correctly.

What if f(x) is a sum of two different types, like 4x squared plus e to the 2x?

Because the equation is linear, particular integrals add: find a particular integral yp1y_{p1} for the polynomial part and, separately, a particular integral yp2y_{p2} for the exponential part (checking each piece for resonance on its own), then take yp=yp1+yp2y_p=y_{p1}+y_{p2}. This is the same superposition idea that lets y=yc+ypy=y_c+y_p work in the first place, just applied one more time, splitting f(x)f(x) into pieces that are each easy to match with a trial.

Does it matter which particular solution I pick for y sub p, since the trial method could give different constants?

No — any correct ypy_p that satisfies the full nonhomogeneous equation works, because two different particular integrals for the same f(x)f(x) can only differ by a solution of the homogeneous equation, which is already absorbed into ycy_c's arbitrary constants. In practice the method of undetermined coefficients with a given trial form produces a unique ypy_p once the coefficients are matched, so this ambiguity rarely shows up — but it is why you never need to worry about "the wrong" particular integral, only whether your trial form was complete and resonance-checked.

Before this

Where this leads