How to Solve a Nonhomogeneous Differential Equation: 3 Methods

The general solution to a nonhomogeneous differential equation has two parts: the solution to the corresponding homogeneous equation (called the complementary solution) plus any single particular solution that satisfies the nonhomogeneous equation. In notation, that’s y = y_h + y_p. Every method for solving these equations follows this same structure, so understanding it is the key to everything else.

The nonhomogeneous part is the term that makes the equation “unbalanced,” the function on the right side of the equals sign that isn’t zero. In physics, this represents an external force acting on a system, like a vibrating motor attached to a spring. The complementary solution describes what the system does on its own; the particular solution captures the system’s response to that outside push.

Step 1: Solve the Homogeneous Equation First

Before finding the particular solution, you need the complementary solution y_h. Set the right-hand side of your equation to zero and solve the resulting homogeneous equation. For a second-order equation with constant coefficients, this means finding the characteristic equation, solving for its roots, and writing the general homogeneous solution from those roots.

For example, given y” + 5y’ + 6y = 3e^(2t), you’d first solve y” + 5y’ + 6y = 0. The characteristic equation r² + 5r + 6 = 0 factors to (r + 2)(r + 3) = 0, giving roots r = -2 and r = -3. So y_h = C₁e^(-2t) + C₂e^(-3t). This complementary solution is essential because it tells you the form of all solutions to the homogeneous version, and you’ll need it to build the complete answer.

Step 2: Find a Particular Solution

This is where you have a choice of method. You only need one particular solution, not a family of them. No arbitrary constants here. The two main approaches are undetermined coefficients and variation of parameters, and they have different strengths.

Method 1: Undetermined Coefficients

This is the faster method when it applies. It works when your equation has constant coefficients and the nonhomogeneous term (the right-hand side) is a polynomial, an exponential, a sine or cosine, or a combination of these. If the right-hand side is something messier, like tan(t) or 1/t, this method won’t work.

The idea is to guess the form of the particular solution based on what the right-hand side looks like, plug that guess into the equation, and solve for the unknown coefficients. Here are the standard guesses:

  • Exponential ae^(βt): Guess y_p = Ae^(βt)
  • Sine or cosine (or both): Guess y_p = A·cos(βt) + B·sin(βt). Always include both sine and cosine, even if only one appears on the right side.
  • Polynomial of degree n: Guess a full polynomial of the same degree. For a cubic like 4t³ + t, guess y_p = At³ + Bt² + Ct + D. Include every term down to the constant, even if some are missing from the original.
  • Products: If the right side is something like t²e^(3t), your guess is the product of the corresponding forms: (At² + Bt + C)e^(3t).

Once you have your guess, substitute it into the differential equation, collect like terms, and set coefficients equal on both sides. This gives you a system of algebra equations to solve for A, B, C, and so on.

The Duplication Rule

There’s one critical catch. If any term in your guess already appears in the complementary solution y_h, the guess won’t work as written because plugging it in will produce zero on the left side. When this happens, multiply your entire guess by t^n, where n is the smallest positive integer that eliminates the overlap.

For instance, if y_h = C₁e^(2t) + C₂e^(-t) and the right-hand side is 5e^(2t), your natural guess would be Ae^(2t). But that duplicates the e^(2t) already in y_h. So you multiply by t and guess y_p = Ate^(2t) instead. If that still duplicates (which can happen with repeated roots), multiply by t again to get At²e^(2t).

Method 2: Variation of Parameters

This method is more general. It works for any nonhomogeneous term, not just the neat exponential/polynomial/trig forms that undetermined coefficients requires. It also handles equations with non-constant coefficients. The trade-off is that it requires you to evaluate integrals, and those integrals can sometimes be difficult or impossible to solve in closed form.

The setup starts with your complementary solution. Say y_h = C₁y₁(t) + C₂y₂(t). Instead of using constants C₁ and C₂, you replace them with unknown functions u₁(t) and u₂(t), then solve for those functions. The particular solution takes the form y_p = u₁y₁ + u₂y₂.

