Differential Equations · § 07

Method of Undetermined
Coefficients

Solving non-homogeneous ODEs ay'' + by' + cy = g(x) by guessing a trial particular solution that mirrors the form of g(x): then determining its coefficients by substitution.

4Forcing Types
12Worked Examples
10Quiz Questions
Share this page

§ 01The Non-Homogeneous Problem

In the previous topic we solved ay'' + by' + cy = 0, the homogeneous equation. Now we add a forcing function g(x) on the right and ask: what particular function y satisfies the full equation?

Non-Homogeneous Second-Order Linear ODE
ay'' + by' + cy = g(x) a, b, c ∈ ℝ with a ≠ 0   |   g(x) ≠ 0 is the forcing function (or non-homogeneous term)

The method of undetermined coefficients applies when g(x) is one of the following types, or a sum or product of them:

  • A polynomial: g(x) = xⁿ + … (any degree)
  • An exponential: g(x) = eᵅˣ
  • A sine or cosine: g(x) = sin(βx) or cos(βx)
  • Any product of the above: g(x) = x²e³ˣ, eˣ sin(2x), etc.

If g(x) is something else (like ln x, tan x, or 1/x) the method does not apply and you must use variation of parameters instead.

§ 02Superposition: y = yh + yp

The complete general solution to the non-homogeneous equation is the sum of two parts: the homogeneous solution and a particular solution. This is the superposition principle.

General Solution
y = yh + yp
=
Homogeneous Solution
yh — solves ay''+by'+cy = 0
Contains C₁, C₂
+
Particular Solution
yp — solves ay''+by'+cy = g(x)
No arbitrary constants

Why does this work? If yh satisfies the homogeneous equation and yp satisfies the full non-homogeneous equation, then substituting y = yh + yp into the left-hand side gives:

