Forcing functions, complementary and particular solutions, undetermined coefficients, resonance, variation of parameters, and the mathematics of driven systems
Every system in the real world receives input. A spring is pushed. A circuit is connected to a power source. A population faces seasonal forcing. A mechanical structure vibrates under an external load. The differential equations that describe these systems are not homogeneous. They are nonhomogeneous equations, equations where the right side is not zero but a function that drives or forces the system.
Chapter 8 builds directly on the work of Chapters 6 and 7. Those chapters established the theory and behavior of homogeneous second-order equations, equations of the form $ay'' + by' + cy = 0$, where the system evolves entirely on its own. This chapter introduces what happens when a forcing function $g(x)$ appears on the right side: $ay'' + by' + cy = g(x)$.
The central insight of this chapter is structural. The complete response of a nonhomogeneous system is always the sum of two parts: the natural behavior of the system without forcing, called the complementary solution, and a particular response to the specific forcing function, called the particular solution. Understanding this structure is as important as knowing how to compute it.
The main solution strategy introduced in this chapter is the method of undetermined coefficients, a powerful and systematic method for finding particular solutions when the forcing function belongs to a recognizable family of functions such as polynomials, exponentials, sines and cosines, and their combinations. A second strategy, variation of parameters, is introduced at the end of the chapter as a more general method that applies to forcing functions not handled by undetermined coefficients.
This chapter also introduces the resonance phenomenon, a situation where the forcing function matches the natural behavior of the system and the particular solution must be modified. Resonance is one of the most important ideas in applied differential equations, with consequences for mechanical design, electrical engineering, and structural safety.
A mass on a spring is pulled slightly and released. Without any external influence, it oscillates with gradually decreasing amplitude because of friction in the system. Now, suppose someone begins pushing the spring periodically with a force that varies as a cosine function of time. What happens to the motion? Does the same oscillation continue, or does the driving force change the behavior? If the driving frequency matches the natural frequency of the spring, something remarkable happens. This chapter explains the mathematics behind that phenomenon and provides the tools to analyze it precisely.
A second-order linear differential equation with constant coefficients has the general form
where $a$, $b$, and $c$ are constants with $a \neq 0$, and $g(x)$ is a function of the independent variable $x$.
When $g(x) = 0$, the equation is called homogeneous. This is the equation studied throughout Chapters 6 and 7. Its solutions describe how a system evolves from given initial conditions with no external driving force. The solutions are built entirely from the characteristic roots $r_1$ and $r_2$ of the characteristic equation $ar^2 + br + c = 0$.
When $g(x) \neq 0$, the equation is called nonhomogeneous. The function $g(x)$ is called the forcing function or the input. It represents something outside the system that is being applied to it, an external force, a voltage source, a periodic push, a constant load, or any function that drives the system's behavior.
The key difference between homogeneous and nonhomogeneous equations is not just computational. It is conceptual. A homogeneous equation describes a system that is free, evolving on its own from initial conditions. A nonhomogeneous equation describes a system that is driven, responding to both its own natural tendency and to an imposed input.
| Equation | Forcing Function $g(x)$ | Type of Forcing |
|---|---|---|
| $y'' + 4y' + 4y = e^{2x}$ | $e^{2x}$ | Exponential |
| $y'' - y = 3x^2 + 1$ | $3x^2 + 1$ | Polynomial |
| $y'' + 9y = \cos(2x)$ | $\cos(2x)$ | Trigonometric |
| $2y'' + 3y' - y = xe^x - 5$ | $xe^x - 5$ | Mixed |
A nonlinear equation such as $y'' + y^2 = \sin(x)$ is not covered by the linear theory of this chapter. The methods here apply specifically to linear equations, where the left side is linear in $y$, $y'$, and $y''$.
Students sometimes confuse the term "nonhomogeneous" with "complicated." Many nonhomogeneous equations are actually not difficult once you know the method. The right side $g(x)$ gives you information. It tells you what kind of particular solution to expect. Recognizing the type of forcing function is one of the most important skills in this chapter.
Before solving a nonhomogeneous equation, it is necessary to solve the associated homogeneous equation, obtained by replacing the right side with zero. The general solution of this homogeneous equation is called the complementary solution and is written $y_c$.
The complementary solution is determined by the characteristic equation $ar^2 + br + c = 0$. The form of $y_c$ depends on the nature of the roots.
Case 1: Two real distinct roots $r_1 \neq r_2$.
$$y_c = C_1 e^{r_1 x} + C_2 e^{r_2 x}$$
Case 2: One repeated real root $r_1 = r_2 = r$.
$$y_c = C_1 e^{rx} + C_2 x e^{rx}$$
Case 3: Complex conjugate roots $r = \alpha \pm \beta i$.
$$y_c = e^{\alpha x}(C_1 \cos(\beta x) + C_2 \sin(\beta x))$$
The complementary solution captures the natural behavior of the system, the way it would respond if left entirely on its own without any external forcing. In a damped mechanical system, this is the decaying oscillation. In an undamped spring, this is the steady oscillation. You cannot find the complete solution to a nonhomogeneous equation without first understanding the complementary solution.
y_c = C₁e^{−2x} + C₂e^{−3x}
A particular solution, written $y_p$, is any single function that satisfies the nonhomogeneous equation $ay'' + by' + cy = g(x)$. The word "particular" means that $y_p$ is not a family of solutions. It is one specific solution, typically with no arbitrary constants. Its entire job is to balance the equation by accounting for the forcing function $g(x)$.
Unlike the complementary solution, $y_p$ does not satisfy the homogeneous equation. If you substitute $y_p$ into $ay'' + by' + cy$, you do not get zero. You get $g(x)$.
In a physical system, the particular solution represents the forced response, the way the system behaves because of the external input. If you apply a sinusoidal voltage to a circuit, the particular solution describes the steady oscillation driven by that voltage. The particular solution depends entirely on $g(x)$. Different forcing functions produce different particular solutions.
Method of undetermined coefficients: Works when $g(x)$ is a polynomial, an exponential, a sine or cosine, or a combination. This is the primary method of this chapter.
Variation of parameters: A more general method that works for any continuous $g(x)$. Introduced in Section 8.11.
Let $y_c$ be the general solution of $ay'' + by' + cy = 0$, and let $y_p$ be any particular solution of $ay'' + by' + cy = g(x)$. Then the general solution of the nonhomogeneous equation is:
$$y = y_c + y_p$$
This is the most important equation in Chapter 8.
Why this works. Suppose $y = y_c + y_p$. Substitute into the nonhomogeneous equation. By linearity: $(ay_c'' + by_c' + cy_c) + (ay_p'' + by_p' + cy_p) = g(x)$. The first group equals zero because $y_c$ satisfies the homogeneous equation. The second group equals $g(x)$ because $y_p$ satisfies the nonhomogeneous equation. The sum is $0 + g(x) = g(x)$. The equation is satisfied.
The general solution $y = y_c + y_p$ contains exactly two arbitrary constants, both from $y_c$. The particular solution $y_p$ contributes no new constants. When initial conditions are given, substitute them into the complete expression $y_c + y_p$ and solve for $C_1$ and $C_2$.
Students sometimes apply initial conditions to $y_c$ alone, before $y_p$ has been found, and then add $y_p$ afterward. This is incorrect. Initial conditions must be applied to the complete expression $y = y_c + y_p$. The constants $C_1$ and $C_2$ depend on both $y_c$ and $y_p$ together.
y(0) = 1: C₁ + C₂ + 1/12 = 1 → C₁ + C₂ = 11/12
y′(0) = 0: −2C₁ − 3C₂ + 1/6 = 0 → −2C₁ − 3C₂ = −1/6
The method of undetermined coefficients is a strategy for finding a particular solution $y_p$ when the forcing function $g(x)$ belongs to a recognizable family. The core idea is to guess a trial solution of the same general form as $g(x)$, with unknown coefficients, and then determine those coefficients by substituting the trial solution into the differential equation.
The method works because differentiation keeps certain families of functions within themselves. Differentiating a polynomial yields a polynomial. Differentiating $e^{kx}$ yields another exponential of the same type. Differentiating $\sin(\beta x)$ or $\cos(\beta x)$ yields functions in the same trigonometric family. This predictability is what makes the guess work.
| Forcing Function $g(x)$ | Trial Form for $y_p$ |
|---|---|
| $P_n(x)$ — polynomial of degree $n$ | $A_n x^n + A_{n-1}x^{n-1} + \cdots + A_1 x + A_0$ |
| $e^{kx}$ | $Ae^{kx}$ |
| $\sin(\beta x)$ or $\cos(\beta x)$ | $A\cos(\beta x) + B\sin(\beta x)$ |
| $P_n(x)e^{kx}$ | $(A_n x^n + \cdots + A_0)e^{kx}$ |
| $e^{kx}\sin(\beta x)$ or $e^{kx}\cos(\beta x)$ | $e^{kx}(A\cos(\beta x) + B\sin(\beta x))$ |
If $g(x)$ involves $\cos(\beta x)$ alone, the trial form must still include both $\cos(\beta x)$ and $\sin(\beta x)$. Similarly for $\sin(\beta x)$ alone. Differentiation connects them, so both must be present.
1. Find $y_c$ by solving the associated homogeneous equation.
2. Identify the form of $g(x)$ and write the trial form $y_p$ with undetermined coefficients.
3. Check whether any term in $y_p$ duplicates a term in $y_c$. If so, multiply by $x$ (see Section 8.10).
4. Substitute $y_p$ into $ay'' + by' + cy = g(x)$.
5. Collect terms and match coefficients to determine the unknowns.
6. Write the general solution $y = y_c + y_p$.
7. Apply initial conditions to $y_c + y_p$ to find $C_1$ and $C_2$ if given.
When $g(x)$ is a polynomial of degree $n$, the trial particular solution is also a polynomial of degree $n$ with undetermined coefficients. Even if some intermediate terms are missing from $g(x)$, the trial form must include all terms from the highest degree down to the constant. For example, if $g(x) = x^2 + 1$, the trial form is $Ax^2 + Bx + C$, not $Ax^2 + C$, because differentiation will generate terms of all intermediate degrees when you substitute.
y_c = C₁e^{−2x} + C₂eˣ
2A + (2Ax + B) − 2(Ax² + Bx + C) = x²
−2Ax² + (2A − 2B)x + (2A + B − 2C) = x² + 0·x + 0
If the equation has the form $ay'' + by' = g(x)$, a constant trial $A$ satisfies $a(0) + b(0) + 0 = 0$, not $g(x)$. The degree of the polynomial trial form must be raised by one. If $g(x)$ is degree $n$, use a trial of degree $n+1$. This is a special instance of the resonance correction.
When $g(x) = Pe^{kx}$, the natural trial form for $y_p$ is $Ae^{kx}$. Differentiating an exponential produces another exponential with the same exponent, so substitution works cleanly.
4Ae²ˣ + 10Ae²ˣ + 6Ae²ˣ = 4e²ˣ
20Ae²ˣ = 4e²ˣ → A = 1/5
When $y_p = Ae^{kx}$ and $g(x) = Pe^{kx}$, substitution gives $A(ak^2 + bk + c) = P$, so $A = P / (ak^2 + bk + c)$, provided $ak^2 + bk + c \neq 0$. When this expression equals zero, $k$ is a characteristic root and the resonance correction is needed.
When $g(x)$ involves $\sin(\beta x)$, $\cos(\beta x)$, or a combination, the trial form must include both sine and cosine:
$$y_p = A\cos(\beta x) + B\sin(\beta x)$$The reason both are needed is that differentiation connects them. When you differentiate $\cos(\beta x)$, you get $-\beta\sin(\beta x)$. Substituting into the equation will produce terms involving both functions, and you need coefficients for both to match them.
y_c = C₁cos(2x) + C₂sin(2x)
= −5Acos(3x) − 5Bsin(3x) = cos(3x)
When $g(x)$ is a combination of different types, use the superposition principle: solve for a particular solution for each part of $g(x)$ separately, then add the results.
y_c = C₁eˣ + C₂e²ˣ
y_{p1} = e^{3x}
y_{p2} = (1/2)x + 3/4
The method of undetermined coefficients encounters a critical problem when the trial form $y_p$ happens to be a solution of the homogeneous equation. When this happens, substituting $y_p$ into $ay'' + by' + cy$ produces zero, not $g(x)$. The trial fails completely.
This situation is called resonance, and it occurs when a term in $g(x)$ matches a term in $y_c$. The correction is to multiply the offending trial form by $x$. If the problem persists (as in the case of a repeated root), multiply by $x^2$.
Before writing a trial form, compare it to $y_c$. If any term of the trial matches any term of $y_c$, multiply the entire trial form by $x$. Repeat if necessary until no term of the trial matches $y_c$.
y_c = C₁e²ˣ + C₂xe²ˣ
y_p = Ax²e²ˣ
y_p′ = e²ˣ(2Ax + 2Ax²)
y_p″ = e²ˣ(2A + 8Ax + 4Ax²)
y_c = C₁cos(3x) + C₂sin(3x)
y_p = Ax·cos(3x) + Bx·sin(3x)
y_p″ = −6Asin(3x) − 9Axcos(3x) + 6Bcos(3x) − 9Bxsin(3x)
The method of undetermined coefficients is powerful but limited. It works only when $g(x)$ belongs to the recognizable families listed in Section 8.5. If $g(x) = \sec(x)$, $\ln(x)$, or $\tfrac{1}{x}$, undetermined coefficients fails.
Variation of parameters is a more general method that produces a particular solution for any continuous forcing function $g(x)$. It starts from the complementary solution $y_c = C_1 y_1(x) + C_2 y_2(x)$ and replaces the constants $C_1$ and $C_2$ with unknown functions $u_1(x)$ and $u_2(x)$, then determines those functions by requiring $y_p = u_1 y_1 + u_2 y_2$ to satisfy the nonhomogeneous equation.
For $y'' + p(x)y' + q(x)y = g(x)$ (divide by leading coefficient first), with Wronskian $W = y_1 y_2' - y_2 y_1'$:
$$u_1' = \frac{-y_2\,g(x)}{W}, \qquad u_2' = \frac{y_1\,g(x)}{W}$$
Then integrate: $u_1 = \int u_1'\,dx$, $u_2 = \int u_2'\,dx$, and $y_p = u_1 y_1 + u_2 y_2$.
u₁′ = −sin(x)·sec(x) = −tan(x) → u₁ = ln|cos(x)|
u₂′ = cos(x)·sec(x) = 1 → u₂ = x
| Situation | Method |
|---|---|
| $g(x)$ is a polynomial, exponential, $\sin$, $\cos$, or product of these | Undetermined coefficients |
| $g(x)$ is $\sec(x)$, $\tan(x)$, $\ln(x)$, $\tfrac{1}{x}$, or any non-standard function | Variation of parameters |
| Resonance occurs | Undetermined coefficients with $x$-correction |
| Non-constant coefficients (e.g., $xy'' + \ldots$) | Variation of parameters |
The methods of this chapter apply directly to engineering, physics, circuits, and control systems. In any system where an external input drives the behavior, the governing equation is nonhomogeneous.
The equation of motion for a mass $m$ on a spring with spring constant $k$, damping coefficient $b$, and external force $F(t)$ is
$$mx'' + bx' + kx = F(t)$$In Chapter 7, the case $F(t) = 0$ was studied. When $F(t) \neq 0$, the complementary solution $x_c$ is the transient response, and the particular solution $x_p$ is the steady-state response. If damping is present, $x_c$ decays, and after a long time only $x_p$ remains. Without damping and with forcing frequency equal to the natural frequency $\omega_0 = \sqrt{k/m}$, pure resonance occurs and amplitude grows without bound.
For a series RLC circuit with resistance $R$, inductance $L$, capacitance $C$, and applied EMF $E(t)$, the charge $q(t)$ satisfies
$$Lq'' + Rq' + \frac{1}{C}q = E(t)$$This has exactly the same mathematical form as the spring-mass equation. The particular solution represents the steady-state current response to the applied EMF. The complementary solution represents the transient behavior as the circuit reaches steady state.
q_c = e^{−t}(C₁cos(2t) + C₂sin(2t))
A + 4B = 0 → A = −4B
B − 4A = 10 → 17B = 10 → B = 10/17, A = −40/17
The general solution is $y = y_c + y_p$. Initial conditions must be applied to the complete expression $y_c + y_p$. Applying them to $y_c$ alone produces wrong values of $C_1$ and $C_2$.
The trial form must include both: $y_p = A\cos(3x) + B\sin(3x)$. Differentiation produces both functions. With only one, substitution will generate an unmatched cosine term.
If any term of $y_p$ appears in $y_c$, substitution gives $A \cdot 0 = g(x)$, which has no solution. Always compare the proposed trial to $y_c$ before substituting. Apply the $x$-multiplication when overlap is found.
For a polynomial of degree $n$, always include all terms from degree $n$ down to degree 0. Missing intermediate terms leaves the system of equations under-determined, producing a contradiction.
The general solution is always $y = y_c + y_p$. The particular solution alone has no arbitrary constants and cannot satisfy arbitrary initial conditions. Always include $y_c$.
The variation of parameters formulas are derived for the standard form $y'' + py' + qy = g(x)$ with leading coefficient 1. Divide by the leading coefficient before applying the formulas.
$y_p$ is a fixed function with determined coefficients. The constants $C_1$ and $C_2$ in $y_c$ remain free and are determined only by initial conditions. $y_p$ does not absorb into them.
Chapter 10 will introduce a third approach to nonhomogeneous equations: Laplace transforms. The Laplace transform method converts the differential equation into an algebraic equation in a new variable $s$, solves algebraically, and then converts the algebraic solution back to a function of $t$. This approach has several advantages over the methods of this chapter.
First, initial conditions are incorporated directly into the algebraic equation, so there is no need to find the general solution and then apply conditions afterward. Second, the same method handles polynomial, exponential, and trigonometric forcing in a uniform way. Third, Laplace transforms extend naturally to forcing functions that are discontinuous, such as step functions and impulse functions, which the methods of this chapter cannot handle easily.
The connection between this chapter and Chapter 10 is deep. The complementary solution corresponds to the homogeneous part of the Laplace-transformed equation, and the particular solution corresponds to the forcing part. The structure $y = y_c + y_p$ is preserved in the transform framework, but the computation is reorganized in a way that is often more systematic.
Students entering Chapter 10 should be comfortable with the characteristic equation, the forms of complementary solutions, the idea of forcing functions, and the general solution structure $y = y_c + y_p$. All of this will reappear in the transform language.
For each equation, find $y_c$ only. Do not solve for $y_p$ yet.
Find only $y_p$ for each equation. Do not include $y_c$.
Find the general solution $y = y_c + y_p$ for each.
Find the solution satisfying the given initial conditions. Remember to apply conditions to the full solution $y_c + y_p$.
Each problem shows student work containing errors. Identify all errors and write the correct solution.
Solve $y'' + 4y' + 3y = 2e^x$, $y(0) = 0$, $y'(0) = 1$.
Student applies IC to $y_c$ alone → $C_1 = 1/4$, $C_2 = -1/4$, then adds $y_p = e^x/4$ at the end.Identify the error. What are the correct values of $C_1$ and $C_2$?
Solve $y'' + y = \cos(x)$.
Trial: $y_p = A\cos(x)$ only. After substituting: $-A\cos(x) + A\cos(x) = 0 \neq \cos(x)$. Concludes: no solution.Two errors are present. Identify both and write the correct solution.
Solve $y'' - 2y' + y = x$.
Trial: $y_p = Ax$. After substituting: $0 - 2A + Ax = x$. Student matches $A = 1$ from $x$-term, then concludes $-2A = 0$ forces $A = 0$. Reports contradiction.What went wrong with the trial form? What is the correct approach?
Solve $y'' + 4y = 8\sin(2x)$.
Trial: $y_p = A\sin(2x)$. After substituting: $-4A\sin(2x) + 4A\sin(2x) = 0 = 8\sin(2x)$. Concludes: no solution.What resonance step was skipped? Write the correct solution.
Chapter 8 completes Part III. You have now studied the full range of second-order linear equations: homogeneous in Chapter 6, mechanical oscillations in Chapter 7, and nonhomogeneous equations here. Part IV expands this theory in three directions.
Chapter 9 introduces systems of differential equations, where several unknown functions change simultaneously in response to each other. The matrix framework $\mathbf{x}' = A\mathbf{x}$ and eigenvalue-eigenvector analysis extend the characteristic equation ideas you developed in Chapters 6 through 8.
Chapter 10 introduces Laplace transforms, which convert differential equations into algebraic equations in a complex frequency variable. This method handles initial conditions directly and extends naturally to discontinuous and impulsive forcing. The complementary-plus-particular structure of this chapter reappears in the transform language.
Chapter 11 introduces numerical methods for when no closed-form solution is available. Euler's method, improved Euler, and Runge-Kutta give you tools for computation when analytic methods are unavailable or impractical.