Method of Undetermined Coefficients

The method of undetermined coefficients finds a particular solution yₚ of ay″ + by′ + cy = g(x) when g(x) is a polynomial, an exponential, a sine or cosine, or a sum or product of these. You guess a yₚ of the same form with unknown coefficients, then substitute and match. The general solution is y = y_c + yₚ.

Before this lesson: Second-Order Homogeneous Linear Equations, Complex Roots of the Characteristic Equation and Repeated Roots of the Characteristic Equation

The idea: guess a solution that looks like g(x)

An equation like y″ − 3y′ − 4y = 3e^(2x) is nonhomogeneous: the right side g(x) is not 0. Its general solution has two parts. The complementary solution y_c solves the homogeneous equation with 0 on the right. A particular solution yₚ is any one function that gives g(x) exactly.

Polynomials, exponentials, sines and cosines have derivatives of the same type. The derivative of e^(2x) is a multiple of e^(2x), and the derivatives of cos x are ±sin x and ±cos x. So if g(x) is one of these, a combination of yₚ and its derivatives can match g(x) when yₚ has the same form. The only unknowns are the coefficients, which is where the name comes from.

Because the equation is linear, adding y_c to yₚ gives y = y_c + yₚ, and this covers every solution.

Undetermined coefficients table

g(x)Trial form of yₚ
Polynomial of degree n, such as 4x²Aₙxⁿ + … + A₁x + A₀ (every lower power too)
ke^(λx)Ae^(λx)
k cos βx or k sin βxA cos βx + B sin βx (both terms)
e^(λx)cos βx or e^(λx)sin βxe^(λx)(A cos βx + B sin βx)
Polynomial times e^(λx)(Aₙxⁿ + … + A₀)e^(λx)
Sum g₁ + g₂The sum of the trial forms for g₁ and g₂

Modification rule: if any term of the trial form already solves the homogeneous equation, multiply the trial form by x. If a term still solves it, multiply by x again (x² in all).

y = y_c + y_p

How to use the method of undetermined coefficients

  1. Solve the homogeneous equation ay″ + by′ + cy = 0 to get y_c.
  2. Choose the trial form of yₚ from the table.
  3. Compare it with y_c. If a term repeats, multiply the trial form by x (or x²).
  4. Find yₚ′ and yₚ″, substitute into the equation, and match the coefficients of like terms.
  5. Solve for the coefficients and write y = y_c + yₚ.
  6. For an initial-value problem, apply the initial conditions to the whole y, not to yₚ alone.

Undetermined coefficients examples

Example 1: An exponential right side

Solve y″ − 3y′ − 4y = 3e^(2x).

r^2 - 3r - 4 = (r - 4)(r + 1) = 0

Write the characteristic equation and factor the trinomial.

y_c = C_1e^{4x} + C_2e^{-x}

Use the roots 4 and −1.

y_p = Ae^{2x}

Choose the trial form; e^(2x) is not in y_c.

y_p' = 2Ae^{2x},\quad y_p'' = 4Ae^{2x}

Differentiate twice.

4Ae^{2x} - 6Ae^{2x} - 4Ae^{2x} = 3e^{2x}

Substitute into the equation.

-6Ae^{2x} = 3e^{2x}

Combine like terms.

A = -\tfrac{1}{2}

Divide both sides by −6e^(2x).

y = C_1e^{4x} + C_2e^{-x} - \tfrac{1}{2}e^{2x}

Add y_c and yₚ.

Answer: y = C₁e^(4x) + C₂e^(−x) − ½e^(2x).

Example 2: A polynomial right side

Solve y″ + y′ − 2y = 4x².

r^2 + r - 2 = (r + 2)(r - 1) = 0

Factor the characteristic equation.

y_c = C_1e^{x} + C_2e^{-2x}

Use the roots 1 and −2.

y_p = Ax^2 + Bx + C

Use a full quadratic, even though 4x² has no x or constant term.

y_p' = 2Ax + B,\quad y_p'' = 2A

Differentiate twice.

2A + (2Ax + B) - 2(Ax^2 + Bx + C) = 4x^2

Substitute into the equation.

-2Ax^2 + (2A - 2B)x + (2A + B - 2C) = 4x^2

Distribute and group by powers of x.

-2A = 4 \Rightarrow A = -2

Match the x² coefficients.

2(-2) - 2B = 0 \Rightarrow B = -2

Match the x coefficients, which must be 0.

2(-2) + (-2) - 2C = 0 \Rightarrow C = -3

