Differential Equations • Second-Order Linear ODEs

Variation of Parameters — Method of Variation of Parameters (Intro)

A powerful technique for solving nonhomogeneous differential equations when simpler methods fall short.

A changing curve with sigma and variable symbols for differential equations
Inside this lesson 10 sections 5 questions 9 figures

SECTION 1

Historical Context & Motivation

Throughout the 1700s and 1800s, mathematicians and physicists were racing to model real-world phenomena — from planetary orbits to vibrating strings — using differential equations. They quickly discovered that many physical systems lead to nonhomogeneous differential equations, equations where an external force or input drives the system. The simplest method for solving these, called undetermined coefficients, only works when the driving force has a very specific, "nice" form — like a polynomial, exponential, or sine function. But what happens when the driving force is something messier, like tan(x) or 1/x? That's the gap the method of variation of parameters was designed to fill.

1748 • Euler's Early Work

Leonhard Euler develops early techniques for solving second-order linear ODEs and lays the groundwork for general solution methods.

1774 • Lagrange Introduces Variation of Parameters

Joseph-Louis Lagrange formally introduces the method of variation of parameters, initially to solve problems in celestial mechanics involving perturbed planetary orbits.

1809 • Refinement Through Celestial Mechanics

Lagrange and other mathematicians refine the technique and apply it broadly, establishing it as a general-purpose tool for nonhomogeneous linear ODEs of any order.

1900s • Modern Textbook Standard

Variation of parameters becomes a standard topic in differential equations courses worldwide, valued for its generality compared to the method of undetermined coefficients.

The key question that variation of parameters answers is this: if we already know how to solve the homogeneous equation (with no driving force), can we cleverly modify that solution to handle any driving force? The answer, as Lagrange showed, is yes — and the trick is to let the "constants" in the homogeneous solution become functions. That's why the method is called variation of parameters: the parameters (constants) are allowed to vary.

SECTION 2

Core Principles & Definitions

Before diving into the method itself, you need to understand a few foundational ideas. Each of these concepts plays a critical role in how variation of parameters works, so take a moment to internalize each one.

1

Homogeneous vs. Nonhomogeneous

A homogeneous ODE has the form y″ + p(x)y′ + q(x)y = 0. A nonhomogeneous ODE has a nonzero right side: y″ + p(x)y′ + q(x)y = g(x). The function g(x) is the driving force.
2

Complementary Solution yc

The complementary solution yc = c₁y₁ + c₂y₂ is the general solution to the associated homogeneous equation. It contains two arbitrary constants c₁ and c₂.
3

Particular Solution yp

A particular solution yp is any single solution to the full nonhomogeneous equation. The general solution is y = yc + yp.
4

The Wronskian W

The Wronskian is a determinant W = y₁y₂′ − y₂y₁′ built from two independent solutions. If W ≠ 0, the solutions are linearly independent and form a valid basis.
5

The Key Idea: Let Constants Vary

Instead of yp = c₁y₁ + c₂y₂ with fixed constants, we guess yp = u₁(x)y₁ + u₂(x)y₂, where u₁ and u₂ are unknown functions we must determine.
✦

KEY TAKEAWAY

Think of the homogeneous solution like a recipe with two fixed ingredients (c₁ and c₂). When the equation has a nonzero right side, those fixed ingredients aren't enough — you need to adjust the amounts as you go. Variation of parameters replaces the fixed constants with adjustable functions u₁(x) and u₂(x), like a chef tweaking a recipe in real time to account for changing conditions.

SECTION 3

Visual Explanation

The diagram below shows the overall logic of variation of parameters. You start with a nonhomogeneous ODE, find the homogeneous (complementary) solution with its two independent solutions y₁ and y₂, compute the Wronskian, and then use integration formulas to find the unknown functions u₁ and u₂. Finally, you assemble the particular solution and add it to the complementary solution to get the general answer.

