OpenStax Calculus 3

Chapter 7: Second-Order Differential Equations

7.2 Nonhomogeneous Linear Equations

Study guide for Calculus Volume 3 (Gilbert Strang, 2016 edition)

Independent study guide. Not affiliated with OpenStax or Rice University.

Big idea

Put a nonzero function on the right side of a second-order linear equation and superposition breaks. Adding two solutions of $y'' + py' + qy = g(x)$ gives a function whose left side is $2g(x)$, not $g(x)$, so the vector-space picture from the homogeneous case does not survive intact.

What survives is the whole content of this section. Suppose $y_p$ is any solution of the nonhomogeneous equation and $y$ is another. Their difference makes the left side $g - g = 0$, so it solves the homogeneous equation. Every solution is therefore one fixed particular solution plus something from the homogeneous family: a two-parameter set shifted off the origin by one representative, the way the solution set of $A\mathbf{x} = \mathbf{b}$ is a particular solution plus the null space.

That reduces the work to one question: find a single solution. Undetermined coefficients is a guess with adjustable constants, and it works whenever the right side reproduces its own shape under differentiation: polynomials, exponentials, sines and cosines, and products of those. Write a trial form of the same shape, substitute, and solve for the coefficients.

The guess has one failure mode, and it is the step students lose marks on. If the trial form already solves the homogeneous equation, substituting it gives zero rather than $g(x)$, and no constants can rescue it. The repair is to multiply by $x$ until the collision clears. For right-hand sides outside that family, such as $\sec x$, no trial form exists at all, and variation of parameters produces a particular solution by integration instead of by guesswork.

Decoder

The general solution of a nonhomogeneous linear equation is the general solution of the matching homogeneous equation plus any one solution of the nonhomogeneous equation.

The phrase “any one” is the part to trust. Two people can produce particular solutions differing by $4e^{2x}$ and both be right; the discrepancy is absorbed into the constant multiplying $e^{2x}$ in the complementary part. Never worry that your particular solution is the wrong one.

“Matching homogeneous equation” means: keep the left side, replace $g(x)$ by zero. That piece is the complementary solution $y_c$. Solving for it is not optional even when you only want a particular solution, because $y_c$ is what tells you whether a collision is coming. Find it first, always.

The classic mistake is fitting initial conditions to $y_c$ alone and only then adding $y_p$. The constants belong to the complete sum $y = y_c + y_p$; fitting them early gives a function that satisfies the conditions but not the equation.

Definitions and results

The structure of the general solution. For $y'' + p(x)y' + q(x)y = g(x)$ with $y_c = c_1 y_1 + c_2 y_2$ solving the homogeneous version and $y_p$ any particular solution,

$$ y = c_1 y_1 + c_2 y_2 + y_p $$

is the general solution, by the subtraction argument above.

Superposition on the right side. If $y_{p1}$ handles right side $g_1$ and $y_{p2}$ handles $g_2$, then $y_{p1} + y_{p2}$ handles $g_1 + g_2$, so a right side like $x^2 + e^{3x}$ splits into two independent passes.

Trial forms for undetermined coefficients. Match the shape of $g(x)$, always with the complete general form rather than only the terms that appear:

$$ \begin{array}{ll} g(x) = \text{polynomial of degree } n & y_p = A_n x^n + \cdots + A_1 x + A_0 \\ g(x) = ae^{kx} & y_p = Ae^{kx} \\ g(x) = a\cos kx \ \text{or}\ a\sin kx & y_p = A\cos kx + B\sin kx \\ g(x) = ae^{kx}\cos kx \ \text{or}\ ae^{kx}\sin kx & y_p = e^{kx}(A\cos kx + B\sin kx) \\ g(x) = \text{polynomial} \times e^{kx} & y_p = (A_n x^n + \cdots + A_0)e^{kx} \end{array} $$

A sine on the right needs a cosine in the trial form and vice versa, since differentiating mixes them. A right side of $5x^2$ needs the full quadratic $Ax^2 + Bx + C$, not just $Ax^2$.

The multiply-by-$x$ rule. If any term of the trial form already appears in $y_c$, multiply the whole trial form by $x$; if a term still collides, multiply by $x$ again. For constant coefficients the exponent never exceeds $2$, since the characteristic equation has at most a double root.

Solving for the coefficients. Substitute the trial form into the left side, collect like terms, and match each independent function separately: the $x^2$ terms give one equation, the $x$ terms another, the constants another, and $\cos kx$ and $\sin kx$ each their own.

Where undetermined coefficients stops. The method needs $g(x)$ to have finitely many independent derivatives. That holds for polynomials, exponentials, sines, cosines and their products; it fails for $\tan x$, $\sec x$, $\ln x$ and $1/x$.

Variation of parameters. Given a fundamental set $y_1, y_2$ with Wronskian $W = y_1 y_2' - y_1' y_2$, and the equation in standard form, a particular solution is

$$ y_p = -y_1 \int \frac{y_2\, g(x)}{W}\, dx + y_2 \int \frac{y_1\, g(x)}{W}\, dx $$

