Differential Equations · § 08

Variation of Parameters

The universal particular-solution method. Where undetermined coefficients fails, ln x, tan x, sec x, 1/x, variation of parameters steps in. One formula, any forcing function.

2Key Integrals
8Worked Examples
10Quiz Questions
Share this page

§ 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.

The core idea: promote constants to functions In the homogeneous solution yh = C₁y₁ + C₂y₂, the constants C₁ and C₂ are fixed numbers. Variation of parameters asks: what if we let C₁ and C₂ vary — become functions u₁(x) and u₂(x) — so that yp = u₁y₁ + u₂y₂ satisfies the full non-homogeneous equation? The result is a system of two equations for u₁' and u₂', which we integrate to find u₁ and u₂.

When to Use Each Method

CriterionUndetermined CoefficientsVariation 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:

Target Equation
y'' + P(x)y' + Q(x)y = g(x) Note: the leading coefficient must be 1. If it is a ≠ 1, divide through by a first.

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:

The Ansatz (Trial Form)
yp = u₁(x)y₁(x) + u₂(x)y₂(x)

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.

1
Differentiate yp = u₁y₁ + u₂y₂: yp' = u₁'y₁ + u₁y₁' + u₂'y₂ + u₂y₂' Impose the simplifying constraint: u₁'y₁ + u₂'y₂ = 0     ← Equation (I) This reduces yp' to: yp' = u₁y₁' + u₂y₂'
2
Differentiate again (with the constraint already applied): yp'' = u₁'y₁' + u₁y₁'' + u₂'y₂' + u₂y₂''
3
Substitute yp, yp', yp'' into y'' + Py' + Qy = g(x). Group by u₁ and u₂: u₁[y₁'' + Py₁' + Qy₁] + u₂[y₂'' + Py₂' + Qy₂] + u₁'y₁' + u₂'y₂' = g(x) The bracketed terms are zero (y₁ and y₂ solve the homogeneous equation), leaving: u₁'y₁' + u₂'y₂' = g(x)     ← Equation (II)
4
Equations (I) and (II) form a 2×2 linear system in u₁' and u₂': y₁ u₁' + y₂ u₂' = 0 y₁' u₁' + y₂' u₂' = g(x) Solve by Cramer's rule. The determinant of the coefficient matrix is the Wronskian W = y₁y₂' − y₂y₁'.
5
Cramer's rule gives: u₁' = −y₂ g(x) / W     u₂' = y₁ g(x) / W Integrate both to get u₁ and u₂ (no constants of integration needed — those are absorbed into yh).

§ 03The Master Formulas

Everything you need in one place. Commit these four expressions to memory and the method becomes mechanical.

Variation of Parameters — Complete Formula Set
Wronskian
W = y₁y₂' − y₂y₁'
Particular Solution
yp = u₁y₁ + u₂y₂
u₁ (integrate)
u₁ = −∫ y₂ g(x) / W dx
u₂ (integrate)
u₂ = ∫ y₁ g(x) / W dx
The leading coefficient must be 1 The formulas above assume the ODE has been written as y'' + P(x)y' + Q(x)y = g(x) with leading coefficient 1. If your ODE is ay'' + by' + cy = f(x), divide everything through by a first to get g(x) = f(x)/a before applying the formulas. Using f(x) instead of g(x) = f(x)/a is the most common error in this method.
The Six-Step Procedure
  1. Write the homogeneous equation and solve it. Identify y₁ and y₂ explicitly.
  2. Divide by the leading coefficient a to put the ODE in standard form. Identify g(x) = f(x)/a.
  3. Compute the Wronskian W = y₁y₂' − y₂y₁'. Confirm W ≠ 0.
  4. Compute u₁' = −y₂g/W and u₂' = y₁g/W. Simplify the integrands as much as possible.
  5. Integrate to find u₁ and u₂. Omit constants of integration (they merge into yh).
  6. 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.

Example 1 — Warm Up: Exponential Forcing

Use variation of parameters to solve: y'' − 3y' + 2y = e3x.

1
Homogeneous solution. r² − 3r + 2 = (r−1)(r−2) = 0. Roots 1, 2.y₁ = eˣ,   y₂ = e²ˣ
2
Standard form. Leading coefficient is already 1. g(x) = e³ˣ.
3
Wronskian.W = eˣ · 2e²ˣ − e²ˣ · eˣ = 2e³ˣ − e³ˣ = e³ˣ
4
Set up integrands.u₁' = −y₂g/W = −e²ˣ · e³ˣ / e³ˣ = −e²ˣu₂' = y₁g/W = eˣ · e³ˣ / e³ˣ = eˣ
5
Integrate.u₁ = −½e²ˣ,    u₂ = eˣ
6
Particular solution.yp = u₁y₁ + u₂y₂ = (−½e²ˣ)(eˣ) + (eˣ)(e²ˣ) = −½e³ˣ + e³ˣ = ½e³ˣ
y = C₁eˣ + C₂e²ˣ + ½e³ˣ    (matches undetermined coefficients result ✓)
Example 2 — Forcing by tan x (Cannot Use Undetermined Coefficients)