Variation of Parameters — Method Overviewy″ + p(x)y′ + q(x)y = g(x)Step 1: Solve homogeneous eqn → y₁, y₂yc = c₁y₁ + c₂y₂Step 2: Compute Wronskian W(y₁, y₂)W = y₁y₂′ − y₂y₁′Step 3: Find u₁′ and u₂′ from the systemu₁′ = −y₂g(x)/W u₂′ = y₁g(x)/WStep 4: Integrate to find u₁ and u₂u₁ = ∫ u₁′ dx u₂ = ∫ u₂′ dxStep 5: Assemble general solutiony = c₁y₁ + c₂y₂ + u₁y₁ + u₂y₂
Flowchart showing the five major steps in variation of parameters. Notice how each step feeds directly into the next: you need y₁ and y₂ to build the Wronskian, and you need the Wronskian to compute u₁′ and u₂′. The final general solution combines the complementary and particular pieces.

The flowchart highlights the sequential, step-by-step nature of the method. Each box depends on the previous one. The most common source of errors is in Step 3, where you must correctly set up and solve the system of equations for u₁′ and u₂′. We'll see how that system is derived in the next section.

SECTION 4

Mathematical Framework

Let's set up the mathematics carefully. We begin with a second-order linear nonhomogeneous ODE in standard form, meaning the coefficient of y″ is 1. If it isn't already 1, divide the entire equation by the leading coefficient before applying the method.

STANDARD FORM

y″+p(x)y′+q(x)y=g(x)y″ + p(x)y′ + q(x)y = g(x)

Here, p(x) and q(x) are the coefficient functions, and g(x) is the nonhomogeneous (driving) term. The leading coefficient of y″ must be 1.

We assume we already know two linearly independent solutions y₁ and y₂ of the corresponding homogeneous equation (where g(x) = 0). The particular solution takes the form:

PARTICULAR SOLUTION FORM

yp=u1(x)⋅y1(x)+u2(x)⋅y2(x)yₚ = u₁(x) · y₁(x) + u₂(x) · y₂(x)

The functions u₁(x) and u₂(x) are the "varied parameters" — they replace the constants c₁ and c₂ from the complementary solution.

When we substitute this guess into the ODE and simplify, we impose an extra condition — called the Lagrange condition — to keep things manageable: u₁′y₁ + u₂′y₂ = 0. This constraint, combined with the ODE itself, produces a clean system of two equations in the two unknowns u₁′ and u₂′.

SYSTEM FOR u₁′ AND u₂′

u1′y1+u2′y2=0andu1′y1′+u2′y2′=g(x)u₁′y₁ + u₂′y₂ = 0 and u₁′y₁′ + u₂′y₂′ = g(x)

Solving this 2×2 system using Cramer's rule (or substitution) gives the formulas for u₁′ and u₂′ in terms of the Wronskian.

VARIATION OF PARAMETERS FORMULAS

u1′=−y2⋅g(x)/Wu2′=y1⋅g(x)/Wu₁′ = −y₂ · g(x) / W u₂′ = y₁ · g(x) / W

Where W is the Wronskian: W = y₁y₂′ − y₂y₁′. You then integrate u₁′ and u₂′ to find u₁ and u₂.

⚠

Don't Forget!

The equation must be in standard form (coefficient of y″ equal to 1) before you use these formulas. If your equation is, say, 2y″ + 6y′ + 4y = 10eˣ, divide everything by 2 first to get y″ + 3y′ + 2y = 5eˣ.

SECTION 5

The Wronskian — Your Key Tool

The Wronskian is the single most important computational tool in variation of parameters. Named after the Polish mathematician Józef Hoene-Wroński, it is a 2×2 determinant that tells you whether two solutions y₁ and y₂ are truly independent — and it appears in every formula for u₁′ and u₂′. If the Wronskian is zero everywhere, the two solutions are not independent, and the method cannot proceed.

