---
title: "Nonhomogeneous Equations: Undetermined Coefficients"
module: Second-Order Linear Equations
moduleNumber: 3
lessonNumber: 3
order: 303
summary: >
  The general solution of a nonhomogeneous linear equation is a complementary
  solution plus any one particular solution. When the forcing term is a
  polynomial, exponential, sine, or cosine, a particular solution can be found by
  assuming a trial form of the same shape with unknown coefficients and solving
  for them. The one complication is resonance, handled by multiplying the trial
  by a power of $t$.
topics: [Second-Order Linear Equations]
draft: false
sources:
  - book: Boyce
    ref: "Ch. 3 — §3.5 Nonhomogeneous Equations; Method of Undetermined Coefficients"
  - book: Simmons
    ref: "Ch. 3 §18 The Method of Undetermined Coefficients"
---

Adding a forcing term to the homogeneous equation gives the **nonhomogeneous**
equation

$$
L[y] = y'' + p(t)y' + q(t)y = g(t), \qquad g \not\equiv 0. \tag{N}
$$

Physically $g$ is an external input: a driving force on a spring, an applied
voltage on a circuit. The problem splits into two parts. One is the general
solution of the homogeneous version. The other is a single particular solution
of (N), and for a useful class of forcing functions it comes from an educated
guess — the method of undetermined coefficients — together with one correction
for when the guess collides with the homogeneous solution.

## The structure of the general solution

Two solutions of (N) differ by a solution of the homogeneous equation, because
$L$ is linear: $L[Y_1 - Y_2] = L[Y_1] - L[Y_2] = g - g = 0$. That
observation determines the entire solution set.

> **Theorem (Difference of solutions).** If $Y_1$ and $Y_2$ both solve the
> nonhomogeneous equation (N), then $Y_1 - Y_2$ solves the corresponding
> homogeneous equation. If $y_1, y_2$ are a fundamental set for the homogeneous
> equation, then $Y_1 - Y_2 = c_1 y_1 + c_2 y_2$ for some constants.

Fix one particular solution $Y$. Any other solution $\phi$ satisfies
$\phi - Y = c_1 y_1 + c_2 y_2$, so $\phi = c_1 y_1 + c_2 y_2 + Y$. This is the
general solution.

> **Theorem (General solution of the nonhomogeneous equation).** The general
> solution of (N) is
> $$
> y = \underbrace{c_1 y_1(t) + c_2 y_2(t)}_{y_c(t)} + \underbrace{Y(t)}_{\text{particular}},
> $$
> where $y_1, y_2$ form a fundamental set of the homogeneous equation and $Y$ is
> any particular solution of (N).

The two pieces have names.

- **Complementary solution** $y_c = c_1 y_1 + c_2 y_2$: the general homogeneous
  solution, carrying both arbitrary constants and therefore all the freedom to
  meet initial conditions.
- **Particular solution** $Y$: one specific solution of the full equation (N),
  with no free constants.

Solving (N) therefore takes three steps: find $y_c$, find any $Y$, and add
them. Initial conditions are applied only at the very end, to the sum, because
$y_c$ carries the adjustable constants. Applying them to $Y$ alone or to
$y_c$ alone is a common error.