Proof of Superposition
a(yh+yp)'' + b(yh+yp)' + c(yh+yp) = [ayh''+byh'+cyh] + [ayp''+byp'+cyp] = 0 + g(x) = g(x) ✓

The arbitrary constants C₁ and C₂ live entirely in yh. The particular solution yp has no free constants, it is a single, specific function. Initial conditions are applied to the complete solution y = yh + yp at the end.

The Five-Step Method
  1. Solve the homogeneous equation ay''+by'+cy = 0 using the characteristic equation. Write down yh.
  2. Identify the form of g(x) and choose the appropriate trial particular solution yp from the table in § 03.
  3. Check for overlap between yp and yh. If any term of the trial yp appears in yh, apply the modification rule (multiply by x, or x² if needed).
  4. Substitute the trial yp (and its derivatives) into the full ODE. Collect like terms and solve for the undetermined coefficients.
  5. Write the complete general solution y = yh + yp, then apply initial conditions if given.

§ 03The Trial Solution Table

The trial particular solution yp must be chosen to match the family of functions that g(x) belongs to. This means including all members of that family, not just the exact terms that appear.

Forcing Function g(x) Trial Particular Solution yp Notes
c (constant) A Single undetermined constant
bx + c (degree 1) Ax + B Include all terms down to degree 0
ax² + bx + c (degree 2) Ax² + Bx + C Full quadratic — all three terms required
Pₙ(x) (degree n poly) Aₙxⁿ + … + A₁x + A₀ n+1 undetermined coefficients
eαx Aeαx One constant; α must not be a root of char. eq.
sin(βx) or cos(βx) A cos(βx) + B sin(βx) Always include BOTH sin and cos, even if g has only one
eαx sin(βx) or eαx cos(βx) eαx(A cos βx + B sin βx) Exponential envelope × both trig terms
Pₙ(x)·eαx (Aₙxⁿ+…+A₀)eαx Polynomial of same degree × exponential
Pₙ(x)·sin(βx)
or Pₙ(x)·cos(βx)
(Aₙxⁿ+…+A₀)cos βx + (Bₙxⁿ+…+B₀)sin βx Two full polynomials — one for cos, one for sin
The "include the whole family" rule If g(x) = 3x², you might be tempted to try yp = Ax². But differentiating Ax² twice produces a constant, which means the y and y' terms need x² and x as well. Always use the full polynomial Ax² + Bx + C for any degree-2 forcing. Similarly, if g(x) = 5 sin(3x), always use A cos(3x) + B sin(3x) — differentiation mixes sin and cos, so you need both.

§ 04Polynomial Forcing

When g(x) is a polynomial, the trial solution is a polynomial of the same degree. Substitute and match coefficients of equal powers of x.

Example 1 — Constant Forcing

Solve: y'' + 3y' + 2y = 10.

1
Homogeneous solution. Characteristic equation: r² + 3r + 2 = (r+1)(r+2) = 0. Roots r = −1, −2.yh = C₁e−x + C₂e−2x
2
Trial solution. g(x) = 10 (constant), so try yp = A. Then yp' = 0, yp'' = 0.
3
Substitute. 0 + 3(0) + 2A = 10  →  2A = 10  →  A = 5.
y = C₁e−x + C₂e−2x + 5
Example 2 — Quadratic Forcing

Find a particular solution of y'' − y = x² − 1.

1
Trial solution. g(x) = x² − 1 has degree 2, so try yp = Ax² + Bx + C.
2
Compute derivatives. yp' = 2Ax + B,   yp'' = 2A.
3
Substitute into y'' − y = x² − 1:2A − (Ax² + Bx + C) = x² − 1−Ax² − Bx + (2A − C) = x² − 1
4
Match coefficients by power of x:
x²: −A = 1  →  A = −1
x¹: −B = 0  →  B = 0
x⁰: 2A − C = −1  →  −2 − C = −1  →  C = −1
yp = −x² − 1
Example 3 — Linear Forcing with Full IVP

Solve: y'' + y' = 2x + 3,   y(0) = 1,   y'(0) = 0.

1
Homogeneous solution. r² + r = r(r+1) = 0. Roots r = 0, r = −1.yh = C₁ + C₂e−x
2
Trial solution. g(x) = 2x + 3 suggests yp = Ax + B. But C₁ (a constant) is already in yh — does this overlap? The constant term B in yp overlaps with C₁·1. Apply the modification rule: multiply by x.yp = x(Ax + B) = Ax² + Bx
3
Derivatives. yp' = 2Ax + B,   yp'' = 2A.
4
Substitute: 2A + (2Ax + B) = 2x + 3.
x¹: 2A = 2  →  A = 1
x⁰: 2A + B = 3  →  2 + B = 3  →  B = 1
5
Complete solution: y = C₁ + C₂e−x + x² + x.
Apply y(0)=1: C₁ + C₂ = 1.
y' = −C₂e−x + 2x + 1. Apply y'(0)=0: −C₂ + 1 = 0  →  C₂ = 1  →  C₁ = 0.
y = e−x + x² + x

§ 05Exponential Forcing

When g(x) = Keαx, try yp = Aeαx, unless α is a root of the characteristic equation, in which case the modification rule applies.

Example 4 — Standard Exponential

Solve: y'' − 3y' + 2y = 4e3x.

1
Homogeneous solution. r² − 3r + 2 = (r−1)(r−2) = 0. Roots r = 1, 2.yh = C₁ex + C₂e2x
2
Trial solution. g(x) = 4e3x. Check: is α = 3 a root? No (roots are 1 and 2). So try yp = Ae3x.
3
Compute derivatives. yp' = 3Ae3x,   yp'' = 9Ae3x.
4
Substitute: 9Ae3x − 3(3Ae3x) + 2(Ae3x) = 4e3x.Ae3x(9 − 9 + 2) = 4e3x  →  2A = 4  →  A = 2
y = C₁ex + C₂e2x + 2e3x
Example 5 — Modification Rule (α is a simple root) Modification Rule

Solve: y'' − 3y' + 2y = 5ex.

1
Homogeneous solution. From Example 4: yh = C₁ex + C₂e2x.
2
Check for overlap. g(x) = 5eˣ suggests trial Aeˣ. But eˣ is already in yh (the C₁eˣ term). The trial would satisfy the homogeneous equation and give 0 = 5eˣ — impossible. Apply the modification rule and multiply by x:yp = Axex
3
Compute derivatives (product rule).
yp' = Aex + Axex = A(1+x)ex
yp'' = Aex + A(1+x)ex = A(2+x)ex
4
Substitute: A(2+x)eˣ − 3A(1+x)eˣ + 2Axeˣ = 5eˣ.eˣ · A[(2+x) − 3(1+x) + 2x] = 5eˣeˣ · A[2+x−3−3x+2x] = eˣ · A(−1) = 5eˣ−A = 5  →  A = −5
y = C₁ex + C₂e2x − 5xex
Example 6 — Modification Rule (α is a double root) Modification Rule ×2

Find a particular solution of y'' − 2y' + y = ex.

1
Homogeneous solution. r² − 2r + 1 = (r−1)² = 0. Double root r = 1.yh = (C₁ + C₂x)ex
2
Check overlap. Trial Aeˣ overlaps with C₁eˣ. Multiply by x: Axeˣ overlaps with C₂xeˣ. Must multiply by x again:yp = Ax²ex
3
Derivatives.
yp' = (2Ax + Ax²)ex = Ax(2+x)ex
yp'' = A(2+x)ex + Ax(2+x)ex + Axex = A(2 + 4x + x²)ex
4
Substitute: A(2+4x+x²)eˣ − 2Ax(2+x)eˣ + Ax²eˣ = eˣ.A[(2+4x+x²) − (4x+2x²) + x²]eˣ = eˣ  →  2Aeˣ = eˣ  →  A = ½
yp = ½x²ex

§ 06Trigonometric Forcing

When g(x) involves sin(βx) or cos(βx), the trial solution must include both A cos(βx) and B sin(βx), because differentiation converts one into the other. Never use only one of the pair.

Example 7 — Sinusoidal Forcing

Find a particular solution of y'' + 4y = 3 sin(x).

1
Homogeneous solution. r² + 4 = 0  →  r = ±2i. Roots are ±2i (not ±i), so β = 1 does not overlap.yh = C₁cos(2x) + C₂sin(2x)
2
Trial solution. yp = A cos(x) + B sin(x).
3
Derivatives. yp'' = −A cos(x) − B sin(x).
4
Substitute into y'' + 4y:(−Acos x − Bsin x) + 4(Acos x + Bsin x) = 3sin x3Acos x + 3Bsin x = 3sin x
5
Match coefficients: cos x: 3A = 0  →  A = 0.   sin x: 3B = 3  →  B = 1.
yp = sin(x)     Full solution: y = C₁cos(2x) + C₂sin(2x) + sin(x)
Example 8 — Resonance Modification Rule

Find a particular solution of y'' + 4y = 3 cos(2x).

1
Homogeneous solution. yh = C₁cos(2x) + C₂sin(2x) (same as Example 7).
2
Check overlap. Trial A cos(2x) + B sin(2x) exactly duplicates yh. This is resonance — the forcing frequency matches the natural frequency. Apply the modification rule: multiply by x.yp = x(A cos(2x) + B sin(2x))
3
Derivatives (product rule).
yp' = (A cos 2x + B sin 2x) + x(−2A sin 2x + 2B cos 2x)
yp'' = (−2A sin 2x + 2B cos 2x) + (−2A sin 2x + 2B cos 2x) + x(−4A cos 2x − 4B sin 2x)
yp'' = (−4A sin 2x + 4B cos 2x) − 4x(A cos 2x + B sin 2x)
4
Substitute into y'' + 4y:(−4A sin 2x + 4B cos 2x) − 4x(A cos 2x + B sin 2x) + 4x(A cos 2x + B sin 2x) = 3cos 2x−4A sin 2x + 4B cos 2x = 3 cos 2x
5
Match: sin 2x: −4A = 0  →  A = 0.   cos 2x: 4B = 3  →  B = ¾.
yp = ¾ x sin(2x)     Full solution: y = C₁cos(2x) + C₂sin(2x) + ¾x sin(2x)

§ 07Combined and Product Forcing

When g(x) is a sum of terms, the particular solution is the sum of the particular solutions for each term separately. When g(x) is a product (like eαx sin βx), treat the whole product as one unit.

Example 9 — Sum of Forcing Terms

Find a particular solution of y'' + y' − 2y = 2ex + 3.

1
Homogeneous solution. r² + r − 2 = (r+2)(r−1) = 0. Roots r = 1, −2.yh = C₁ex + C₂e−2x
2
Split: find yp1 for 2eˣ. Trial Aeˣ overlaps with C₁eˣ in yh. Apply modification rule: yp1 = Axeˣ.
Derivatives: yp1' = A(1+x)eˣ, yp1'' = A(2+x)eˣ.
Substitute: A(2+x)eˣ + A(1+x)eˣ − 2Axeˣ = 2eˣ  →  A(3)eˣ = 2eˣ  →  A = 2/3.
3
Find yp2 for 3 (constant). Trial yp2 = B. Substitute: 0 + 0 − 2B = 3  →  B = −3/2.
yp = ⅔xex − 3/2      y = C₁ex + C₂e−2x + ⅔xex − 3/2
Example 10 — Exponential × Trig Forcing

Find a particular solution of y'' + 2y' + 2y = e−x cos(x).

1
Homogeneous solution. r² + 2r + 2 = 0. r = [−2 ± √(4−8)]/2 = −1 ± i.yh = e−x(C₁cos x + C₂sin x)
2
Check overlap. Trial e−x(Acos x + Bsin x) is exactly yh. Apply modification rule:yp = xe−x(Acos x + Bsin x)
3
Compute yp' and yp'' (product rule, collecting terms):
yp' = e−x[(A+B)cos x + (B−A)sin x] + xe−x[(B−A)cos x − (A+B)sin x]
4
After computing yp'' and substituting into y''+2y'+2y, the x-terms cancel (as expected from the modification rule) and the remaining terms give:2B cos x − 2A sin x = cos x
5
Match: cos x: 2B = 1  →  B = ½.   sin x: −2A = 0  →  A = 0.
yp = ½ xe−x sin(x)
Example 11 — Polynomial × Exponential Forcing

Find a particular solution of y'' − y' = 2xex.

1
Homogeneous solution. r² − r = r(r−1) = 0. Roots r = 0, 1.yh = C₁ + C₂ex
2
Trial solution. g(x) = 2xeˣ — a degree-1 polynomial times eˣ. Standard trial: (Ax + B)eˣ. Check overlap: Beˣ overlaps with C₂eˣ. Multiply the whole trial by x:yp = x(Ax + B)ex = (Ax² + Bx)ex
3
Derivatives.
yp' = (2Ax + B)eˣ + (Ax²+Bx)eˣ = (Ax² + (2A+B)x + B)eˣ
yp'' = (Ax² + (4A+B)x + (2A+2B))eˣ
4
Substitute into y'' − y':[Ax²+(4A+B)x+(2A+2B)]eˣ − [Ax²+(2A+B)x+B]eˣ = 2xeˣ[2Ax + (2A+B)]eˣ = 2xeˣ
5
Match: x¹: 2A = 2  →  A = 1.   x⁰: 2A + B = 0  →  B = −2.
yp = (x² − 2x)ex
Example 12 — Complete IVP

Solve: y'' − 2y' + y = eˣ + 4,   y(0) = 2,   y'(0) = 3.

1
Homogeneous. (r−1)² = 0. Double root r = 1.yh = (C₁ + C₂x)ex
2
Particular for eˣ. From Example 6 (same equation): yp1 = ½x²eˣ.
3
Particular for 4 (constant). Trial yp2 = A. Substitute: 0 − 0 + A = 4  →  A = 4.
4
Complete general solution:y = (C₁ + C₂x)eˣ + ½x²eˣ + 4
5
Apply y(0) = 2: C₁ + 0 + 0 + 4 = 2  →  C₁ = −2.
6
Differentiate: y' = C₂eˣ + (C₁+C₂x)eˣ + xeˣ + ½x²eˣ.
Apply y'(0) = 3: C₂ + C₁ + 0 + 0 = 3  →  C₂ + (−2) = 3  →  C₂ = 5.
y = (−2 + 5x)eˣ + ½x²eˣ + 4  =  (−2 + 5x + ½x²)eˣ + 4

§ 08The Modification Rule — Full Summary

The modification rule is the single most important subtlety in the method of undetermined coefficients. Master it and you can handle every case.

When to apply the modification rule If any term in the initial trial yp is a solution of the homogeneous equation (i.e., it appears in yh), then that trial will produce 0 = g(x) upon substitution — useless. The fix: multiply the entire trial by xˢ, where s is the smallest positive integer that eliminates all overlaps. Typically s = 1 (simple root) or s = 2 (double root).
Situation Action Example
No overlap between trial yp and yh Use trial as-is g=e³ˣ, roots 1,2  →  yp=Ae³ˣ
Trial overlaps yh (simple root) Multiply trial by x g=eˣ, root 1  →  yp=Axeˣ
Trial overlaps yh after ×x (double root) Multiply original trial by x² g=eˣ, double root 1  →  yp=Ax²eˣ
Trig trial overlaps (resonance) Multiply trig trial by x g=cos 2x, yh has cos 2x  →  yp=x(Acos 2x+Bsin 2x)
Polynomial trial overlaps (root r=0) Multiply polynomial trial by x g=3x, r=0 is root  →  yp=x(Ax+B)=Ax²+Bx
What "overlap" means precisely A term in the trial yp overlaps with yh if substituting that term alone into the left-hand side ay''+by'+cy would give zero. Concretely: eᵅˣ overlaps if α is a root; cos(βx) or sin(βx) overlaps if ±βi are roots; a constant overlaps if 0 is a root (i.e., c = 0 in the ODE).

§ 09Common Mistakes

Mistake 1: Only including the terms that actually appear in g(x) If g(x) = 5x, using trial yp = Ax misses the constant term. Because yp'' and yp' generate constants, you must use yp = Ax + B. Similarly for trig: g(x) = cos x requires yp = A cos x + B sin x, not just A cos x.
Mistake 2: Forgetting to check for overlap before writing the trial Always write out yh first, then check every term of your proposed trial against it. Skipping this step and discovering halfway through that your trial gives 0 = g(x) wastes enormous effort.
Mistake 3: Applying initial conditions before adding yp to yh Initial conditions must be applied to the complete solution y = yh + yp. Applying them to yh alone gives wrong values of C₁ and C₂.
Mistake 4: Using the method when g(x) is not of the required type The method only works for polynomials, exponentials, sines, cosines, and their products. It does not work for g(x) = ln x, g(x) = tan x, g(x) = sec x, or g(x) = 1/x. Use variation of parameters for those.
Mistake 5: Incorrect differentiation in the substitution step Expressions like xeαx or xe−xcos(βx) require the product rule (sometimes applied twice). Differentiating them as if the x is just a constant is the most common algebraic error in this method.

§ 1010-Question Quiz

Test every aspect of the method, trial selection, modification rule, coefficient matching, and complete solutions.

Score: 0 / 0
Question 1

For y'' + 3y' + 2y = 5x², what is the correct trial particular solution?

Question 2

For y'' + y' − 6y = 4e2x, the homogeneous solution is yh = C₁e2x + C₂e−3x. Which trial particular solution should be used?

Question 3

For y'' + 9y = 4 cos(3x), the homogeneous solution is yh = C₁cos(3x) + C₂sin(3x). What is the correct trial yp?

Question 4

After substituting yp = Ae5x into y'' − 4y' + 3y = 2e5x, which expression do you solve for A?

Question 5 — Fill In

For y'' − y = 6 with trial yp = A, substituting gives −A = 6. Therefore A = .

Question 6

The general solution to a non-homogeneous ODE is y = yh + yp. Where should initial conditions be applied?

Question 7

For y'' + y = sin(x), the homogeneous solution is yh = C₁cos x + C₂sin x. Which trial is correct?

Question 8

For which type of forcing function does the method of undetermined coefficients NOT apply?

Question 9

For y'' − y' = 4 (with root r = 0 in yh), the constant trial yp = A would overlap yh. What is the correct modified trial?

Question 10 — Fill In

For y'' + 4y' + 4y = e−2x, the homogeneous solution is yh=(C₁+C₂x)e−2x (double root r=−2). The modified trial is yp=Ax²e−2x. After substitution, you find 2A = 1, so A = .


Continue in Differential Equations

Undetermined coefficients handles a wide range of forcing functions, but for cases it cannot handle, and for a deeper theoretical understanding, explore these topics next:

Cookie Settings