Differential Equations · Undergraduate

Nonhomogeneous Equations and Undetermined Coefficients

Quick answer

The general solution of ay″ + by′ + cy = g(x) is the homogeneous solution y_h plus any one particular solution y_p. When g is a polynomial, an exponential, a sine or cosine, or a product of these, y_p has the same form with unknown coefficients; substituting the guess and matching terms finds them. If the guess already solves the homogeneous equation, multiply it by x. Initial conditions are applied to the full solution y_h + y_p, last.

What you'll learn

  • Explain why the general solution is y_h + y_p
  • Choose the form of y_p from the right-hand side
  • Find the coefficients by substituting and matching terms
  • Fix a guess that overlaps the homogeneous solution by multiplying by x

A homogeneous part plus one particular solution

When the right side is not zero,

ay′′+by′+cy=g(x)ay'' + by' + cy = g(x)

the equation is nonhomogeneous. Its general solution has two parts:

y=yh+ypy = y_h + y_p

where yhy_h is the general solution of the homogeneous equation (with gg replaced by 00) and ypy_p is any one solution of the full equation.

Why one particular solution is enough

If ypy_p and yy both solve the full equation, subtract: by linearity, y−ypy - y_p solves the equation with right side g−g=0g - g = 0. So y−ypy - y_p is one of the homogeneous solutions, and y=yp+yhy = y_p + y_h. Every solution is the one particular solution shifted by a homogeneous solution, the same way every solution of a linear system Ax=bA\mathbf{x} = \mathbf{b} is one solution plus the null space. Finding a single ypy_p, by any means, finishes the problem.

Guessing the form

The derivatives of polynomials, exponentials, sines and cosines stay in the same family, so ypy_p can be guessed with unknown coefficients:

g(x)g(x)Guess for ypy_p
constantAA
polynomial of degree nnAnxn+⋯+A1x+A0A_nx^n + \cdots + A_1x + A_0
ekxe^{kx}AekxAe^{kx}
sin⁡ωx\sin\omega x or cos⁡ωx\cos\omega xAcos⁡ωx+Bsin⁡ωxA\cos\omega x + B\sin\omega x

The overlap rule: if any term of the guess already solves the homogeneous equation, multiply the whole guess by xx, and by xx again if needed.

Worked examples

Common mistakes

Practice problems

  1. Find a particular solution of y′′+y=5y'' + y = 5.

    Answer

    yp=5y_p = 5

    Full solution

    Guess AA: 0+A=50 + A = 5.

  2. Find a particular solution of y′′−4y=8xy'' - 4y = 8x.

    Answer

    yp=−2xy_p = -2x

    Full solution

    Guess Ax+BAx + B: −4Ax−4B=8x-4Ax - 4B = 8x, so A=−2A = -2, B=0B = 0.

  3. Find a particular solution of y′′+3y′+2y=6exy'' + 3y' + 2y = 6e^x.

    Answer

    yp=exy_p = e^x

    Full solution

    Guess AexAe^x: (1+3+2)A=6(1 + 3 + 2)A = 6.

  4. Find a particular solution of y′′+y=cos⁡2xy'' + y = \cos 2x.

    Answer

    yp=−13cos⁡2xy_p = -\tfrac{1}{3}\cos 2x

    Full solution

    Guess Acos⁡2x+Bsin⁡2xA\cos 2x + B\sin 2x: (−4+1)Acos⁡2x+(−4+1)Bsin⁡2x=cos⁡2x(-4 + 1)A\cos 2x + (-4 + 1)B\sin 2x = \cos 2x, so A=−13A = -\tfrac{1}{3}, B=0B = 0.

  5. Find a particular solution of y′′+2y′=4xy'' + 2y' = 4x.

    Answer

    yp=x2−xy_p = x^2 - x

    Full solution

    A constant solves the homogeneous equation (root 00), so guess x(Ax+B)x(Ax + B). Then 2A+2(2Ax+B)=4x2A + 2(2Ax + B) = 4x gives A=1A = 1, B=−1B = -1.

  6. Find a particular solution of y′′+y=sin⁡xy'' + y = \sin x.

    Answer

    yp=−x2cos⁡xy_p = -\tfrac{x}{2}\cos x

    Full solution

    sin⁡x\sin x solves the homogeneous equation, so guess x(Acos⁡x+Bsin⁡x)x(A\cos x + B\sin x). Substituting gives −2Asin⁡x+2Bcos⁡x=sin⁡x-2A\sin x + 2B\cos x = \sin x.

  7. Write, without solving, the form of ypy_p for y′′−4y′+4y=e2xy'' - 4y' + 4y = e^{2x}.

    Answer

    yp=Ax2e2xy_p = Ax^2e^{2x}

    Full solution

    22 is a double root, so both e2xe^{2x} and xe2xxe^{2x} solve the homogeneous equation. Multiply by x2x^2.

  8. A student guesses yp=Aexy_p = Ae^x for y′′−3y′+2y=exy'' - 3y' + 2y = e^x and gets 0=ex0 = e^x. What went wrong?

    Answer

    exe^x solves the homogeneous equation; the guess must be AxexAxe^x, giving yp=−xexy_p = -xe^x.

    Full solution

    Substituting a homogeneous solution always gives 00 on the left. Multiplying by xx creates a function that does not.

Frequently asked questions

What is the general solution of a nonhomogeneous equation?

y = y_h + y_p: the general solution of the homogeneous equation, with its two constants, plus any one particular solution of the full equation.

How do you choose the form of the particular solution?

Copy the form of g(x) with unknown coefficients: a polynomial of the same degree for a polynomial, Ae^(kx) for e^(kx), and A cos ωx + B sin ωx for either sin ωx or cos ωx.

What do you do if the guess solves the homogeneous equation?

Multiply the guess by x, or by x² if x times the guess still solves it. Otherwise substituting gives 0 on the left and no coefficient can match g.

When do you apply the initial conditions?

After adding y_h and y_p. The constants belong to y_h, but the conditions describe the whole solution.

Why must a sine guess include a cosine too?

Differentiating sin turns it into cos, so both appear after substitution. The guess needs both to have enough freedom to match.

What to learn next