$$
% caption: The general nonhomogeneous solution is the complementary solution
% (all of the homogeneous freedom) plus one particular solution of the forced
% equation.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  box/.style={draw, minimum width=30mm, minimum height=13mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[box] (yc) at (0,0) {complementary\\ $y_c = c_1 y_1 + c_2 y_2$\\ solves $L[y]=0$};
  \node[font=\large] (plus) at (3.5,0) {$+$};
  \node[box] (yp) at (7,0) {particular\\ $Y$\\ solves $L[y]=g$};
  \node[box, draw=acc, text=acc, thick] (gen) at (12,0) {general solution\\ $y = y_c + Y$};
  \draw[->, thick] (yp) -- (gen);
  \draw[->, thick] (yc.east) -- ++(0.9,0);
\end{tikzpicture}
$$

## The trial-form guess

The **method of undetermined coefficients** finds $Y$ by assuming it has the
same functional shape as $g$, with unknown coefficients, then substituting to
pin the coefficients down. It works because the derivatives of exponentials,
sines, cosines, and polynomials stay within the same small families, so
$L[Y]$ has the same shape as $Y$ and matching it to $g$ gives linear equations
for the unknowns. The method is limited to constant-coefficient equations and to
forcing terms of these types, but that covers a large share of applications.

> **Worked example (Exponential forcing).** Find a particular solution of
> $y'' - 3y' - 4y = 3e^{2t}$. Since the exponential reproduces itself under
> differentiation, try $Y = Ae^{2t}$. Then $Y' = 2Ae^{2t}$, $Y'' = 4Ae^{2t}$,
> and
> $$
> Y'' - 3Y' - 4Y = (4A - 6A - 4A)e^{2t} = -6Ae^{2t} = 3e^{2t},
> $$
> so $A = -\tfrac{1}{2}$ and $Y = -\tfrac{1}{2}e^{2t}$.

> **Worked example (Polynomial forcing).** Find a particular solution of
> $y'' - 3y' - 4y = 4t^2 - 1$. A degree-2 forcing needs the full degree-2 trial
> $Y = At^2 + Bt + C$, since differentiation feeds the lower-degree terms back.
> Then $Y' = 2At + B$, $Y'' = 2A$, and
> $$
> Y'' - 3Y' - 4Y = -4A\,t^2 + (-6A - 4B)\,t + (2A - 3B - 4C) = 4t^2 - 1.
> $$
> Matching powers of $t$ gives $-4A = 4$, $-6A - 4B = 0$, and
> $2A - 3B - 4C = -1$, so $A = -1$, $B = \tfrac{3}{2}$, $C = -\tfrac{11}{8}$ and
> $$
> Y = -t^2 + \tfrac{3}{2}t - \tfrac{11}{8}.
> $$

> **Worked example (Sine forcing needs a cosine too).** Find a particular
> solution of
> $y'' - 3y' - 4y = 2\sin t$. The guess $Y = A\sin t$ fails: substituting
> produces a stray $\cos t$ term that cannot be cancelled. Differentiation mixes
> sine and cosine, so the trial must include both:
> $Y = A\sin t + B\cos t$. Substituting and matching the $\sin t$ and $\cos t$
> coefficients gives $-5A + 3B = 2$ and $-3A - 5B = 0$, so
> $A = -\tfrac{5}{17}$, $B = \tfrac{3}{17}$ and
> $Y = -\tfrac{5}{17}\sin t + \tfrac{3}{17}\cos t$.

$$
% caption: Differentiation cycles sine and cosine into each other (up to sign),
% so a trigonometric trial must carry both terms to close under $L$.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{2A6F97}
  \node[draw, minimum width=18mm, minimum height=9mm] (s) at (0,0) {$\sin bt$};
  \node[draw, minimum width=18mm, minimum height=9mm] (c) at (4.4,0) {$\cos bt$};
  \draw[->, thick] (s.north east) to[bend left=28] node[above, font=\scriptsize, text=black] {derivative} (c.north west);
  \draw[->, thick] (c.south west) to[bend left=28] node[below, font=\scriptsize, text=black] {derivative} (s.south east);
\end{tikzpicture}
$$

Closure under differentiation determines every trial form. A polynomial of
degree $n$ needs a full degree-$n$ trial
$A_0 t^n + \cdots + A_n$ (all lower terms, since differentiation feeds them
back), and a product such as $e^{\alpha t}\cos(\beta t)$ needs both
$e^{\alpha t}\cos(\beta t)$ and $e^{\alpha t}\sin(\beta t)$.

$$
% caption: Each forcing type maps to a trial solution closed under
% differentiation, with $a, b$ real constants; the coefficients $A, B$ are
% solved for by substitution.
\begin{tikzpicture}[>=stealth, font=\footnotesize,
  fbox/.style={draw, minimum width=40mm, minimum height=9mm, align=center, font=\scriptsize},
  tbox/.style={draw, minimum width=52mm, minimum height=9mm, align=center, font=\scriptsize}]
  \definecolor{acc}{HTML}{2A6F97}
  \node[fbox] (g1) at (0,2.4) {$g = P_n(t)$ (degree $n$)};
  \node[fbox] (g2) at (0,1.2) {$g = e^{at}$};
  \node[fbox] (g3) at (0,0.0) {$g = \sin bt$ or $\cos bt$};
  \node[fbox] (g4) at (0,-1.2) {$g = e^{at}\cos bt$};
  \node[tbox] (t1) at (7.2,2.4) {$A_0 t^n + A_1 t^{n-1} + \cdots + A_n$};
  \node[tbox] (t2) at (7.2,1.2) {$A\,e^{at}$};
  \node[tbox] (t3) at (7.2,0.0) {$A\sin bt + B\cos bt$};
  \node[tbox] (t4) at (7.2,-1.2) {$e^{at}(A\cos bt + B\sin bt)$};
  \foreach \i in {1,2,3,4} \draw[->, thick] (g\i) -- (t\i);
\end{tikzpicture}
$$

## Sums and products of forcing terms

If the forcing is a sum $g = g_1 + g_2$, solve one equation per term and add the
particular solutions. This follows from linearity: if $L[Y_1] = g_1$ and
$L[Y_2] = g_2$, then $L[Y_1 + Y_2] = g_1 + g_2$.

A _product_ of types, by contrast, stays together: $g = t e^{\alpha t}$ is one
term needing the trial $(A_0 t + A_1)e^{\alpha t}$, not a sum of separate
guesses. A product with a trigonometric factor needs both the sine and cosine
versions.

> **Worked example (Product forcing).** Find a particular solution of
> $y'' - 3y' - 4y = -8e^{t}\cos 2t$. The trial pairs the exponential with both
> a sine and a cosine: $Y = e^{t}(A\cos 2t + B\sin 2t)$. Differentiating,
> $$
> Y'' - 3Y' - 4Y
>   = e^{t}\bigl[(-10A - 2B)\cos 2t + (2A - 10B)\sin 2t\bigr] = -8e^{t}\cos 2t.
> $$
> Matching the $\cos 2t$ and $\sin 2t$ coefficients gives $-10A - 2B = -8$ and
> $2A - 10B = 0$, so $A = \tfrac{10}{13}$, $B = \tfrac{2}{13}$ and
> $$
> Y = e^{t}\Bigl(\tfrac{10}{13}\cos 2t + \tfrac{2}{13}\sin 2t\Bigr).
> $$

> **Worked example (Sum of forcing terms).** For
> $y'' - 3y' - 4y = 3e^{2t} + 2\sin t - 8e^{t}\cos 2t$, solve one equation per
> term and add. The three particular pieces are the three worked above, so
> $$
> Y = -\tfrac{1}{2}e^{2t} + \tfrac{3}{17}\cos t - \tfrac{5}{17}\sin t
>   + \tfrac{10}{13}e^t\cos 2t + \tfrac{2}{13}e^t\sin 2t.
> $$

## Resonance and the multiplicity correction

The method has one failure mode, and it is physically important.

> **Worked example (Guess collides with the homogeneous solution).** Find a particular
> solution of $y'' - 3y' - 4y = 2e^{-t}$. The natural guess $Y = Ae^{-t}$ gives
> $$
> Y'' - 3Y' - 4Y = (A + 3A - 4A)e^{-t} = 0 \neq 2e^{-t}.
> $$
> No choice of $A$ works. The reason: $e^{-t}$ is a solution of the homogeneous
> equation (its characteristic roots are $-1$ and $4$), so $L$ annihilates the
> trial. To fix this, multiply the trial by $t$: take $Y = Ate^{-t}$. Then
> $Y' = (A - At)e^{-t}$, $Y'' = (-2A + At)e^{-t}$, and
> $$
> Y'' - 3Y' - 4Y = -5Ae^{-t} = 2e^{-t}, \qquad A = -\tfrac{2}{5},
> $$
> so $Y = -\tfrac{2}{5}te^{-t}$.

This is **resonance**: when the forcing frequency matches a natural mode of the
system, the response grows with $t$ instead of staying bounded, and the trial
solution must carry an explicit factor of $t$ to reflect it. The general rule:

> **Rule (Multiplicity correction).** Form the trial solution as usual. If any
> term of it duplicates a solution of the homogeneous equation, multiply the
> whole trial by $t$. If duplication persists (a repeated characteristic root),
> multiply by $t$ a second time. For a second-order equation, $t^2$ is the most
> ever needed.

The correction tracks the multiplicity of the offending root. If $e^{\alpha t}$
is a simple root of the characteristic equation, one factor of $t$ suffices; if
it is a double root (so both $e^{\alpha t}$ and $t e^{\alpha t}$ solve the
homogeneous equation), two are needed.

$$
% caption: The naive trial $Ae^{-t}$ lies in the homogeneous solution space, so
% $L$ sends it to zero; multiplying by $t$ moves it out and produces a genuine
% response.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{2A6F97}
  % homogeneous solution plane
  \draw[black, fill=black!6] (-0.3,-0.3) -- (3.6,0.4) -- (3.0,2.2) -- (-0.9,1.5) -- cycle;
  \node[black, anchor=west, font=\scriptsize] at (2.0,0.3) {homogeneous solutions};
  \node[black, font=\scriptsize] at (1.2,1.1) {$L[\,\cdot\,]=0$};
  % naive guess inside plane
  \draw[->, black, very thick] (1.2,0.8) -- (2.6,1.15);
  \node[black, anchor=south, font=\scriptsize] at (2.6,1.15) {$Ae^{-t}$};
  % corrected guess pointing out of plane
  \draw[->, acc, very thick] (1.2,0.8) -- (1.9,2.6);
  \node[acc, anchor=south, font=\scriptsize] at (1.9,2.6) {$At e^{-t}$};
  \node[acc, anchor=west, font=\scriptsize] at (2.1,2.0) {leaves the plane};
\end{tikzpicture}
$$

When the complementary and particular parts are plotted together, the resonant
particular solution is visibly the growing one: the complementary exponential
decays while $t e^{-t}$ first rises.

$$
% caption: For the resonant equation, the complementary part decays while the
% particular part $t e^{-t}$ grows before decaying; their sum is the full
% response.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
  \definecolor{acc}{HTML}{2A6F97}
  \draw[->, thick] (-0.3,0) -- (6.2,0) node[right] {$t$};
  \draw[->, thick] (0,-0.3) -- (0,2.5) node[above] {$y$};
  % complementary e^{-t} decaying
  \draw[black, dashed, thick] (0,2.0) .. controls (0.9,1.1) and (2.0,0.5) .. (3.2,0.28)
    .. controls (4.2,0.15) and (5.2,0.09) .. (6.0,0.06);
  \node[black, anchor=west, font=\scriptsize] at (2.4,0.5) {$y_c$ (decays)};
  % particular |t e^{-t}| rising then decaying
  \draw[acc, very thick] (0,0) .. controls (0.4,0.85) and (0.95,1.35) .. (1.5,1.38)
    .. controls (2.4,1.35) and (3.4,0.8) .. (4.3,0.45)
    .. controls (5.0,0.28) and (5.6,0.18) .. (6.0,0.14);
  \node[acc, anchor=south, font=\scriptsize] at (1.5,1.4) {$Y = -\tfrac{2}{5}t e^{-t}$};
\end{tikzpicture}
$$

## Trial-solution reference

The table collects the standard trials, before any multiplicity correction.
$P_n$ denotes a general polynomial of degree $n$, and $\tilde{P}_n$ the general
polynomial trial $A_0 t^n + \cdots + A_n$ of the same degree.

| Forcing term $g(t)$ | Trial solution $Y(t)$ |
| --- | --- |
| $P_n(t)$ | $\tilde{P}_n(t)$ |
| $e^{\alpha t}$ | $A e^{\alpha t}$ |
| $P_n(t)\, e^{\alpha t}$ | $\tilde{P}_n(t)\, e^{\alpha t}$ |
| $\sin\beta t$ or $\cos\beta t$ | $A\sin\beta t + B\cos\beta t$ |
| $e^{\alpha t}\sin\beta t$ or $e^{\alpha t}\cos\beta t$ | $e^{\alpha t}(A\sin\beta t + B\cos\beta t)$ |
| $P_n(t)\, e^{\alpha t}\sin\beta t$ | $e^{\alpha t}\big(\tilde{P}_n\sin\beta t + \tilde{Q}_n\cos\beta t\big)$ |

In every row: if a term of the trial already solves the homogeneous equation,
multiply the row's trial by $t$ (or $t^2$ for a double root) before solving for
the coefficients.

The method is fast when the trial form is easy to write down, but it fails when
$g$ falls outside these families, for instance $g(t) = \tan t$ or
$g(t) = 1/t$. The
[variation of parameters](/differential-equations/second-order-linear/variation-of-parameters)
method removes that restriction at the cost of evaluating two
integrals.[^boyce35][^simmons18]

[^boyce35]: **Boyce**, _Elementary Differential Equations_, §3.5 — Nonhomogeneous Equations; Method of Undetermined Coefficients: the complementary-plus-particular structure (Theorems 3.5.1–3.5.2), the trial-form guesses for polynomial/exponential/trigonometric forcing, sums of forcing terms, and the multiply-by-$t$ resonance correction.
[^simmons18]: **Simmons**, _Differential Equations with Applications and Historical Notes_, §18 — The Method of Undetermined Coefficients: assuming a particular solution of the same form as the forcing term and determining its coefficients by substitution.
