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:

  1. Write the general solution as $y = y_h + y_p$ (complementary + particular)
  2. Apply the method of undetermined coefficients
  3. Apply the method of variation of parameters
  4. Handle resonance cases in forcing
  5. Solve physical problems: forced oscillations

Core Content

General Solution Structure

For $ay'' + by' + cy = g(x)$:

$$y(x) = y_h(x) + y_p(x)$$

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

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)

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)

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)

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)

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)

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)

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)

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)

Practice Problems

  1. 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$.

  2. 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$.

  3. 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|$.

  4. 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$.

  5. 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:


Pitfalls



Next Steps

Next up: 27-05-systems-of-odes.md — coupled ODEs, matrix exponential, eigenvalues.