For a second-order equation y” + p(t)y’ + q(t)y = f(t), the formulas for u₁ and u₂ are:

u₁(t) = ∫ [-y₂(t)·f(t) / W(t)] dt

u₂(t) = ∫ [y₁(t)·f(t) / W(t)] dt

Here W(t) is the Wronskian, calculated as y₁·y₂’ – y₂·y₁’. It’s a determinant that measures whether your two homogeneous solutions are truly independent (if W = 0, something went wrong earlier).

The practical steps: compute the Wronskian from y₁ and y₂, plug everything into the two integral formulas, evaluate the integrals, then assemble y_p = u₁y₁ + u₂y₂. Finally, the general solution is y = y_h + y_p.

Method 3: Laplace Transforms

Laplace transforms take a completely different approach. Instead of guessing or integrating, you transform the entire differential equation into an algebraic equation, solve that algebraic equation, then transform back. This method is especially convenient for initial value problems because the initial conditions get built into the process automatically rather than applied at the end.

The steps are: take the Laplace transform of every term in the equation, substitute in your initial conditions (which appear naturally when transforming derivatives), solve the resulting algebraic equation for Y(s), then use inverse Laplace transforms (often with partial fractions) to convert back to y(t).

For example, transforming y” – 10y’ + 9y = 5t with known initial values turns the whole thing into an equation in s and Y(s): s²Y(s) – sy(0) – y'(0) – 10(sY(s) – y(0)) + 9Y(s) = 5/s². From here it’s algebra, not calculus. You isolate Y(s), decompose it with partial fractions, and invert each term.

Which Method Should You Use

Undetermined coefficients is the fastest option when it’s available. If your equation has constant coefficients and the right-hand side is built from polynomials, exponentials, sines, and cosines, start here. The algebra can get tedious for complicated right-hand sides, but the process is mechanical and predictable.

Variation of parameters handles everything undetermined coefficients can’t. If the right-hand side involves tan(t), sec(t), ln(t), 1/t, or any function outside the standard list, this is your method. It also works when the coefficients of the differential equation aren’t constants. The downside is that the required integrals may not have clean closed-form answers.

Laplace transforms are ideal for initial value problems, especially when the forcing function involves step functions, impulses, or piecewise-defined inputs. If you’re given specific initial conditions and want the complete specific solution in one pass, Laplace transforms fold everything together efficiently.

A Complete Worked Example

Solve y” + 4y = 8t² using undetermined coefficients.

First, solve the homogeneous equation y” + 4y = 0. The characteristic equation is r² + 4 = 0, so r = ±2i. The complementary solution is y_h = C₁cos(2t) + C₂sin(2t).

The right-hand side 8t² is a second-degree polynomial, so guess y_p = At² + Bt + C. Compute y_p” = 2A. Substituting into the equation: 2A + 4(At² + Bt + C) = 8t². Expanding: 4At² + 4Bt + (2A + 4C) = 8t² + 0t + 0.

Match coefficients. For t²: 4A = 8, so A = 2. For t: 4B = 0, so B = 0. For the constant: 2A + 4C = 0, so 4 + 4C = 0, giving C = -1. The particular solution is y_p = 2t² – 1.

The general solution is y = C₁cos(2t) + C₂sin(2t) + 2t² – 1.

Why This Structure Works

The reason y = y_h + y_p always works comes from linearity. If you plug y_h + y_p into the left side of the equation, the y_h part produces zero (because it solves the homogeneous equation) and the y_p part produces the right-hand side. The two pieces handle different jobs: y_h captures all the freedom in the solution (the arbitrary constants that get pinned down by initial conditions), while y_p accounts for the external forcing.

In physical terms, this split is intuitive. A damped spring with an external vibration will eventually settle into a steady oscillation driven by the external force (the particular solution). The complementary solution represents the transient behavior that dies away over time. In undamped systems, both parts persist, which is how resonance occurs: when the forcing frequency matches the system’s natural frequency, the particular solution grows without bound.