27-04 — Second-Order Nonhomogeneous ODEs
Phase: Ordinary Differential Equations | Subject: 27-04 Prerequisites: 27-03-second-order-linear-odes-homogeneous.md Next subject: 27-05-systems-of-odes.md
Learning Objectives
By the end of this subject, you will be able to:
- Write the general solution as $y = y_h + y_p$ (complementary + particular)
- Apply the method of undetermined coefficients
- Apply the method of variation of parameters
- Handle resonance cases in forcing
- Solve physical problems: forced oscillations
Core Content
General Solution Structure
For $ay'' + by' + cy = g(x)$:
$$y(x) = y_h(x) + y_p(x)$$
- $y_h$ (complementary solution): solves $ay'' + by' + cy = 0$
- $y_p$ (particular solution): any one solution to the nonhomogeneous equation
Method 1: Undetermined Coefficients
Works when $g(x)$ has a finite number of linearly independent derivatives: polynomials, exponentials, sines/cosines, and products/sums thereof.
Recipe: 1. Solve homogeneous part → $y_h$ 2. Guess $y_p$ based on $g(x)$ with undetermined coefficients 3. Substitute into ODE, equate coefficients, solve 4. If guess overlaps with $y_h$, multiply by $x$ (or $x^2$ if double overlap)
Guessing table:
| $g(x)$ | Trial $y_p$ |
|---|---|
| $e^{kx}$ | $Ae^{kx}$ |
| $\sin kx$ or $\cos kx$ | $A \cos kx + B \sin kx$ |
| $x^n$ (polynomial) | $A_n x^n + \cdots + A_1 x + A_0$ |
| $e^{kx} \sin(mx)$ | $e^{kx}(A \cos mx + B \sin mx)$ |
Method 2: Variation of Parameters
Works for any linear nonhomogeneous ODE (even with non-constant coefficients).
Given $y_h = c_1 y_1 + c_2 y_2$, seek $y_p = u_1(x) y_1(x) + u_2(x) y_2(x)$.
Formulas (for $y'' + P(x)y' + Q(x)y = g(x)$):
$$u_1' = \frac{-y_2 g}{W(y_1, y_2)}, \quad u_2' = \frac{y_1 g}{W(y_1, y_2)}$$
where $W(y_1, y_2) = y_1 y_2' - y_1' y_2$ is the Wronskian.
Then $u_1 = \int u_1' dx$, $u_2 = \int u_2' dx$.
Resonance
When the forcing term matches a homogeneous solution, the particular solution grows in amplitude.
Example: $y'' + \omega_0^2 y = F_0 \cos \omega t$.
If $\omega \neq \omega_0$: $y_p = \frac{F_0}{\omega_0^2 - \omega^2} \cos \omega t$ (bounded). If $\omega = \omega_0$: $y_p = \frac{F_0}{2\omega_0} t \sin \omega_0 t$ (amplitude grows linearly — resonance!).
Key Terms
- Complementary Solution $y_h$
- Particular Solution $y_p$
- Undetermined Coefficients
- Variation of Parameters
- Wronskian
- Resonance
Worked Examples
Example 1: Undetermined Coefficients (Polynomial)
Solve $y'' + 4y = 8x^2$.
Solution: $y_h$: $r^2 + 4 = 0$, $r = \pm 2i$, $y_h = c_1 \cos 2x + c_2 \sin 2x$. Guess $y_p = Ax^2 + Bx + C$. $y_p'' = 2A$. Substitute: $2A + 4(Ax^2 + Bx + C) = 8x^2$. $4A x^2 + 4B x + (2A + 4C) = 8x^2 + 0x + 0$. $4A = 8 \Rightarrow A = 2$, $4B = 0 \Rightarrow B = 0$, $2(2) + 4C = 0 \Rightarrow C = -1$. $y_p = 2x^2 - 1$. General: $y = c_1 \cos 2x + c_2 \sin 2x + 2x^2 - 1$.
Click for answer
$y = c_1 \cos 2x + c_2 \sin 2x + 2x^2 - 1$.Example 2: Variation of Parameters
Solve $y'' + y = \tan x$ ($0 < x < \pi/2$).
Solution: $y_h = c_1 \cos x + c_2 \sin x$. $W = \cos x \cdot \cos x - (-\sin x)\sin x = \cos^2 x + \sin^2 x = 1$. $u_1' = -y_2 g / W = -\sin x \tan x = -\sin^2 x / \cos x$. $u_2' = y_1 g / W = \cos x \tan x = \sin x$. $u_1 = \int (-\sin^2 x / \cos x) dx = \int (\cos x - \sec x) dx = \sin x - \ln|\sec x + \tan x|$. $u_2 = \int \sin x dx = -\cos x$. $y_p = (\sin x - \ln|\sec x + \tan x|)\cos x + (-\cos x)\sin x = -\cos x \ln|\sec x + \tan x|$.
Click for answer
$y = c_1 \cos x + c_2 \sin x - \cos x \ln|\sec x + \tan x|$.Example 3: Resonance
Solve $y'' + y = \sin x$, $y(0) = y'(0) = 0$.
Solution: $y_h = c_1 \cos x + c_2 \sin x$. Forcing $\sin x$ overlaps $y_h$. Guess $y_p = x(A \cos x + B \sin x)$. $y_p' = (A + Bx)\cos x + (B - Ax)\sin x$, $y_p'' = (2B - Ax)\cos x + (-2A - Bx)\sin x$. $y_p'' + y_p = 2B \cos x - 2A \sin x = \sin x \Rightarrow B = 0, A = -1/2$. $y_p = -\frac{x}{2} \cos x$. General: $y = c_1 \cos x + c_2 \sin x - \frac{x}{2}\cos x$. $y(0) = c_1 = 0$. $y'(0) = c_2 - 1/2 = 0 \Rightarrow c_2 = 1/2$. $y = \frac{1}{2}\sin x - \frac{x}{2}\cos x$.
Click for answer
$y = \frac{1}{2}(\sin x - x\cos x)$. Amplitude grows linearly (resonance).Quiz
Q1: What does the concept of Formulas primarily refer to in this subject?
A) The definition and application of Formulas B) A visual representation of Formulas C) A computational error related to Formulas D) A historical anecdote about Formulas
Correct: A)
- If you chose A: Formulas is defined as: the definition and application of formulas. The other options describe different aspects that are not the primary focus. Correct!
- If you chose B: This is incorrect. Formulas is defined as: the definition and application of formulas. The other options describe different aspects that are not the primary focus.
- If you chose C: This is incorrect. Formulas is defined as: the definition and application of formulas. The other options describe different aspects that are not the primary focus.
- If you chose D: This is incorrect. Formulas is defined as: the definition and application of formulas. The other options describe different aspects that are not the primary focus.
Q2: Which of the following is the key formula discussed in this subject?
A) The inverse operation of the formula in question B) y = y_h + y_p C) An unrelated formula from a different topic D) A simplified version of y = y_h + y_p...
Correct: B)
- If you chose A: This is incorrect. The formula y = y_h + y_p is central to this subject. The other options are either simplified versions or unrelated.
- If you chose B: The formula y = y_h + y_p is central to this subject. The other options are either simplified versions or unrelated. Correct!
- If you chose C: This is incorrect. The formula y = y_h + y_p is central to this subject. The other options are either simplified versions or unrelated.
- If you chose D: This is incorrect. The formula y = y_h + y_p is central to this subject. The other options are either simplified versions or unrelated.
Q3: What is the primary purpose of Wronskian?
A) It is used to wronskian in mathematical analysis B) It is used only in advanced research contexts C) It replaces all other methods in this domain D) It is primarily a historical notation system
Correct: A)
- If you chose A: Wronskian serves the purpose described in the correct answer. The other options misrepresent its role. Correct!
- If you chose B: This is incorrect. Wronskian serves the purpose described in the correct answer. The other options misrepresent its role.
- If you chose C: This is incorrect. Wronskian serves the purpose described in the correct answer. The other options misrepresent its role.
- If you chose D: This is incorrect. Wronskian serves the purpose described in the correct answer. The other options misrepresent its role.
Q4: Which statement about Undetermined Coefficients is TRUE?
A) Undetermined Coefficients is mentioned only as a historical footnote B) Undetermined Coefficients is a fundamental concept covered in this subject C) Undetermined Coefficients is not related to this subject D) Undetermined Coefficients is an advanced topic beyond this subject's scope
Correct: B)
- If you chose A: This is incorrect. Undetermined Coefficients is a fundamental concept covered in this subject. This subject covers Undetermined Coefficients as part of its core content.
- If you chose B: Undetermined Coefficients is a fundamental concept covered in this subject. This subject covers Undetermined Coefficients as part of its core content. Correct!
- If you chose C: This is incorrect. Undetermined Coefficients is a fundamental concept covered in this subject. This subject covers Undetermined Coefficients as part of its core content.
- If you chose D: This is incorrect. Undetermined Coefficients is a fundamental concept covered in this subject. This subject covers Undetermined Coefficients as part of its core content.
Q5: Based on the worked examples in this subject, what is the correct result?
A) Variation of Parameters B) A different result from a common mistake C) An unrelated numerical value D) The inverse of the correct answer
Correct: A)
- If you chose A: The worked examples show that the result is Variation of Parameters. The other options represent common errors. Correct!
- If you chose B: This is incorrect. The worked examples show that the result is Variation of Parameters. The other options represent common errors.
- If you chose C: This is incorrect. The worked examples show that the result is Variation of Parameters. The other options represent common errors.
- If you chose D: This is incorrect. The worked examples show that the result is Variation of Parameters. The other options represent common errors.
Q6: How are Undetermined Coefficients and Variation of Parameters related?
A) Undetermined Coefficients and Variation of Parameters are completely unrelated topics B) Undetermined Coefficients and Variation of Parameters are closely related concepts C) Undetermined Coefficients is a special case of Variation of Parameters D) Undetermined Coefficients is the inverse of Variation of Parameters
Correct: B)
- If you chose A: This is incorrect. Both Undetermined Coefficients and Variation of Parameters are covered in this subject as interconnected topics.
- If you chose B: Both Undetermined Coefficients and Variation of Parameters are covered in this subject as interconnected topics. Correct!
- If you chose C: This is incorrect. Both Undetermined Coefficients and Variation of Parameters are covered in this subject as interconnected topics.
- If you chose D: This is incorrect. Both Undetermined Coefficients and Variation of Parameters are covered in this subject as interconnected topics.
Q7: What is a common pitfall when working with Resonance?
A) A common mistake is confusing Resonance with a similar concept B) The main error with Resonance is using it when it is not needed C) Resonance is always computed the same way in all contexts D) Resonance has no common misconceptions
Correct: A)
- If you chose A: Students often confuse Resonance with similar-sounding or related concepts. Pay attention to the precise definitions. Correct!
- If you chose B: This is incorrect. Students often confuse Resonance with similar-sounding or related concepts. Pay attention to the precise definitions.
- If you chose C: This is incorrect. Students often confuse Resonance with similar-sounding or related concepts. Pay attention to the precise definitions.
- If you chose D: This is incorrect. Students often confuse Resonance with similar-sounding or related concepts. Pay attention to the precise definitions.
Q8: When should you apply General Solution Structure?
A) Use General Solution Structure only in pure mathematics contexts B) Apply General Solution Structure to solve problems in this subject's domain C) General Solution Structure is not practically useful D) Avoid General Solution Structure unless explicitly instructed
Correct: B)
- If you chose A: This is incorrect. General Solution Structure is a practical tool used throughout this subject to solve relevant problems.
- If you chose B: General Solution Structure is a practical tool used throughout this subject to solve relevant problems. Correct!
- If you chose C: This is incorrect. General Solution Structure is a practical tool used throughout this subject to solve relevant problems.
- If you chose D: This is incorrect. General Solution Structure is a practical tool used throughout this subject to solve relevant problems.
Practice Problems
-
Find a particular solution for $y'' - 3y' + 2y = e^{4x}$.
Click for answer
Try $y_p = Ae^{4x}$. $16Ae^{4x} - 12Ae^{4x} + 2Ae^{4x} = 6Ae^{4x} = e^{4x} \Rightarrow A = 1/6$. $y_p = e^{4x}/6$. -
Solve $y'' + 4y = \sin 2x$ (resonance case).
Click for answer
$y_h = c_1 \cos 2x + c_2 \sin 2x$. Forcing overlaps. Try $y_p = x(A \cos 2x + B \sin 2x)$. Get $A = -1/4, B = 0$. $y_p = -(x/4)\cos 2x$. -
Use variation of parameters: $y'' - 2y' + y = e^x/x$.
Click for answer
$y_h = (c_1 + c_2 x)e^x$. $y_1 = e^x, y_2 = xe^x$. $W = e^{2x}$. $u_1' = -xe^x \cdot (e^x/x) / e^{2x} = -1$, $u_1 = -x$. $u_2' = e^x \cdot (e^x/x) / e^{2x} = 1/x$, $u_2 = \ln|x|$. $y_p = -xe^x + xe^x \ln|x|$. -
Determine the form of $y_p$ for $y'' + y' - 2y = x e^x$ (don't solve coefficients).
Click for answer
$y_h$: roots 1 and -2. $g(x) = xe^x$ overlaps with $e^x$. Try $y_p = x(Ax + B)e^x = (Ax^2 + Bx)e^x$. -
Solve $y'' + y = 2\cos x$, $y(0) = 0, y'(0) = 0$.
Click for answer
Resonance: try $y_p = x(A\cos x + B\sin x)$. Find $A = 0, B = 1$. $y_p = x\sin x$. $y = c_1 \cos x + c_2 \sin x + x\sin x$. $y(0)=0 \Rightarrow c_1=0$. $y'(0)=c_2=0$. So $y = x\sin x$.
Summary
Key takeaways:
- $y = y_h + y_p$: complementary + particular
- Undetermined coefficients: guess based on $g(x)$; adjust if overlap
- Variation of parameters: general method using Wronskian
- Resonance: forcing frequency matches natural frequency → unbounded growth
- Wronskian: $W(y_1, y_2) = y_1 y_2' - y_1' y_2$; nonzero → linear independence
Pitfalls
- Guessing the wrong form for $y_p$ in undetermined coefficients: The trial solution must match the family of $g(x)$ and all its derivatives. For $g(x) = x^2 e^{3x}$, the correct trial is $(Ax^2 + Bx + C)e^{3x}$, not $A x^2 e^{3x}$ — you need all lower-degree terms because differentiation generates them. Similarly, for $g(x) = x \cos 2x$, the trial is $(Ax + B)\cos 2x + (Cx + D)\sin 2x$, including both sine and cosine with full polynomial coefficients.
- Forgetting to multiply by $x$ (or $x^2$) when the trial overlaps $y_h$: If any term in the standard trial for $y_p$ already appears in $y_h$, multiply the entire trial by $x$. If the overlap still persists (double root in characteristic equation), multiply by $x^2$. Missing this step leads to $0 = g(x)$ when substituting — the trial gets "absorbed" into $y_h$. Always compute $y_h$ first and check for overlap before guessing $y_p$.
- Miscomputing the Wronskian: The Wronskian is $W = y_1 y_2' - y_1' y_2$, NOT $y_1' y_2' - y_1 y_2$ or $y_1 y_2$. A sign error here flips the signs of $u_1'$ and $u_2'$ in variation of parameters, producing the wrong particular solution. Always double-check the order: first function times derivative of second minus derivative of first times second.
- Using variation of parameters when undetermined coefficients would work: Variation of parameters works universally but involves messy integrals. For $g(x) = e^{2x}$, $3\cos x$, $x^3$, or any combination of polynomials, exponentials, and sines/cosines, undetermined coefficients is faster and less error-prone. Reserve variation of parameters for $g(x)$ like $\tan x$, $\sec x$, $\ln x$, or $1/x$ that don't have finite derivative families.
- Forgetting that resonance only occurs when the forcing frequency exactly matches a natural frequency: In $y'' + \omega_0^2 y = F_0 \cos \omega t$, resonance (linearly growing amplitude) occurs only when $\omega = \omega_0$. If $\omega$ is merely close to $\omega_0$, the amplitude is large but bounded: $y_p = \frac{F_0}{\omega_0^2 - \omega^2}\cos\omega t$. Students sometimes incorrectly multiply by $x$ whenever the forcing "looks similar" to a homogeneous solution — only exact matching triggers the $x$ (or $t$) multiplier.
Next Steps
Next up: 27-05-systems-of-odes.md — coupled ODEs, matrix exponential, eigenvalues.