Variation of parameters finds a particular solution of y″ + p(x)y′ + q(x)y = f(x) for any continuous forcing f, once you know two independent solutions y₁ and y₂ of the homogeneous equation. You look for y_p = u₁y₁ + u₂y₂, and the formula gives u₁′ = −y₂f/W and u₂′ = y₁f/W, where W = y₁y₂′ − y₂y₁′ is the Wronskian. It is the method to reach for when f is sec x, ln x, 1/x or anything else that undetermined coefficients cannot handle.
The formula, and the one step everyone forgets
Write the equation in standard form, with the coefficient of y″ equal to 1. The f in the formula is the right-hand side after that division. Then:
- Find y₁ and y₂ from the homogeneous equation.
- Compute the Wronskian W = y₁y₂′ − y₂y₁′.
- u₁ = −∫(y₂f/W) dx and u₂ = ∫(y₁f/W) dx. Constants of integration can be dropped, because they only add multiples of y₁ and y₂.
- y_p = u₁y₁ + u₂y₂, and the general solution is y = c₁y₁ + c₂y₂ + y_p.
Where the formula comes from: with y_p = u₁y₁ + u₂y₂ we are free to impose u₁′y₁ + u₂′y₂ = 0, which keeps y_p′ free of u′ terms. Substituting into the equation then leaves u₁′y₁′ + u₂′y₂′ = f. Those two linear equations for u₁′ and u₂′, solved by Cramer's rule, give exactly the formula above, with W as the determinant.
This builds on the complementary functions from our guide to second order linear differential equations, so make sure the three root cases are secure first. For help with your own course problems, our online differential equations tutoring page explains how sessions with Ajay Vatsyayan work.
Which method for y_p?
| Situation | Undetermined coefficients | Variation of parameters |
|---|---|---|
| f is a polynomial, e^(kx), sin, cos or a product of these | fast; use it | works, but slower |
| f is sec x, tan x, 1/x, ln x, e^x/x, 1/(1 + e^x) | fails | the standard method |
| non-constant coefficients (e.g. Cauchy–Euler) | not applicable | works once y₁, y₂ are known |
| higher order (third and above) | works for the usual f | works, with a 3×3 Wronskian |
| integration needed | none | two integrals, sometimes hard |
Worked examples
Example 1 (warm-up): compare with the trial method
Solve y″ − 3y′ + 2y = e^(3x).
r² − 3r + 2 = (r − 1)(r − 2), so y₁ = e^x and y₂ = e^(2x).
W = e^x·2e^(2x) − e^(2x)·e^x = e^(3x).
u₁′ = −e^(2x)·e^(3x)/e^(3x) = −e^(2x), so u₁ = −½e^(2x).
u₂′ = e^x·e^(3x)/e^(3x) = e^x, so u₂ = e^x.
y_p = −½e^(2x)·e^x + e^x·e^(2x) = ½e^(3x).
Answer: y = c₁e^x + c₂e^(2x) + ½e^(3x). The trial Ae^(3x) gives 2A = 1 and the same y_p in two lines, which is why you use the trial method when it applies.
Example 2: a secant forcing with initial conditions
Solve y″ + 4y = 4 sec 2x with y(0) = 1, y′(0) = 0, on −π/4 < x < π/4.
y₁ = cos 2x, y₂ = sin 2x, and W = cos 2x·2cos 2x − sin 2x·(−2 sin 2x) = 2.
u₁′ = −sin 2x·4 sec 2x/2 = −2 tan 2x, so u₁ = ln(cos 2x). (cos 2x is positive on this interval, so no absolute value is needed.)
u₂′ = cos 2x·4 sec 2x/2 = 2, so u₂ = 2x.
y_p = cos 2x·ln(cos 2x) + 2x sin 2x.
General solution: y = c₁cos 2x + c₂sin 2x + cos 2x·ln(cos 2x) + 2x sin 2x.
y(0) = c₁ = 1. For y′(0), both parts of y_p have zero derivative at x = 0, so y′(0) = 2c₂ = 0 and c₂ = 0.
Answer: y = cos 2x + cos 2x·ln(cos 2x) + 2x sin 2x.
The interval matters: the solution is only valid where sec 2x is continuous, here |x| below π/4.
Example 3: a repeated root, and a term that disappears
Solve y″ − 4y′ + 4y = e^(2x)/x² for x > 0.
r = 2 twice, so y₁ = e^(2x), y₂ = xe^(2x).
W = e^(2x)(e^(2x) + 2xe^(2x)) − xe^(2x)·2e^(2x) = e^(4x).
u₁′ = −xe^(2x)·(e^(2x)/x²)/e^(4x) = −1/x, so u₁ = −ln x.
u₂′ = e^(2x)·(e^(2x)/x²)/e^(4x) = 1/x², so u₂ = −1/x.
y_p = −e^(2x)ln x − (1/x)·xe^(2x) = −e^(2x)ln x − e^(2x).
The −e^(2x) is a multiple of y₁, so it belongs to the complementary function. Absorb it into c₁.
Answer: y = (c₁ + c₂x)e^(2x) − e^(2x)ln x.
Example 4: Cauchy–Euler, where standard form decides the answer
Given that y₁ = x and y₂ = x³ solve x²y″ − 3xy′ + 3y = 0, solve x²y″ − 3xy′ + 3y = 2x⁴ for x > 0.
Divide by x² first: y″ − (3/x)y′ + (3/x²)y = 2x². So f = 2x², not 2x⁴.
W = x·3x² − x³·1 = 2x³.
u₁′ = −x³·2x²/(2x³) = −x², so u₁ = −x³/3.
u₂′ = x·2x²/(2x³) = 1, so u₂ = x.
y_p = −x⁴/3 + x⁴ = 2x⁴/3.
Check in the original: for y = x⁴, x²·12x² − 3x·4x³ + 3x⁴ = 3x⁴, so y_p = 2x⁴/3 gives 2x⁴. Correct.
Answer: y = c₁x + c₂x³ + 2x⁴/3.
Using f = 2x⁴ without dividing gives y_p = 2x⁶/15, which fails the check. This is one of the most common lost marks on this topic.
Example 5 (exam level): integrals that need care
Find a particular solution of y″ − y = 2/(1 + e^x).
y₁ = e^x, y₂ = e^(−x), W = e^x(−e^(−x)) − e^(−x)e^x = −2.
u₁′ = −e^(−x)·(2/(1 + e^x))/(−2) = e^(−x)/(1 + e^x)
u₂′ = e^x·(2/(1 + e^x))/(−2) = −e^x/(1 + e^x)
For u₁, split with partial fractions in e^x: 1/(e^x(1 + e^x)) = e^(−x) − 1/(1 + e^x), and ∫1/(1 + e^x) dx = x − ln(1 + e^x). So
u₁ = −e^(−x) − x + ln(1 + e^x)
u₂ = −ln(1 + e^x)
y_p = e^x(−e^(−x) − x + ln(1 + e^x)) − e^(−x)ln(1 + e^x)
Answer: y_p = −1 − xe^x + (e^x − e^(−x))ln(1 + e^x).
Substituting back confirms y_p″ − y_p = 2/(1 + e^x). The techniques for the integrals here are the ones in our guides to partial fractions and trig substitution and integration by parts; in this topic, integration is usually where the time goes.
Common errors and their fixes
- Not in standard form. f must be the right-hand side after dividing by the coefficient of y″ (Example 4).
- Sign of u₁. The minus sign belongs to u₁′ = −y₂f/W. If you mix up which function is y₁, the signs swap with it, so label y₁ and y₂ before computing W.
- Wronskian slips. W is y₁y₂′ − y₂y₁′. For cos kx and sin kx it is k; for e^(ax) and e^(bx) it is (b − a)e^((a+b)x). Knowing these speeds up checking.
- Keeping terms that belong to y_c. In Example 3, −e^(2x) is a multiple of y₁. Leaving it in y_p is not wrong, but writing it twice in the general solution looks careless.
- Absolute values in logarithms. ∫tan 2x dx gives −½ln|cos 2x|. State the interval so the modulus can be dropped honestly.
- Applying initial conditions to y_p alone. The constants c₁ and c₂ are found from the full general solution.
Practice problems
- Find a particular solution of y″ + 9y = 9 sec²(3x).
- Solve y″ − 2y′ + y = e^x/(1 + x²).
- Given y₁ = x and y₂ = x², solve x²y″ − 2xy′ + 2y = x³ for x > 0.
- Use variation of parameters on y″ − y = e^x and compare with the trial method.
- Find a particular solution of y″ + y = csc x on 0 < x < π.
Answers
- y_p = −1 + sin 3x·ln|sec 3x + tan 3x|.
- y = (c₁ + c₂x)e^x + e^x(x·arctan x − ½ln(1 + x²)).
- Standard form gives f = x; y = c₁x + c₂x² + x³/2.
- The method gives (x/2 − 1/4)e^x; the −e^x/4 joins y_c, leaving y_p = ½xe^x, as the trial Axe^x also gives.
- y_p = −x cos x + sin x·ln(sin x).
Where this leads
Variation of parameters is the first appearance of an idea that runs through the rest of the subject. For systems x′ = Ax + f(t), the same trick with a fundamental matrix gives the particular solution (see our guide to systems of differential equations). Written as a single integral, y_p becomes a Green's function formula, which returns in boundary value problems and PDEs such as the heat equation by separation of variables. Laplace transforms give the same particular solutions for many inputs through convolution, as our Laplace transform guide shows.
How Maths Bodhi helps
We work through your own problem sets and past papers, check your integrals and Wronskians as you go, and review your attempts line by line. If your final is coming up, our plan for passing differential equations sets out the order to revise, and the university maths hub lists every course we teach. We explain and practise; we don't complete graded work for you.
Home tuition is available in Gurgaon (Gurugram). Students elsewhere in India and abroad learn with us online. You can book a free demo class.
Written and checked by the Maths Bodhi team (November 2026).
Frequently asked questions
- What is the variation of parameters formula?
- For y″ + py′ + qy = f, y_p = −y₁∫(y₂f/W) dx + y₂∫(y₁f/W) dx, where W = y₁y₂′ − y₂y₁′.
- When should I use variation of parameters instead of undetermined coefficients?
- When f is not a polynomial, exponential, sine, cosine or a product of these, or when the coefficients are not constant.
- Why do I need to put the equation in standard form first?
- The formula assumes the coefficient of y″ is 1, so f must be the right-hand side after dividing by it.
- Do I need constants of integration when finding u₁ and u₂?
- No; they only add multiples of y₁ and y₂, which are already in the complementary function.
- What is the Wronskian used for in variation of parameters?
- It is the determinant of the system for u₁′ and u₂′, and it is non-zero exactly when y₁ and y₂ are independent.
- Does variation of parameters work for higher order equations?
- Yes, with n functions uᵢ and an n×n Wronskian, solved by Cramer's rule.
