On this page
For y″ + ay′ + by = f(x) with constant a and b, undetermined coefficients is often the quickest route to a particular solution: guess its shape from f(x), leave the constants as letters, and let the equation find them.
What is the method of undetermined coefficients?
The general solution of a nonhomogeneous linear equation is y = y_c + y_p: the complementary solution of y″ + ay′ + by = 0 plus any one particular solution, as Theorem 7.4 of OpenStax Calculus Volume 3 states. The method of undetermined coefficients finds y_p when f(x) is built from polynomials, exponentials, sines and cosines. When f(x) is not such a combination, OpenStax says the method does not work and points you to variation of parameters; Paul's Online Notes adds that it is generally only useful for constant-coefficient equations.
If finding y_c is still shaky, start with our guide to solving second-order linear differential equations.
Which guess do you use for each f(x)?
Match the guess to the family of f(x), following the table of trial solutions in OpenStax section 7.2:
Polynomial of degree n (for example 4x or 3x² − 1): a full polynomial of the same degree, Ax + B or Ax² + Bx + C. Keep every lower power, even if f(x) lacks it.
Exponential ke^(λx): Ae^(λx).
k cos βx or k sin βx: A cos βx + B sin βx, with both terms even if f(x) has only one.
Sums and products: add or multiply the matching guesses, so xe^(2x) gets (Ax + B)e^(2x).
A quick polynomial case: for y″ − 3y′ + 2y = 4x, try y_p = Ax + B. Then y_p′ = A and y_p″ = 0, so −3A + 2(Ax + B) = 4x. Matching x terms gives A = 2; matching constants, 2B − 3A = 0 gives B = 3. So y_p = 2x + 3.
What do you do when the guess solves the homogeneous equation?
This is the case that catches most students. A guess term already in y_c gives zero when substituted, so no constants can produce f(x). The fix, in step 3 of the strategy in OpenStax section 7.2, is to multiply the guess by x, and to repeat until no term of the guess solves the homogeneous equation. Paul's Online Notes gives the same rule with t in place of x.
Take y″ − 3y′ + 2y = 4e^(2x). The roots of r² − 3r + 2 = 0 are 1 and 2, so y_c = c₁eˣ + c₂e^(2x). The natural guess Ae^(2x) is already in y_c, so use Axe^(2x) instead. Substituting, every x term cancels and you are left with Ae^(2x) = 4e^(2x), so y_p = 4xe^(2x).
When λ is a double root of the characteristic equation, multiplying by x once is not enough: both e^(λx) and xe^(λx) are in y_c, so you need Ax²e^(λx), as in part 2 of Example 7.14 in OpenStax, which uses At²e^(−t).
Worked example: y″ + 4y = 8 cos 2x with y(0) = 1, y′(0) = 0
Complementary solution. r² + 4 = 0 gives r = ±2i, so y_c = c₁ cos 2x + c₂ sin 2x.
Guess. The table says A cos 2x + B sin 2x, but both terms are in y_c. Multiply by x: y_p = x(A cos 2x + B sin 2x).
Differentiate twice. y_p″ = −4A sin 2x + 4B cos 2x − 4x(A cos 2x + B sin 2x).
Substitute. The x terms cancel against 4y_p, leaving −4A sin 2x + 4B cos 2x = 8 cos 2x. So A = 0 and B = 2, and y_p = 2x sin 2x.
General solution. y = c₁ cos 2x + c₂ sin 2x + 2x sin 2x.
Initial conditions, last. y(0) = c₁ = 1. Differentiating, y′ = −2c₁ sin 2x + 2c₂ cos 2x + 2 sin 2x + 4x cos 2x, so y′(0) = 2c₂ = 0 and c₂ = 0.
The answer is y = cos 2x + 2x sin 2x.
The extra x is resonance you can see: an undamped spring with natural angular frequency 2, pushed at exactly that frequency, swings ever wider inside the envelope ±√(1 + 4x²) in the diagram above. For ideas that are easier to see than to read, the Fermi Simulation Lab has interactive simulations.
How do you check your answer?
Substitute y_p into the left side; it must return f(x) exactly.
No term of y_p may also appear in y_c.
Check both initial conditions on the final answer.
For practice, try our differential equations JEE Advanced practice questions with solutions, and compare this method with the Laplace transform route, which builds the initial conditions in from the start. When a substitution goes wrong and you cannot see where, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