The Wronskian Determinant2×2 DeterminantW = | y₁ y₂ | | y₁′ y₂′ |W = y₁y₂′ − y₂y₁′Must be ≠ 0 for the method to workExampley₁ = cos x, y₂ = sin xy₁′ = −sin xy₂′ = cos xW = (cos x)(cos x) − (sin x)(−sin x)W = 1 ✓What the Wronskian Tells You✓W ≠ 0 → y₁ and y₂ are linearly independentVariation of parameters will work✗W = 0 → y₁ and y₂ are dependentYou need to find different solutionsFor constant-coefficient equations, the Wronskian is never zero when y₁ and y₂ come from distinct roots.
The Wronskian determinant and a concrete example. With y₁ = cos x and y₂ = sin x, the Wronskian simplifies to W = 1, confirming the two solutions are independent. The bottom panel summarizes what W ≠ 0 and W = 0 each mean.

In practice, computing the Wronskian is straightforward. You write down your two solutions y₁ and y₂, differentiate each one to get y₁′ and y₂′, and then evaluate the 2×2 determinant. For constant-coefficient equations (the kind you'll see most often at this level), the Wronskian often turns out to be a simple exponential or even a constant — as in the cos x, sin x example above, where W = 1.

Homogeneous Solutionsy₁′, y₂′Wronskian W
y₁ = eˣ, y₂ = e²ˣeˣ, 2e²ˣeˣ · 2e²ˣ − e²ˣ · eˣ = e³ˣ
y₁ = cos 2x, y₂ = sin 2x−2 sin 2x, 2 cos 2x2cos²2x + 2sin²2x = 2
y₁ = e⁻ˣ, y₂ = xe⁻ˣ−e⁻ˣ, e⁻ˣ − xe⁻ˣe⁻ˣ(e⁻ˣ − xe⁻ˣ) − xe⁻ˣ(−e⁻ˣ) = e⁻²ˣ

Common Wronskian calculations for frequently encountered solution pairs

SECTION 6

Worked Example

Let's walk through a complete example to see every step of variation of parameters in action. We'll solve the equation y″ + y = sec x. Notice that the right side, sec x, is not an exponential, polynomial, or simple sine/cosine — so the method of undetermined coefficients would fail here. This is exactly the kind of problem where variation of parameters shines.

Solve y″ + y = sec x

  1. 1

    Step 1 — Verify Standard Form

    The equation y″ + y = sec x is already in standard form: the coefficient of y″ is 1, p(x) = 0, q(x) = 1, and g(x) = sec x. No division is needed.
    Standard form confirmed: g(x) = sec x
  2. 2

    Step 2 — Solve the Homogeneous Equation

    The homogeneous equation is y″ + y = 0. The characteristic equation is r² + 1 = 0, giving r = ±i. The two independent solutions are y₁ = cos x and y₂ = sin x, so the complementary solution is yc = c₁ cos x + c₂ sin x.
    y₁ = cos x, y₂ = sin x
  3. 3

    Step 3 — Compute the Wronskian

    We need y₁′ = −sin x and y₂′ = cos x. Then W = y₁y₂′ − y₂y₁′ = (cos x)(cos x) − (sin x)(−sin x) = cos²x + sin²x.
    W = 1
  4. 4

    Step 4 — Find u₁′ and u₂′

    Using the formulas: u₁′ = −y₂ · g(x) / W = −(sin x)(sec x) / 1 = −sin x · sec x = −sin x / cos x = −tan x. And u₂′ = y₁ · g(x) / W = (cos x)(sec x) / 1 = cos x · sec x = 1.
    u₁′ = −tan x, u₂′ = 1
  5. 5

    Step 5 — Integrate to Find u₁ and u₂

    u₁ = ∫(−tan x) dx = ln|cos x| (we drop the constant of integration since we only need one particular solution). u₂ = ∫ 1 dx = x.
    u₁ = ln|cos x|, u₂ = x
  6. 6

    Step 6 — Assemble the General Solution

    The particular solution is yp = u₁y₁ + u₂y₂ = (ln|cos x|)(cos x) + (x)(sin x) = cos x · ln|cos x| + x sin x. The general solution is y = yc + yp.
    y = c₁ cos x + c₂ sin x + cos x · ln|cos x| + x sin x
💡

Why This Matters

The function sec x cannot be handled by the method of undetermined coefficients because there is no finite combination of sec x and its derivatives that closes under differentiation. Variation of parameters handles it gracefully, proving its value as a universal method for nonhomogeneous linear ODEs.

SECTION 7

Strengths, Limitations & Comparison

You might wonder: if variation of parameters works for any g(x), why do we even bother with undetermined coefficients? The answer is efficiency. When undetermined coefficients applies, it's often faster because it avoids integration. But it only applies to a limited set of right-hand-side functions. Here's a side-by-side comparison of the two methods.

FeatureUndetermined CoefficientsVariation of Parameters
Types of g(x) handledPolynomials, exponentials, sines, cosines, and products/sums of theseAny continuous g(x)
Coefficient requirementsConstant coefficients onlyConstant or variable coefficients
Guesswork needed?Yes — you must guess the form of yₚNo guessing — systematic formulas
Integration required?No (only algebra)Yes — two integrals needed
Typical speedFaster when applicableSlower but always works
Best used wheng(x) is a standard formg(x) is non-standard (tan x, sec x, 1/x, etc.)

Comparison of the two main methods for finding particular solutions

✦

KEY TAKEAWAY

Think of undetermined coefficients as a specialized power tool — extremely fast for the right job, but only fits specific screws. Variation of parameters is like a universal wrench — it takes a bit more effort to use, but it fits every screw you'll ever encounter. The smart strategy is to check whether undetermined coefficients applies first; if not, reach for variation of parameters.

SECTION 8

Connection to Higher-Order & Advanced Theory

Variation of parameters is not limited to second-order equations. The same idea — replace constants in the complementary solution with unknown functions — extends naturally to third-order, fourth-order, and even n-th order linear ODEs. The Wronskian becomes a larger n×n determinant, and you solve an n×n system of equations for u₁′, u₂′, …, uₙ′. The algebra grows, but the principle is identical.

FeatureSecond-Order (This Lesson)Higher-Order / Advanced
Number of solutions needed2 (y₁, y₂)n (y₁, y₂, …, yₙ)
Wronskian size2×2 determinantn×n determinant
System to solve2 equations, 2 unknownsn equations, n unknowns
Integrals needed2n
Related advanced topicsBasic applicationGreen's functions, integral transforms, systems of ODEs

From second-order to the general n-th order case

In more advanced courses (college-level differential equations and beyond), you'll encounter Green's functions, which can be viewed as a generalization of variation of parameters. The particular solution formula can be rewritten as an integral involving a special function G(x, t) called the Green's function. This perspective connects variation of parameters to powerful tools used in physics, engineering, and applied mathematics.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

Explain in your own words why the method is called "variation of parameters." What exactly is being "varied," and why is this necessary?
Show answer
The "parameters" that are varied are the constants c₁ and c₂ in the complementary solution yc = c₁y₁ + c₂y₂. In the homogeneous case, these constants are fixed. Variation of parameters replaces them with unknown functions u₁(x) and u₂(x) that are allowed to change with x. This is necessary because the constant-coefficient combination can only satisfy the homogeneous equation — to account for the nonhomogeneous driving term g(x), the parameters must adapt ("vary") to absorb the effect of that driving force.

Question 2: BASIC CALCULATION

Compute the Wronskian of y₁ = e³ˣ and y₂ = e⁻ˣ.
Show answer
First, find the derivatives: y₁′ = 3e³ˣ and y₂′ = −e⁻ˣ. Then W = y₁y₂′ − y₂y₁′ = (e³ˣ)(−e⁻ˣ) − (e⁻ˣ)(3e³ˣ) = −e²ˣ − 3e²ˣ = −4e²ˣ. Since −4e²ˣ is never zero, the two solutions are linearly independent for all x, confirming they form a valid fundamental set of solutions.

Question 3: INTERMEDIATE

Use variation of parameters to find a particular solution to y″ − y = eˣ/x. (The homogeneous solutions are y₁ = eˣ and y₂ = e⁻ˣ.) Set up the integrals for u₁ and u₂; you do not need to evaluate them.
Show answer
First, confirm standard form: the equation is already y″ − y = eˣ/x, so g(x) = eˣ/x. Compute W = y₁y₂′ − y₂y₁′ = (eˣ)(−e⁻ˣ) − (e⁻ˣ)(eˣ) = −1 − 1 = −2. Then u₁′ = −y₂g(x)/W = −(e⁻ˣ)(eˣ/x)/(−2) = 1/(2x), and u₂′ = y₁g(x)/W = (eˣ)(eˣ/x)/(−2) = −e²ˣ/(2x). So u₁ = ∫ 1/(2x) dx = (1/2) ln|x|, and u₂ = ∫ −e²ˣ/(2x) dx (this integral cannot be expressed in elementary terms, which is fine — the setup is the key skill).

Question 4: APPLIED

A spring-mass system is modeled by y″ + 4y = tan(2x), where y represents displacement. Find the general solution using variation of parameters.
Show answer
The homogeneous equation y″ + 4y = 0 has characteristic equation r² + 4 = 0, giving r = ±2i. So y₁ = cos 2x and y₂ = sin 2x. The Wronskian is W = (cos 2x)(2cos 2x) − (sin 2x)(−2sin 2x) = 2cos²2x + 2sin²2x = 2. Then u₁′ = −(sin 2x)(tan 2x)/2 = −sin²2x/(2cos 2x) = −(1 − cos²2x)/(2cos 2x) = (cos 2x)/2 − (sec 2x)/2. And u₂′ = (cos 2x)(tan 2x)/2 = (sin 2x)/2. Integrating: u₁ = (sin 2x)/4 − (1/4)ln|sec 2x + tan 2x| and u₂ = −(cos 2x)/4. The particular solution is yₚ = u₁cos 2x + u₂sin 2x. The general solution is y = c₁cos 2x + c₂sin 2x + yₚ.

Question 5: CRITICAL THINKING

Why does the method of variation of parameters impose the condition u₁′y₁ + u₂′y₂ = 0? What would happen if we didn't impose this condition? Would the method still work? Explain your reasoning.
Show answer
When we substitute yₚ = u₁y₁ + u₂y₂ into the ODE, we compute yₚ′ using the product rule, which produces terms involving both u₁′ and u₂′. Without any extra condition, yₚ″ would contain second derivatives u₁″ and u₂″, leaving us with one equation but two unknown functions — an underdetermined system. The condition u₁′y₁ + u₂′y₂ = 0 eliminates the u₁″ and u₂″ terms from yₚ″, simplifying the resulting equation dramatically and giving us a clean second equation. Together with the ODE, we then have a 2×2 system in u₁′ and u₂′, which is solvable. The method would still theoretically work without this condition (any choice would lead to a valid particular solution), but the algebra would become far more complicated, and we'd have infinitely many choices — the Lagrange condition picks the simplest one.

SUMMARY

Lesson Summary

Summary

The method of variation of parameters is a systematic technique for finding a particular solution to any second-order linear nonhomogeneous ODE y″ + p(x)y′ + q(x)y = g(x). The method works by replacing the constants c₁ and c₂ in the complementary solution with unknown functions u₁(x) and u₂(x). The Wronskian W = y₁y₂′ − y₂y₁′ must be nonzero, confirming that y₁ and y₂ are linearly independent.

The formulas u₁′ = −y₂g(x)/W and u₂′ = y₁g(x)/W give you the derivatives of the unknown functions, which you then integrate to find u₁ and u₂. The general solution is y = c₁y₁ + c₂y₂ + u₁y₁ + u₂y₂. Unlike undetermined coefficients, this method works for any continuous g(x), making it the go-to approach when the driving function has a non-standard form like sec x, tan x, or 1/x.

Varsity Tutors • Differential Equations • Variation of Parameters — Method of Variation of Parameters (Intro)