The idea is to replace the constants $c_1, c_2$ by functions $u_1, u_2$ and impose the extra condition $u_1' y_1 + u_2' y_2 = 0$, reducing the substitution to a linear system with solution $u_1' = -y_2 g/W$ and $u_2' = y_1 g/W$.

Standard form matters. Both methods assume the coefficient of $y''$ is $1$ before $g(x)$ is read off. For $3y'' + y = 12x$, divide through first; reading $g = 12x$ off the undivided equation inflates the answer by a factor of $3$.

Worked examples

A polynomial on the right

Solve $y'' - y' - 2y = 4x^2$.

First the complementary solution: $r^2 - r - 2 = (r-2)(r+1)$, so $y_c = c_1 e^{2x} + c_2 e^{-x}$, which holds no polynomial and cannot collide. Try $y_p = Ax^2 + Bx + C$, with $y_p' = 2Ax + B$ and $y_p'' = 2A$:

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

Match against $4x^2 + 0x + 0$: the $x^2$ terms give $A = -2$, the $x$ terms give $4 - 2B = 0$ so $B = 2$, and the constants give $-4 - 2 - 2C = 0$ so $C = -3$:

$$ y = c_1 e^{2x} + c_2 e^{-x} - 2x^2 + 2x - 3 $$

Check $y_p$: $-4 - (-4x + 2) - 2(-2x^2 + 2x - 3) = -4 + 4x - 2 + 4x^2 - 4x + 6 = 4x^2$.

When the guess collides with the complementary solution

Solve $y'' - y' - 2y = 6e^{2x}$.

The complementary solution is the same, $y_c = c_1 e^{2x} + c_2 e^{-x}$. The natural trial form $Ae^{2x}$ is already in there, so substituting it returns $0$, never $6e^{2x}$. Multiply by $x$ and try $y_p = Axe^{2x}$, with $y_p' = A(e^{2x} + 2xe^{2x})$ and $y_p'' = A(4e^{2x} + 4xe^{2x})$. Grouping the $xe^{2x}$ terms apart from the $e^{2x}$ terms:

$$ A\left[4e^{2x} + 4xe^{2x} - e^{2x} - 2xe^{2x} - 2xe^{2x}\right] = A\left[3e^{2x} + 0 \cdot xe^{2x}\right] $$

The $xe^{2x}$ terms cancel, which they must: $e^{2x}$ solves the homogeneous equation, so its coefficient can carry no information. That leaves $3A = 6$:

$$ y = c_1 e^{2x} + c_2 e^{-x} + 2xe^{2x} $$

The habit worth building is to compute $y_c$ before writing any trial form and compare the two lists term by term. Skipping that comparison produces a contradiction like $0 = 6e^{2x}$ several lines later.

A trigonometric right-hand side

Solve $y'' + 4y = 10\sin 3x$. Here $r = \pm 2i$ and $y_c = c_1 \cos 2x + c_2 \sin 2x$; the forcing frequency is $3$, not $2$, so nothing collides. With $y_p = A\cos 3x + B\sin 3x$, the left side is $-5A\cos 3x - 5B\sin 3x$, so $A = 0$, $B = -2$, and $y = c_1\cos 2x + c_2 \sin 2x - 2\sin 3x$. The cosine had to be carried even though its coefficient came out zero; with a $y'$ term present both would be nonzero.

A right-hand side no trial form reaches

Solve $y'' + y = \sec x$ on an interval where $\cos x > 0$.

There is no finite trial form for $\sec x$; its derivatives keep producing new functions. Use variation of parameters with $y_1 = \cos x$, $y_2 = \sin x$ and $W = \cos^2 x + \sin^2 x = 1$. Then $u_1' = -y_2 g/W = -\sin x \sec x = -\tan x$, so $u_1 = \ln|\cos x|$, and $u_2' = y_1 g / W = \cos x \sec x = 1$, so $u_2 = x$. Therefore

$$ y_p = \cos x \ln|\cos x| + x\sin x, \qquad y = c_1 \cos x + c_2 \sin x + \cos x \ln|\cos x| + x \sin x $$

Check by differentiating. Two terms cancel in the first derivative, leaving $y_p' = -\sin x\ln|\cos x| + x\cos x$, and then

$$ y_p'' = -\cos x \ln|\cos x| + \frac{\sin^2 x}{\cos x} + \cos x - x\sin x $$

Adding $y_p$ cancels the logarithm and the $x$ terms, leaving $(\sin^2 x + \cos^2 x)/\cos x = \sec x$.

Practice

Begin with trial forms. Find the complementary solution, choose a trial form matching the right side, apply the multiply-by-$x$ rule if it collides, and solve for the coefficients.

Practice

Generated problems for this section, graded instantly.

Then the integral method, for right-hand sides no trial form reaches. Compute the Wronskian, set up the two integrals, and evaluate them.

Practice

Generated problems for this section, graded instantly.

Quiz

Five items on the structure of the general solution, trial forms including collisions, and variation of parameters.

Quiz

5 problems with a score at the end.