Match the constant terms.

y = C_1e^{x} + C_2e^{-2x} - 2x^2 - 2x - 3

Add y_c and yₚ.

Answer: y = C₁e^x + C₂e^(−2x) − 2x² − 2x − 3.

Example 3: A cosine right side

Solve y″ − y′ − 2y = 10 cos x.

y_c = C_1e^{2x} + C_2e^{-x}

The characteristic equation r² − r − 2 = (r − 2)(r + 1) has roots 2 and −1.

y_p = A\cos x + B\sin x

Use both cosine and sine.

y_p' = -A\sin x + B\cos x

Differentiate (see derivatives of trig functions).

y_p'' = -A\cos x - B\sin x

Differentiate again.

(-A - B - 2A)\cos x + (-B + A - 2B)\sin x = 10\cos x

Substitute and group the cosine and sine terms.

(-3A - B)\cos x + (A - 3B)\sin x = 10\cos x

Combine like terms.

-3A - B = 10,\quad A - 3B = 0

Match coefficients: the sine coefficient must be 0.

A = 3B

Solve the second equation for A.

-9B - B = 10 \Rightarrow B = -1

Substitute into the first equation and solve.

A = -3

Use A = 3B.

y = C_1e^{2x} + C_2e^{-x} - 3\cos x - \sin x

Add y_c and yₚ.

Answer: y = C₁e^(2x) + C₂e^(−x) − 3 cos x − sin x. Even though g(x) has no sine, the sine term is needed.

Example 4: Using the modification rule

Solve y″ − 5y′ + 6y = 2e^(3x).

y_c = C_1e^{2x} + C_2e^{3x}

The characteristic equation (r − 2)(r − 3) = 0 has roots 2 and 3.

y_p = Axe^{3x}

Ae^(3x) is already in y_c, so multiply the trial form by x.

y_p' = A(1 + 3x)e^{3x}

Differentiate with the product rule.

y_p'' = A(6 + 9x)e^{3x}

Differentiate again and combine like terms.

A\left[(6 + 9x) - 5(1 + 3x) + 6x\right]e^{3x} = 2e^{3x}

Substitute and factor out Ae^(3x).

A\left[6 + 9x - 5 - 15x + 6x\right] = 2

Distribute and divide both sides by e^(3x).

A = 2

Combine like terms: the x terms cancel and 6 − 5 = 1.

y = C_1e^{2x} + C_2e^{3x} + 2xe^{3x}

Add y_c and yₚ.

Answer: y = C₁e^(2x) + C₂e^(3x) + 2xe^(3x). Trying Ae^(3x) would give 0 = 2e^(3x), which is why the x is needed.

Example 5: A spring pushed by a motor (word problem)

A spring with no damping is pushed by a motor, and its position x (in centimeters, t in seconds) satisfies x″ + 9x = 5 cos 2t. It starts at rest at its rest position, so x(0) = 0 and x′(0) = 0. Find x(t) and its largest displacement.

x_c = C_1\cos 3t + C_2\sin 3t

The roots of r² + 9 = 0 are ±3i.

x_p = A\cos 2t + B\sin 2t

Choose the trial form; cos 2t is not in x_c.

x_p'' = -4A\cos 2t - 4B\sin 2t

Differentiate twice.

5A\cos 2t + 5B\sin 2t = 5\cos 2t

Substitute: −4A + 9A = 5A and −4B + 9B = 5B.

A = 1,\quad B = 0

Match coefficients.

x = C_1\cos 3t + C_2\sin 3t + \cos 2t

Add x_c and xₚ.

C_1 + 1 = 0 \Rightarrow C_1 = -1

Substitute t = 0 into x and subtract 1.

x' = -3C_1\sin 3t + 3C_2\cos 3t - 2\sin 2t

Differentiate.

3C_2 = 0 \Rightarrow C_2 = 0

Substitute t = 0 into x′.

x = \cos 2t - \cos 3t

Write the motion.

x(\pi) = \cos 2\pi - \cos 3\pi = 1 - (-1) = 2

Each cosine is between −1 and 1, so 2 is the most possible; t = π reaches it.

Answer: x(t) = cos 2t − cos 3t. The largest displacement is 2 cm, first reached at t = π ≈ 3.14 s. The two frequencies drift in and out of step, so the motion swells and fades, repeating every 2π seconds.

Graph of x(t) = cos 2t − cos 3t for t from 0 to 4π, about 12.6 seconds. The curve starts at 0, wiggles with small swings near t = 0, 2π and 4π, and reaches its largest value 2 at t = π and t = 3π, marked with dots. Its values stay between −2 and 2 (dashed lines); the lowest values are about −1.63.
The motor’s frequency 2 and the spring’s natural frequency 3 drift in and out of step, so the motion swells to 2 cm at t = π and nearly stops near t = 2π.

Common mistakes

MistakeExample of the errorFix
Using only the cosine termyₚ = A cos x for g(x) = 10 cos xUse A cos x + B sin x; the derivatives mix the two.
Leaving out lower powersyₚ = Ax² for g(x) = 4x²Use Ax² + Bx + C.
Ignoring the modification ruleyₚ = Ae^(3x) when e^(3x) is in y_cMultiply by x: yₚ = Axe^(3x).
Applying initial conditions to yₚ aloneSolving yₚ(0) = 0 for AFind A first, then apply the conditions to y = y_c + yₚ.
Forgetting y_cAnswering y = −½e^(2x)The general solution is y_c + yₚ, with two constants.
Using the method on the wrong g(x)Guessing A tan x for g(x) = tan xDerivatives of tan x are new functions; use Variation of Parameters instead.

Related ideas

Superposition for sums

If g(x) = g₁(x) + g₂(x), find a particular solution for each part and add them. For y″ + y = e^x + 2, the trial Ae^x gives A = ½ and the trial C gives C = 2, so yₚ = ½e^x + 2. Practice problem 8 works this out.

Resonance

When g(x) is a cosine or sine with the same frequency as y_c, the modification rule multiplies by x, and yₚ grows like x cos βx. For a spring, that is resonance. Practice problem 6 shows it, and Forced Oscillations and Resonance explains it.

When the method does not apply

The method needs a g(x) whose derivatives stay in a finite family. It does not work for tan x, sec x, ln x or 1/x, or for equations whose coefficients depend on x. Variation of Parameters handles those.

Practice problems

  1. Solve y″ − y = 2e^(3x).
  2. Find a particular solution of y″ + 3y′ + 2y = 6x + 1.
  3. Solve y″ + y = 2x².
  4. Solve y″ + 4y′ + 4y = 8 sin 2x.
  5. Find a particular solution of y″ − 4y = 8e^(2x).
  6. Find a particular solution of y″ + 9y = 6 sin 3x.
  7. Write the trial form of yₚ for y″ − 2y′ + y = xe^x. Do not solve for the coefficients.
  8. Find a particular solution of y″ + y = e^x + 2.
  9. Solve y″ − y′ − 2y = 4x with y(0) = 1 and y′(0) = 1.
  10. A damped spring driven by a motor satisfies x″ + 2x′ + 5x = 10 cos t (x in centimeters, t in seconds). Find the steady-state motion xₚ and its amplitude.
Show answers

1.

y_c = C_1e^{x} + C_2e^{-x}

The roots of r² − 1 = 0 are ±1.

9Ae^{3x} - Ae^{3x} = 2e^{3x}

Substitute yₚ = Ae^(3x), with yₚ″ = 9Ae^(3x).

8A = 2 \Rightarrow A = \tfrac{1}{4}

Combine like terms and divide by 8.

Answer: y = C₁e^x + C₂e^(−x) + ¼e^(3x)

2.

0 + 3A + 2(Ax + B) = 6x + 1

Substitute yₚ = Ax + B, with yₚ′ = A and yₚ″ = 0.

2A = 6 \Rightarrow A = 3

Match the x coefficients.

3(3) + 2B = 1 \Rightarrow B = -4

Match the constants.

Answer: yₚ = 3x − 4

3.

2A + Ax^2 + Bx + C = 2x^2

Substitute yₚ = Ax² + Bx + C, with yₚ″ = 2A.

A = 2,\quad B = 0,\quad 2A + C = 0

Match the x², x and constant coefficients.

C = -4

Substitute A = 2.

Answer: y = C₁ cos x + C₂ sin x + 2x² − 4

4.

y_c = \left(C_1 + C_2x\right)e^{-2x}

The characteristic equation (r + 2)² = 0 has a repeated root.

(-4A + 8B + 4A)\cos 2x + (-4B - 8A + 4B)\sin 2x = 8\sin 2x

Substitute yₚ = A cos 2x + B sin 2x and group terms.

8B = 0,\quad -8A = 8

Combine like terms and match coefficients.

A = -1,\quad B = 0

Solve.

Answer: y = (C₁ + C₂x)e^(−2x) − cos 2x

5.

y_p = Axe^{2x}