Find the general solution of y'' + y = tan x.

1
Homogeneous solution. r² + 1 = 0 → r = ±i.y₁ = cos x,   y₂ = sin x
2
Standard form. g(x) = tan x.
3
Wronskian.W = cos x · cos x − sin x · (−sin x) = cos²x + sin²x = 1
4
Integrands.u₁' = −sin x · tan x / 1 = −sin²x / cos x = −(1−cos²x)/cos x = cos x − sec xu₂' = cos x · tan x / 1 = sin x
5
Integrate.u₁ = sin x − ln|sec x + tan x|u₂ = −cos x
6
Particular solution.yp = (sin x − ln|sec x + tan x|)cos x + (−cos x)sin x= sin x cos x − cos x · ln|sec x + tan x| − sin x cos x= −cos x · ln|sec x + tan x|
y = C₁cos x + C₂sin x − cos x · ln|sec x + tan x|
Example 3 — Forcing by sec x

Find a particular solution of y'' + y = sec x.

1
Homogeneous solution. Same as Example 2: y₁ = cos x, y₂ = sin x, W = 1.
2
Integrands.u₁' = −sin x · sec x = −sin x / cos x = −tan xu₂' = cos x · sec x = cos x / cos x = 1
3
Integrate.u₁ = ln|cos x|     u₂ = x
4
Particular solution.yp = cos x · ln|cos x| + x sin x
y = C₁cos x + C₂sin x + cos x · ln|cos x| + x sin x
Example 4 — Forcing by ex / x (Cannot use Undetermined Coefficients)

Find the general solution of y'' − 2y' + y = eˣ / x  (x > 0).

1
Homogeneous solution. (r−1)² = 0. Double root r = 1.y₁ = eˣ,   y₂ = xeˣ
2
Standard form. Already in standard form. g(x) = eˣ/x.
3
Wronskian.
y₁' = eˣ,   y₂' = eˣ + xeˣ = (1+x)eˣ
W = eˣ(1+x)eˣ − xeˣ · eˣ = e²ˣ(1+x) − xe²ˣ = e²ˣ
4
Integrands.u₁' = −y₂g/W = −xeˣ · (eˣ/x) / e²ˣ = −e²ˣ / e²ˣ = −1u₂' = y₁g/W = eˣ · (eˣ/x) / e²ˣ = 1/x
5
Integrate.u₁ = −x     u₂ = ln x
6
Particular solution.yp = (−x)eˣ + (ln x)(xeˣ) = xeˣ(ln x − 1)
y = (C₁ + C₂x)eˣ + xeˣ(ln x − 1)
Example 5 — Non-constant Coefficient ODE

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⁴.

1
Standard form. Divide by x²:y'' − (2/x)y' + (2/x²)y = x²So g(x) = x².
2
Wronskian.
y₁ = x, y₁' = 1     y₂ = x², y₂' = 2x
W = x·2x − x²·1 = 2x² − x² = x²
3
Integrands.u₁' = −y₂g/W = −x² · x² / x² = −x²u₂' = y₁g/W = x · x² / x² = x
4
Integrate.u₁ = −x³/3     u₂ = x²/2
5
Particular solution.yp = (−x³/3)(x) + (x²/2)(x²) = −x⁴/3 + x⁴/2 = x⁴(−1/3 + 1/2) = x⁴/6
yp = x⁴/6      Full solution: y = C₁x + C₂x² + x⁴/6
Example 6 — Forcing by ln x

Find a particular solution of y'' − 2y' + y = ln x  (x > 0).

1
Homogeneous solution. (r−1)² = 0. Double root r = 1.y₁ = eˣ,   y₂ = xeˣ,   W = e²ˣ  (from Example 4)
2
Standard form. g(x) = ln x.
3
Integrands.u₁' = −xeˣ · ln x / e²ˣ = −x e⁻ˣ ln xu₂' = eˣ · ln x / e²ˣ = e⁻ˣ ln x
4
Integrate by parts.
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)
yp = ln x + 2    (verifiable by direct substitution: yp'' = 0, yp' = 1/x — substitute to confirm)    ✓
Note: for this particular ODE, the particular solution simplifies beautifully. More general ln-forcing may require the exponential integral Ei(x).
Example 7 — Full IVP with Sinusoidal Forcing

Solve the IVP: y'' + 4y = 8 cos(2x),   y(0) = 1,   y'(0) = 0.

1
Homogeneous solution. r² + 4 = 0 → r = ±2i.y₁ = cos(2x),   y₂ = sin(2x)
2
Wronskian.W = cos(2x)·2cos(2x) − sin(2x)·(−2sin(2x)) = 2cos²(2x) + 2sin²(2x) = 2
3
Standard form. g(x) = 8cos(2x) (leading coefficient already 1).
4
Integrands.u₁' = −sin(2x) · 8cos(2x) / 2 = −4sin(2x)cos(2x) = −2sin(4x)u₂' = cos(2x) · 8cos(2x) / 2 = 4cos²(2x) = 2(1 + cos(4x))
5
Integrate.u₁ = ½cos(4x)     u₂ = 2x + ½sin(4x)
6
Particular solution. Use double-angle identities: sin(4x) = 2sin(2x)cos(2x), cos(4x) = 1 − 2sin²(2x).
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)
7
Complete solution: y = C₁cos(2x) + C₂sin(2x) + 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.
y = cos(2x) + 2x sin(2x)
Example 8 — Complex Wronskian Simplification

