Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 39 ยท Second-order Linear ODEs

Undetermined Coefficients

Solve a*y'' + b*y' + c*y = g(t) by guessing the form of a particular solution: polynomials, exponentials, sines and cosines, plus the resonance rule. Checked with SymPy.

Real systems are pushed around: a spring is driven by a motor, a circuit is fed a voltage. The mathematical model is a nonhomogeneous equation

a*y'' + b*y' + c*y = g(t),

where g(t) is the forcing term. The structure of the solution is the same as in the first-order case:

y = y_h + y_p.

Here y_h = C1*y1 + C2*y2 is the general solution of the homogeneous equation (see the previous two lessons) and y_p is any one particular solution of the full equation. Why does it work? If y_p and another solution Y both solve the forced equation, their difference solves the homogeneous one, so Y = y_p + (something in y_h). Finding y_p is the new task. For common forcing terms you can guess its form and solve for unknown coefficients: that is the method of undetermined coefficients.

Which guess for which forcing?

Forcing g(t) Guess y_p
A*e**(k*t) K*e**(k*t)
polynomial of degree n general polynomial of degree n
A*cos(w*t) or A*sin(w*t) K1*cos(w*t) + K2*sin(w*t) (both always!)
a product, e.g. t*e**(k*t) polynomial times exponential, same degree
a sum sum of the guesses for each piece

Then substitute the guess into the equation, match coefficients of like terms, and solve the resulting linear equations for the unknown constants.

Worked example 1: exponential forcing

y'' - 3*y' + 2*y = 4*e**(3*t). Guess y_p = K*e**(3*t): y_p'' - 3*y_p' + 2*y_p = (9 - 9 + 2)*K*e**(3*t) = 2*K*e**(3*t), so 2*K = 4, K = 2. The full solution is y = C1*e**t + C2*e**(2*t) + 2*e**(3*t).

Worked example 2: sinusoidal forcing

y'' + y' + y = sin(2*t). Guess y_p = K1*cos(2*t) + K2*sin(2*t). Substitution gives (-3*K1 + 2*K2)*cos 2t + (-2*K1 - 3*K2)*sin 2t = sin 2t. So -3*K1 + 2*K2 = 0 and -2*K1 - 3*K2 = 1, giving K1 = -2/13, K2 = -3/13.

Python Solve for undetermined coefficients

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Worked example 3: polynomial forcing

y'' + 4*y = 8*t**2: guess y_p = A*t**2 + B*t + C. Then y_p'' = 2*A, so 2*A + 4*A*t**2 + 4*B*t + 4*C = 8*t**2: A = 2, B = 0, 4*C = -2*A = -4, C = -1. Therefore y_p = 2*t**2 - 1. Always include every lower-degree term even if you suspect it is zero.

The resonance (overlap) rule

If part of your guess already solves the homogeneous equation, substitution would give zero and fail. The fix: multiply the guess by t (or t**2 if it is a double root) until no term overlaps the homogeneous solution.

Example: y'' - 3*y' + 2*y = e**t. Since e**t is a homogeneous solution (root r = 1), the guess K*e**t yields 0 = e**t, impossible. Use y_p = K*t*e**t: y_p' = K*(1 + t)*e**t, y_p'' = K*(2 + t)*e**t, so K*[(2 + t) - 3*(1 + t) + 2*t]*e**t = K*(-1)*e**t = e**t, giving K = -1. So y_p = -t*e**t.

For sinusoids: y'' + 4*y = cos(2*t) has e**(ยฑ2it) as homogeneous solutions, so the guess must be t*(K1*cos 2t + K2*sin 2t). The solution then grows linearly in amplitude: this is physical resonance, treated in oscillators and resonance.

Python The overlap rule in action

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Initial conditions come last

Apply y(t0) and y'(t0) to the full solution y_h + y_p, never to y_h alone. For y'' - 3*y' + 2*y = 4*e**(3*t), y(0) = 0, y'(0) = 0: C1 + C2 + 2 = 0 and C1 + 2*C2 + 6 = 0, so C2 = -4, C1 = 2.

Python Full IVP with forcing

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Limits of the method

Undetermined coefficients works only when g(t) is built from polynomials, exponentials, sines and cosines, and when the coefficients are constant. For g(t) = tan(t), ln(t) or 1/t, use variation of parameters, which always works. Laplace transforms (next chapter) handle discontinuous forcing smoothly.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a correct guess for y_p in y'' + y = 3*cos(2t)?

    Derivatives of cosines produce sines, so both cos and sin must be in the guess. There is no overlap since the natural frequency is 1.
  2. 2. For y'' - y = e**t the guess for y_p is

    e**t solves y'' - y = 0 (root r = 1), so the guess must be multiplied by t.
  3. 3. Initial conditions are applied to

    Only the complete solution has to satisfy the initial data.
  4. 4. For forcing g(t) = tan(t), undetermined coefficients

    tan(t) does not have a finite family of derivatives, so no finite guess exists.

Summary

  • General solution of a forced linear equation: y = y_h + y_p.
  • Guess y_p of the same type as g(t); include both cos and sin for sinusoids and all lower powers for polynomials.
  • If the guess overlaps the homogeneous solution, multiply by t (resonance rule).
  • Match coefficients to solve for the constants; apply initial conditions to the complete solution.
  • For forcing like tan t or 1/t, use variation of parameters.

Next: Variation of Parameters