e^(2x) is in y_c = C₁e^(2x) + C₂e^(−2x), so multiply by x.

y_p'' = A(4 + 4x)e^{2x}

Differentiate twice with the product rule.

A(4 + 4x - 4x)e^{2x} = 8e^{2x}

Substitute into y″ − 4y.

4A = 8 \Rightarrow A = 2

Simplify and divide by 4.

Answer: yₚ = 2xe^(2x)

6.

y_p = x(A\cos 3x + B\sin 3x)

sin 3x is in y_c = C₁ cos 3x + C₂ sin 3x, so multiply by x.

y_p'' + 9y_p = -6A\sin 3x + 6B\cos 3x

Differentiate twice and substitute; the x terms cancel.

-6A = 6,\quad 6B = 0

Match coefficients with 6 sin 3x.

A = -1,\quad B = 0

Solve.

Answer: yₚ = −x cos 3x (resonance: it grows with x)

7.

y_c = \left(C_1 + C_2x\right)e^{x}

The characteristic equation (r − 1)² = 0 has the repeated root 1.

(Ax + B)e^{x}

Start with the table form for xe^x; both e^x and xe^x are in y_c.

x(Ax + B)e^{x} = (Ax^2 + Bx)e^{x}

Multiply by x; Bxe^x is still in y_c.

x^2(Ax + B)e^{x} = (Ax^3 + Bx^2)e^{x}

Multiply by x again; no term is in y_c now.

Answer: yₚ = x²(Ax + B)e^x

8.

2Ae^{x} = e^{x} \Rightarrow A = \tfrac{1}{2}

For e^x, substitute Ae^x: Ae^x + Ae^x = 2Ae^x.

C = 2

For 2, substitute the constant C: 0 + C = 2.

Answer: yₚ = ½e^x + 2

9.

y_c = C_1e^{2x} + C_2e^{-x}

The roots of r² − r − 2 = 0 are 2 and −1.

-A - 2(Ax + B) = 4x

Substitute yₚ = Ax + B.

A = -2,\quad B = 1

Match coefficients: −2A = 4, then −A − 2B = 0.

y = C_1e^{2x} + C_2e^{-x} - 2x + 1

Add y_c and yₚ.

C_1 + C_2 + 1 = 1,\quad 2C_1 - C_2 - 2 = 1

Apply y(0) = 1 and y′(0) = 1 to the whole solution.

C_1 = 1,\quad C_2 = -1

Add the equations C₁ + C₂ = 0 and 2C₁ − C₂ = 3 to get 3C₁ = 3.

Answer: y = e^(2x) − e^(−x) − 2x + 1

10.

(4A + 2B)\cos t + (4B - 2A)\sin t = 10\cos t

Substitute xₚ = A cos t + B sin t and group terms.

4A + 2B = 10,\quad 4B - 2A = 0

Match coefficients.

A = 2B \Rightarrow 10B = 10 \Rightarrow B = 1,\ A = 2

Solve the second equation for A and substitute.

\sqrt{2^2 + 1^2} = \sqrt{5} \approx 2.24

Amplitude of A cos t + B sin t.

Answer: xₚ = 2 cos t + sin t, amplitude √5 ≈ 2.24 cm (the x_c part has e^(−t) and dies out)

Undetermined coefficients FAQ

What is the method of undetermined coefficients?

It is a way to find a particular solution of a linear nonhomogeneous equation with constant coefficients. You guess a solution with the same form as g(x), leaving the coefficients unknown, and then solve for them.

How do you choose the form of the particular solution?

Match the form of g(x) using the table: a full polynomial for a polynomial, Ae^(λx) for an exponential, and both cosine and sine for either one. Then check y_c and multiply by x if any term repeats.

When do you multiply the guess by x?

Multiply by x when a term of your guess already solves the homogeneous equation. If a term still repeats, multiply by x again.

When does undetermined coefficients not work?

It fails when g(x) is something like tan x, ln x or 1/x, and when the coefficients of the equation are not constants. Use variation of parameters for those.

Summary

  • The general solution of ay″ + by′ + cy = g(x) is y = y_c + yₚ.
  • Guess yₚ with the same form as g(x), using the table.
  • Always include every lower power of a polynomial and both cosine and sine.
  • If a term of the guess is in y_c, multiply by x (or x²).
  • Apply initial conditions to y_c + yₚ after finding the coefficients.

Previous lesson: Repeated Roots of the Characteristic Equation

Next lesson: Variation of Parameters

Back to the Differential Equations Index