Find a particular solution of y'' + 2y' + y = e−x ln x  (x > 0).

1
Homogeneous solution. (r+1)² = 0. Double root r = −1.y₁ = e⁻ˣ,   y₂ = xe⁻ˣ
2
Wronskian.
y₁' = −e⁻ˣ,   y₂' = e⁻ˣ − xe⁻ˣ = (1−x)e⁻ˣ
W = e⁻ˣ·(1−x)e⁻ˣ − xe⁻ˣ·(−e⁻ˣ) = e⁻²ˣ(1−x) + xe⁻²ˣ = e⁻²ˣ
3
Integrands. g(x) = e⁻ˣ ln x.u₁' = −xe⁻ˣ · e⁻ˣ ln x / e⁻²ˣ = −x ln xu₂' = e⁻ˣ · e⁻ˣ ln x / e⁻²ˣ = ln x
4
Integrate by parts.
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.
5
Particular solution.yp = (−x²ln x/2 + x²/4)e⁻ˣ + (x ln x − x)·xe⁻ˣ= e⁻ˣ[−x²ln x/2 + x²/4 + x²ln x − x²]= e⁻ˣ[x²ln x/2 − 3x²/4]= ¼x²e⁻ˣ(2 ln x − 3)
yp = ¼x²e−x(2 ln x − 3)

§ 05Common Mistakes

Mistake 1: Forgetting to divide by the leading coefficient The formulas u₁' = −y₂g/W and u₂' = y₁g/W require g(x) from the standard form y'' + Py' + Qy = g(x), not from the original ay'' + by' + cy = f(x). If a ≠ 1, then g(x) = f(x)/a. Using f(x) directly gives an answer that is a times too large.
Mistake 2: Getting the signs wrong u₁' carries a negative sign: u₁' = −y₂g/W.   u₂' carries a positive sign: u₂' = +y₁g/W. A sign error here propagates through the entire calculation. Derive them from scratch using Cramer's rule if unsure, rather than memorising with the wrong sign.
Mistake 3: Including constants of integration in u₁ and u₂ When computing u₁ and u₂, do not add +C. Any arbitrary constants added here would produce additional multiples of y₁ and y₂ — terms that are already in yh. They contribute nothing new and clutter the answer.
Mistake 4: Incorrect Wronskian computation W = y₁y₂' − y₂y₁'. The most frequent error is swapping the order: W = y₂y₁' − y₁y₂' = −W. This flips the signs of both u₁ and u₂ — the errors cancel in yp = u₁y₁ + u₂y₂, but intermediate steps will be wrong, which makes checking difficult. Always write W = y₁y₂' − y₂y₁'.
Mistake 5: Applying initial conditions before forming the complete solution As with undetermined coefficients, initial conditions must be applied to y = yh + yp. Applying them to yh alone — before computing yp — gives wrong constants C₁ and C₂.
Mistake 6: Confusing y₁ and y₂ in the formula The asymmetry matters: u₁ goes with y₁ and carries a minus sign; u₂ goes with y₂ and carries a plus sign. If you swap them you get the wrong signs. Label y₁ and y₂ clearly at the start and refer back to them consistently.

§ 0610-Question Quiz

Test the Wronskian, the integral formulas, sign conventions, and when to use variation of parameters over undetermined coefficients.

Score: 0 / 0
Question 1

What is the Wronskian W(y₁, y₂)?

Question 2

For y'' + y = tan x, what is the correct formula for u₂'?

Question 3

For y'' − y = 1/x (x > 0), why can't we use undetermined coefficients?

Question 4 — Fill In

For y'' + y = sec x with y₁ = cos x, y₂ = sin x, the Wronskian W = (a constant).

Question 5

The ODE is 2y'' + 4y = 8 tan x. What is g(x) to use in the variation of parameters formulas?

Question 6

For y'' − 2y' + y = eˣ/x (x > 0), after finding u₂' = 1/x, the function u₂ equals:

Question 7

For y₁ = e⁻ˣ and y₂ = xe⁻ˣ (double root r = −1), what is the Wronskian W?

Question 8

Should constants of integration be included when computing u₁ and u₂?

Question 9

For y'' + y = sec²x, with y₁ = cos x, y₂ = sin x, W = 1, the integrand for u₁' simplifies to:

Question 10 — Fill In

For y'' − 3y' + 2y = e³ˣ (Example 1), the Wronskian of y₁ = eˣ and y₂ = e²ˣ is W = ex.


Cookie Settings