§ 01Why This Method Exists
The method of undetermined coefficients is powerful but limited: it only works when the forcing function g(x) belongs to a specific family (polynomials, exponentials, sines, cosines, and their products). The moment g(x) is something like ln x, tan x, sec x, or ex/x, the trial-solution approach has no room to proceed.
Variation of parameters solves this problem completely. It works for any continuous g(x), no restrictions on the form of the forcing function. The price is that instead of solving an algebraic system for coefficients, you must evaluate two integrals. Those integrals may or may not have closed forms, but the method itself never fails.
When to Use Each Method
| Criterion | Undetermined Coefficients | Variation of Parameters |
|---|---|---|
| Polynomial g(x) | ✓ Preferred | ✓ Works |
| Exponential g(x) = eᵅˣ | ✓ Preferred | ✓ Works |
| Sinusoidal g(x) = sin/cos | ✓ Preferred | ✓ Works |
| g(x) = ln x, tan x, sec x | ✗ Cannot use | ✓ Use this |
| g(x) = 1/x, eˣ/x | ✗ Cannot use | ✓ Use this |
| Variable-coefficient ODE | ✗ Cannot use | ✓ Works (if y₁,y₂ known) |
| Integration required | ✗ Algebra only | ✓ Always integrates |
§ 02The Derivation
Understanding where the formulas come from makes them easy to remember and apply correctly. The derivation takes just a few lines and introduces the Wronskian naturally.
We want to solve:
Suppose y₁ and y₂ are two linearly independent solutions of the corresponding homogeneous equation y'' + Py' + Qy = 0. We seek a particular solution of the form:
Two unknowns, u₁ and u₂, means we need two equations. We get the first by imposing a simplifying constraint (chosen to eliminate second-derivative terms of u₁ and u₂), and the second by substituting yp into the ODE.
§ 03The Master Formulas
Everything you need in one place. Commit these four expressions to memory and the method becomes mechanical.
- Write the homogeneous equation and solve it. Identify y₁ and y₂ explicitly.
- Divide by the leading coefficient a to put the ODE in standard form. Identify g(x) = f(x)/a.
- Compute the Wronskian W = y₁y₂' − y₂y₁'. Confirm W ≠ 0.
- Compute u₁' = −y₂g/W and u₂' = y₁g/W. Simplify the integrands as much as possible.
- Integrate to find u₁ and u₂. Omit constants of integration (they merge into yh).
- Write yp = u₁y₁ + u₂y₂, then the complete solution y = yh + yp. Apply initial conditions if given.
§ 04Worked Examples
Eight examples, escalating in difficulty: from a simple exponential forcing where the Wronskian is trivial, up to sec(x) and ln(x) forcing where undetermined coefficients cannot help at all.
Use variation of parameters to solve: y'' − 3y' + 2y = e3x.
Find the general solution of y'' + y = tan x.
Find a particular solution of y'' + y = sec x.
Find the general solution of y'' − 2y' + y = eˣ / x (x > 0).
y₁' = eˣ, y₂' = eˣ + xeˣ = (1+x)eˣ
W = eˣ(1+x)eˣ − xeˣ · eˣ = e²ˣ(1+x) − xe²ˣ = e²ˣ
Given that y₁ = x and y₂ = x² are solutions of x²y'' − 2xy' + 2y = 0 (x > 0), use variation of parameters to find a particular solution of x²y'' − 2xy' + 2y = x⁴.
y₁ = x, y₁' = 1 y₂ = x², y₂' = 2x
W = x·2x − x²·1 = 2x² − x² = x²
Find a particular solution of y'' − 2y' + y = ln x (x > 0).
For u₂ = ∫e⁻ˣ ln x dx: let v = ln x, dw = e⁻ˣ dx → w = −e⁻ˣ.
u₂ = −e⁻ˣ ln x − ∫(−e⁻ˣ/x)dx = −e⁻ˣ ln x + ∫(e⁻ˣ/x)dx = −e⁻ˣ ln x + Ei(−x) where Ei(x) is the exponential integral. Similarly u₁ involves a related integral. The particular solution is:yp = eˣ[(2 + ln x)e⁻ˣ + … ] = 2 + ln x + (related terms)
Note: for this particular ODE, the particular solution simplifies beautifully. More general ln-forcing may require the exponential integral Ei(x).
Solve the IVP: y'' + 4y = 8 cos(2x), y(0) = 1, y'(0) = 0.
yp = ½cos(4x)·cos(2x) + [2x + ½sin(4x)]·sin(2x)
= ½(1−2sin²2x)cos(2x) + 2x sin(2x) + sin(2x)cos(2x)sin(2x)
= ½cos(2x) − sin²(2x)cos(2x) + 2x sin(2x) + sin²(2x)cos(2x) = ½cos(2x) + 2x sin(2x)
The ½cos(2x) term is already in yh and can be absorbed. The essential new term is: yp = 2x sin(2x)
y' = −2C₁sin(2x) + 2C₂cos(2x) + 2sin(2x) + 4x cos(2x).
y(0)=1: C₁ = 1. y'(0)=0: 2C₂ = 0 → C₂ = 0.
Find a particular solution of y'' + 2y' + y = e−x ln x (x > 0).
y₁' = −e⁻ˣ, y₂' = e⁻ˣ − xe⁻ˣ = (1−x)e⁻ˣ
W = e⁻ˣ·(1−x)e⁻ˣ − xe⁻ˣ·(−e⁻ˣ) = e⁻²ˣ(1−x) + xe⁻²ˣ = e⁻²ˣ
u₂ = ∫ln x dx = x ln x − x.
u₁ = −∫x ln x dx = −[x²ln x /2 − x²/4] = −x²ln x/2 + x²/4.
§ 05Common Mistakes
§ 0610-Question Quiz
Test the Wronskian, the integral formulas, sign conventions, and when to use variation of parameters over undetermined coefficients.
What is the Wronskian W(y₁, y₂)?
For y'' + y = tan x, what is the correct formula for u₂'?
For y'' − y = 1/x (x > 0), why can't we use undetermined coefficients?
For y'' + y = sec x with y₁ = cos x, y₂ = sin x, the Wronskian W = (a constant).
The ODE is 2y'' + 4y = 8 tan x. What is g(x) to use in the variation of parameters formulas?
For y'' − 2y' + y = eˣ/x (x > 0), after finding u₂' = 1/x, the function u₂ equals:
For y₁ = e⁻ˣ and y₂ = xe⁻ˣ (double root r = −1), what is the Wronskian W?
Should constants of integration be included when computing u₁ and u₂?
For y'' + y = sec²x, with y₁ = cos x, y₂ = sin x, W = 1, the integrand for u₁' simplifies to:
For y'' − 3y' + 2y = e³ˣ (Example 1), the Wronskian of y₁ = eˣ and y₂ = e²ˣ is W = ex.
Continue in Differential Equations
Variation of parameters completes your toolkit for second-order non-homogeneous ODEs. These topics build directly on this page: