Variation of Parameters

Suppose a mass on a spring is forced not by a clean sinusoid, but by a signal like g(t)=sec⁡tg(t) = \sec t or g(t)=1/tg(t) = 1/t. Can any method still hand us an explicit particular solution? This question matters because most forcing functions occurring in real circuits, structures, and orbits are not the polynomials, exponentials, and sinusoids that Method of Undetermined Coefficients can handle. Variation of parameters answers the question completely. Given any continuous forcing function, and given only the homogeneous solutions, it produces a particular solution. It does so by an explicit integral formula. The technique replaces the constants in the homogeneous solution with unknown functions. It then forces those functions to satisfy a clever pair of algebraic constraints. These constraints are solvable precisely because the The Wronskian and Linear Independence of the homogeneous solutions never vanishes. This article states and proves the variation-of-parameters formula for second-order linear equations in full generality. It works two asymmetric examples by hand. It shows exactly what fails without linear independence. Finally, it points toward its extension to higher-order and first-order linear systems.

Key takeaways
  • Variation of parameters produces a particular solution ypy_p for any continuous forcing g(t)g(t), not just special forms.
  • It starts from the homogeneous solutions y1,y2y_1, y_2 and lets the "constants" c1,c2c_1, c_2 become functions u1(t),u2(t)u_1(t), u_2(t).
  • Two algebraic conditions on u1′,u2′u_1', u_2' come from substitution; solving them requires the Wronskian W(y1,y2)≠0W(y_1,y_2) \neq 0.
  • The final formula is an explicit definite integral built from y1y_1, y2y_2, gg, and WW.
  • It strictly generalizes undetermined coefficients and handles g(t)=tan⁡tg(t) = \tan t, ln⁡t\ln t, 1/t1/t, etc.
  • Key idea: replace constants by functions, and choose those functions so the extra derivative terms cancel exactly.

Where this lives today

Variation of parameters extends directly to higher-order linear equations (see Higher-Order Linear Equations), where an n×nn \times n linear system built from the Wronskian-like determinant of nn fundamental solutions plays the same role, and to first-order linear systems x′=A(t)x+g(t)\mathbf{x}' = A(t)\mathbf{x} + \mathbf{g}(t) (see Systems of First-Order Linear ODEs), where the fundamental matrix Φ(t)\Phi(t) replaces the pair (y1,y2)(y_1,y_2) and the formula becomes xp(t)=Φ(t)∫Φ(t)−1g(t) dt\mathbf{x}_p(t) = \Phi(t)\int \Phi(t)^{-1}\mathbf{g}(t)\,dt. In physics, the same "constants become slowly varying functions" idea underlies classical perturbation theory for planetary orbits (Lagrange's original motivation) and the interaction picture in quantum mechanics, where wavefunction coefficients evolve slowly under a perturbing Hamiltonian. In electrical engineering, it computes the response of an RLCRLC circuit to an arbitrary time-varying voltage source that is not expressible via simple Laplace-transform table entries. In control theory, the variation-of-parameters (Duhamel) formula gives the state of a linear time-varying system driven by an arbitrary input, forming the basis of convolution representations of system response. In numerical analysis and applied math more broadly, the formula is the continuous analogue of Duhamel's principle, used to build solution representations for inhomogeneous PDEs (heat and wave equations) from their homogeneous Green's functions.

Ask the tutor: How does the variation-of-parameters formula change for a third-order linear equation, and what replaces the 2×22\times2 Wronskian system?

DefinitionVariation of Parameters — Setup and Formula

Consider the second-order linear nonhomogeneous equation in standard form

y′′+p(t) y′+q(t) y=g(t),y'' + p(t)\,y' + q(t)\,y = g(t),

where p,q,gp, q, g are continuous on an open interval II. Let y1,y2y_1, y_2 be a fundamental set of solutions of the associated homogeneous equation

y′′+p(t) y′+q(t) y=0y'' + p(t)\,y' + q(t)\,y = 0

on II, so that the Wronskian

W(t)=W(y1,y2)(t)=y1(t)y2′(t)−y1′(t)y2(t)W(t) = W(y_1,y_2)(t) = y_1(t)y_2'(t) - y_1'(t)y_2(t)

satisfies W(t)≠0W(t) \neq 0 for every t∈It \in I. Variation of parameters seeks a particular solution of the form

yp(t)=u1(t) y1(t)+u2(t) y2(t),y_p(t) = u_1(t)\,y_1(t) + u_2(t)\,y_2(t),

where u1,u2u_1, u_2 are functions (not constants) determined by imposing

u1′(t) y1(t)+u2′(t) y2(t)=0,u1′(t) y1′(t)+u2′(t) y2′(t)=g(t).u_1'(t)\,y_1(t) + u_2'(t)\,y_2(t) = 0, \qquad u_1'(t)\,y_1'(t) + u_2'(t)\,y_2'(t) = g(t).

Solving this linear system for u1′,u2′u_1', u_2' via Cramer's rule and integrating yields the particular solution

yp(t)=−y1(t)∫y2(t) g(t)W(t) dt  +  y2(t)∫y1(t) g(t)W(t) dt.y_p(t) = -y_1(t)\int \frac{y_2(t)\,g(t)}{W(t)}\,dt \;+\; y_2(t)\int \frac{y_1(t)\,g(t)}{W(t)}\,dt.

Intuition

The starting point is the general homogeneous solution yh(t)=c1y1(t)+c2y2(t)y_h(t) = c_1 y_1(t) + c_2 y_2(t), valid when g≡0g \equiv 0. When g≢0g \not\equiv 0, constants c1,c2c_1, c_2 can no longer make the equation balance — the equation has a "budget" of forcing g(t)g(t) to absorb at every instant, and fixed constants have no way to track a moving target. The fix is to let the coefficients drift in time, c1→u1(t)c_1 \to u_1(t) and c2→u2(t)c_2 \to u_2(t), giving them exactly enough freedom to soak up the forcing at each instant while still riding along the shapes y1,y2y_1, y_2 that solve the homogeneous problem. There is a subtlety: differentiating yp=u1y1+u2y2y_p = u_1 y_1 + u_2 y_2 twice introduces four new terms involving u1′,u2′,u1′′,u2′′u_1', u_2', u_1'', u_2'', and substituting into the ODE gives one equation in two unknown functions u1,u2u_1, u_2 — hopelessly underdetermined without another condition. The trick is to impose a second condition by choice: demand u1′y1+u2′y2=0u_1' y_1 + u_2' y_2 = 0. This eliminates the second-derivative terms from the substitution entirely, and what remains collapses to a clean 2×22\times 2 linear algebraic system for u1′(t),u2′(t)u_1'(t), u_2'(t) at each fixed tt. That system's coefficient matrix is exactly the matrix whose determinant is the Wronskian — this is the payoff for demanding y1,y2y_1, y_2 be linearly independent solutions in the first place. Geometrically, think of (y1(t),y1′(t))(y_1(t), y_1'(t)) and (y2(t),y2′(t))(y_2(t), y_2'(t)) as two vectors in the phase plane at each time tt. Linear independence of y1,y2y_1, y_2 as functions is equivalent to these two vectors never being parallel, i.e. W(t)≠0W(t) \neq 0. The system for u1′,u2′u_1', u_2' asks: "in the basis given by these two non-parallel vectors, how do I resolve the pure forcing vector (0,g(t))(0, g(t))?" Because the vectors are never parallel, this resolution is always possible and unique.

Figure
The two homogeneous solution-vectors in phase space span the plane whenever W(t)≠0W(t)\neq 0, allowing the forcing vector (0,g(t))(0,g(t)) to be resolved uniquely
y y' (y₁, y₁′) (y₂, y₂′) (0, g(t)) not parallel ⇒ W(t) ≠ 0

The Central Theorem

TheoremVariation of Parameters Formula

Let I⊂RI \subset \mathbb{R} be an open interval and let p,q,g:I→Rp, q, g : I \to \mathbb{R} be continuous functions. Consider

y′′+p(t) y′+q(t) y=g(t),(∗)y'' + p(t)\,y' + q(t)\,y = g(t), \tag{$\ast$}

and suppose y1,y2y_1, y_2 form a fundamental set of solutions of the homogeneous equation

y′′+p(t) y′+q(t) y=0y'' + p(t)\,y' + q(t)\,y = 0

on II, i.e. y1,y2y_1, y_2 are twice continuously differentiable, each solves the homogeneous equation, and their Wronskian W(t)=y1(t)y2′(t)−y1′(t)y2(t)W(t) = y_1(t)y_2'(t) - y_1'(t)y_2(t) is nonzero for every t∈It \in I. Fix any t0∈It_0 \in I. Then the function

yp(t)=−y1(t)∫t0ty2(s) g(s)W(s) ds  +  y2(t)∫t0ty1(s) g(s)W(s) dsy_p(t) = -y_1(t)\int_{t_0}^{t} \frac{y_2(s)\,g(s)}{W(s)}\,ds \;+\; y_2(t)\int_{t_0}^{t} \frac{y_1(s)\,g(s)}{W(s)}\,ds

is well-defined, twice continuously differentiable on II, and satisfies (∗)(\ast) on II. Consequently, the general solution of (∗)(\ast) on II is

y(t)=c1y1(t)+c2y2(t)+yp(t),c1,c2∈R.y(t) = c_1 y_1(t) + c_2 y_2(t) + y_p(t), \qquad c_1, c_2 \in \mathbb{R}.
Proof

Technique: direct construction and verification (variation of the constants, followed by substitution check). Step 1 — Setting up the ansatz. Seek a particular solution of the form

yp(t)=u1(t)y1(t)+u2(t)y2(t)y_p(t) = u_1(t) y_1(t) + u_2(t) y_2(t)

for functions u1,u2u_1, u_2 to be determined, assumed differentiable where needed (this will be justified by the explicit formula obtained). Differentiate once:

yp′=u1′y1+u1y1′+u2′y2+u2y2′.y_p' = u_1' y_1 + u_1 y_1' + u_2' y_2 + u_2 y_2'.

There are two unknown functions u1,u2u_1, u_2 but so far only one equation will eventually come from substituting into (∗)(\ast); to pin down u1,u2u_1, u_2 uniquely we impose, by choice, the auxiliary condition

u1′y1+u2′y2=0.(A)u_1' y_1 + u_2' y_2 = 0. \tag{A}

This is legitimate: we are not assuming a fact but choosing one of two degrees of freedom to simplify the computation; we must verify at the end that a solution satisfying (A) actually produces a genuine particular solution, which we do below. With (A) imposed,

yp′=u1y1′+u2y2′.y_p' = u_1 y_1' + u_2 y_2'.

Step 2 — Second derivative and substitution. Differentiate again:

yp′′=u1′y1′+u1y1′′+u2′y2′+u2y2′′.y_p'' = u_1' y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2''.

Substitute yp,yp′,yp′′y_p, y_p', y_p'' into (∗)(\ast):

(u1′y1′+u1y1′′+u2′y2′+u2y2′′)+p(u1y1′+u2y2′)+q(u1y1+u2y2)=g.\big(u_1' y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2''\big) + p\big(u_1 y_1' + u_2 y_2'\big) + q\big(u_1 y_1 + u_2 y_2\big) = g.

Group terms by u1u_1 and u2u_2:

u1(y1′′+py1′+qy1)+u2(y2′′+py2′+qy2)+(u1′y1′+u2′y2′)=g.u_1\big(y_1'' + p y_1' + q y_1\big) + u_2\big(y_2'' + p y_2' + q y_2\big) + \big(u_1' y_1' + u_2' y_2'\big) = g.

Since y1y_1 and y2y_2 each solve the homogeneous equation, the two parenthesized coefficients of u1u_1 and u2u_2 vanish identically. What remains is the second condition

u1′y1′+u2′y2′=g.(B)u_1' y_1' + u_2' y_2' = g. \tag{B}

Step 3 — Solving the linear system (A)–(B) using the Wronskian. Conditions (A) and (B) together form the linear system

(y1y2y1′y2′)(u1′u2′)=(0g)\begin{pmatrix} y_1 & y_2 \\ y_1' & y_2' \end{pmatrix} \begin{pmatrix} u_1' \\ u_2' \end{pmatrix} = \begin{pmatrix} 0 \\ g \end{pmatrix}

at each t∈It \in I. The coefficient matrix has determinant exactly W(t)=y1y2′−y1′y2W(t) = y_1 y_2' - y_1' y_2, which is nonzero for all t∈It \in I by hypothesis (this is precisely where linear independence of y1,y2y_1, y_2, via The Wronskian and Linear Independence, is used). Hence the matrix is invertible at every tt, and by Cramer's rule the unique solution is

u1′(t)=∣0y2(t)g(t)y2′(t)∣W(t)=−y2(t)g(t)W(t),u2′(t)=∣y1(t)0y1′(t)g(t)∣W(t)=y1(t)g(t)W(t).u_1'(t) = \frac{\begin{vmatrix} 0 & y_2(t) \\ g(t) & y_2'(t)\end{vmatrix}}{W(t)} = \frac{-y_2(t) g(t)}{W(t)}, \qquad u_2'(t) = \frac{\begin{vmatrix} y_1(t) & 0 \\ y_1'(t) & g(t)\end{vmatrix}}{W(t)} = \frac{y_1(t) g(t)}{W(t)}.

Both right-hand sides are continuous on II: y1,y2y_1, y_2 are C2C^2 hence continuous, gg is continuous by hypothesis, and WW is continuous (a sum of products of continuous functions) and nonvanishing, so the quotient is continuous. Continuous functions have antiderivatives (by the Fundamental Theorem of Calculus), so define

u1(t)=−∫t0ty2(s)g(s)W(s) ds,u2(t)=∫t0ty1(s)g(s)W(s) ds,u_1(t) = -\int_{t_0}^{t} \frac{y_2(s) g(s)}{W(s)}\, ds, \qquad u_2(t) = \int_{t_0}^{t} \frac{y_1(s) g(s)}{W(s)}\, ds,

for a fixed base point t0∈It_0 \in I. These are well-defined, differentiable on II (again by the Fundamental Theorem of Calculus, since the integrands are continuous), with derivatives exactly matching the required u1′,u2′u_1', u_2' above. Since u1′,u2′u_1', u_2' are themselves continuous, u1,u2u_1, u_2 are in fact C1C^1, and since y1,y2∈C2y_1, y_2 \in C^2, the combination yp=u1y1+u2y2y_p = u_1 y_1 + u_2 y_2 is C2C^2 as required (each term is a product of a C1C^1 and a C2C^2 function, hence C1C^1; and we already showed yp′y_p' is differentiable again in Step 2's computation, which used only y1′′,y2′′y_1'', y_2'' existing and u1′,u2′u_1', u_2' existing — all present). Step 4 — Verification that ypy_p solves (∗)(\ast). By construction, u1,u2u_1, u_2 satisfy (A) and (B) by the Fundamental Theorem of Calculus applied to their defining integrals. Retracing Steps 1–2 in reverse: because (A) holds, yp′=u1y1′+u2y2′y_p' = u_1 y_1' + u_2 y_2'; because (A) and (B) both hold, the substitution computation in Step 2 shows

yp′′+pyp′+qyp=u1(y1′′+py1′+qy1)+u2(y2′′+py2′+qy2)+(u1′y1′+u2′y2′)=0+0+g=g.y_p'' + p y_p' + q y_p = u_1(y_1'' + p y_1' + q y_1) + u_2(y_2'' + p y_2' + q y_2) + (u_1' y_1' + u_2' y_2') = 0 + 0 + g = g.

Thus ypy_p solves (∗)(\ast) on II. Substituting the explicit forms of u1,u2u_1, u_2 gives the stated closed formula for ypy_p. Step 5 — General solution. Let yy be any solution of (∗)(\ast) on II. Then y−ypy - y_p satisfies, by linearity of the differential operator,

(y−yp)′′+p(y−yp)′+q(y−yp)=g−g=0,(y - y_p)'' + p(y-y_p)' + q(y - y_p) = g - g = 0,

so y−ypy - y_p solves the homogeneous equation. Since y1,y2y_1, y_2 form a fundamental set, every homogeneous solution is uniquely c1y1+c2y2c_1 y_1 + c_2 y_2 for some constants c1,c2c_1, c_2 (this is the standard existence-and-uniqueness consequence for linear homogeneous equations, taken as known background here). Hence y=c1y1+c2y2+ypy = c_1 y_1 + c_2 y_2 + y_p, establishing that this family is exactly the general solution of (∗)(\ast). ■\blacksquare

∎

Worked examples

Example 1: Non-constant forcing requiring variation of parameters, with g(t)=tan⁡tg(t) = \tan t. Solve y′′+y=tan⁡ty'' + y = \tan t on the interval I=(−π/2,π/2)I = (-\pi/2, \pi/2) (where tan⁡t\tan t is continuous). The homogeneous equation y′′+y=0y'' + y = 0 has fundamental set y1(t)=cos⁡ty_1(t) = \cos t, y2(t)=sin⁡ty_2(t) = \sin t. Compute the Wronskian:

W(t)=y1y2′−y1′y2=cos⁡t⋅cos⁡t−(−sin⁡t)⋅sin⁡t=cos⁡2t+sin⁡2t=1.W(t) = y_1 y_2' - y_1' y_2 = \cos t \cdot \cos t - (-\sin t)\cdot \sin t = \cos^2 t + \sin^2 t = 1.

So W≡1≠0W \equiv 1 \neq 0 on II, confirming a fundamental set. Undetermined coefficients cannot handle tan⁡t\tan t (it is not a solution of any constant-coefficient homogeneous equation), so variation of parameters is the tool required. Using the formula with t0=0t_0 = 0:

u1′(t)=−y2(t)g(t)W(t)=−sin⁡ttan⁡t=−sin⁡2tcos⁡t=cos⁡2t−1cos⁡t=cos⁡t−sec⁡t.u_1'(t) = \frac{-y_2(t)g(t)}{W(t)} = -\sin t \tan t = -\frac{\sin^2 t}{\cos t} = \frac{\cos^2 t - 1}{\cos t} = \cos t - \sec t.

Integrate:

u1(t)=∫0t(cos⁡s−sec⁡s) ds=sin⁡t−ln⁡∣sec⁡t+tan⁡t∣.u_1(t) = \int_0^t (\cos s - \sec s)\, ds = \sin t - \ln|\sec t + \tan t|.

Next,

u2′(t)=y1(t)g(t)W(t)=cos⁡ttan⁡t=sin⁡t,u_2'(t) = \frac{y_1(t)g(t)}{W(t)} = \cos t \tan t = \sin t,

so

u2(t)=∫0tsin⁡s ds=1−cos⁡t.u_2(t) = \int_0^t \sin s \, ds = 1 - \cos t.

Assemble the particular solution:

yp(t)=u1(t)cos⁡t+u2(t)sin⁡t=(sin⁡t−ln⁡∣sec⁡t+tan⁡t∣)cos⁡t+(1−cos⁡t)sin⁡t.y_p(t) = u_1(t)\cos t + u_2(t)\sin t = \big(\sin t - \ln|\sec t + \tan t|\big)\cos t + (1 - \cos t)\sin t.

Expand and simplify:

yp(t)=sin⁡tcos⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣+sin⁡t−sin⁡tcos⁡t=sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣.y_p(t) = \sin t \cos t - \cos t \ln|\sec t + \tan t| + \sin t - \sin t \cos t = \sin t - \cos t \ln|\sec t + \tan t|.

The sin⁡tcos⁡t\sin t \cos t terms cancel exactly — a useful arithmetic check. The general solution is

y(t)=c1cos⁡t+c2sin⁡t+sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣,y(t) = c_1 \cos t + c_2 \sin t + \sin t - \cos t \ln|\sec t + \tan t|,

and since sin⁡t\sin t already appears in the homogeneous family, one may absorb it: y(t)=c1cos⁡t+c~2sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣y(t) = c_1 \cos t + \tilde c_2 \sin t - \cos t \ln|\sec t + \tan t| with c~2=c2+1\tilde c_2 = c_2 + 1 arbitrary. As a sanity check, differentiate yp=sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣y_p = \sin t - \cos t \ln|\sec t + \tan t| directly:

yp′=cos⁡t+sin⁡tln⁡∣sec⁡t+tan⁡t∣−cos⁡t⋅sec⁡ttan⁡t+sec⁡2tsec⁡t+tan⁡t=cos⁡t+sin⁡tln⁡∣sec⁡t+tan⁡t∣−1,y_p' = \cos t + \sin t \ln|\sec t + \tan t| - \cos t \cdot \frac{\sec t \tan t + \sec^2 t}{\sec t + \tan t} = \cos t + \sin t \ln|\sec t + \tan t| - 1,

using sec⁡t(tan⁡t+sec⁡t)sec⁡t+tan⁡t=sec⁡t\frac{\sec t(\tan t + \sec t)}{\sec t + \tan t} = \sec t. Then

yp′′=−sin⁡t+cos⁡tln⁡∣sec⁡t+tan⁡t∣+sin⁡t⋅sec⁡t=−sin⁡t+cos⁡tln⁡∣sec⁡t+tan⁡t∣+tan⁡t.y_p'' = -\sin t + \cos t \ln|\sec t + \tan t| + \sin t \cdot \sec t = -\sin t + \cos t \ln|\sec t+\tan t| + \tan t.

Add: yp′′+yp=(−sin⁡t+cos⁡tln⁡∣sec⁡t+tan⁡t∣+tan⁡t)+(sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣)=tan⁡ty_p'' + y_p = \big(-\sin t + \cos t\ln|\sec t + \tan t| + \tan t\big) + \big(\sin t - \cos t \ln|\sec t+\tan t|\big) = \tan t, confirming the solution.

Example 2: A Cauchy–Euler equation with forcing g(t)=tln⁡tg(t) = t\ln t (variable coefficients, asymmetric homogeneous solutions). Solve, for t>0t > 0,

t2y′′−2ty′+2y=t3ln⁡t.t^2 y'' - 2t y' + 2y = t^3 \ln t.

First convert to standard form by dividing by t2t^2 (valid since t>0t > 0):

y′′−2ty′+2t2y=tln⁡t,p(t)=−2t,  q(t)=2t2,  g(t)=tln⁡t.y'' - \frac{2}{t} y' + \frac{2}{t^2} y = t \ln t, \qquad p(t) = -\frac{2}{t}, \; q(t) = \frac{2}{t^2}, \; g(t) = t\ln t.

This is a Cauchy–Euler equation; trying y=try = t^r in t2y′′−2ty′+2y=0t^2y'' - 2ty' + 2y=0 gives r(r−1)−2r+2=0r(r-1) - 2r + 2 = 0, i.e. r2−3r+2=0r^2 - 3r + 2 = 0, so r=1,2r = 1, 2. Take the fundamental set

y1(t)=t,y2(t)=t2.y_1(t) = t, \qquad y_2(t) = t^2.

Compute the Wronskian:

W(t)=y1y2′−y1′y2=t(2t)−(1)(t2)=2t2−t2=t2,W(t) = y_1 y_2' - y_1' y_2 = t(2t) - (1)(t^2) = 2t^2 - t^2 = t^2,

nonzero for t>0t > 0, confirming linear independence there. Now apply the formula with the standard-form g(t)=tln⁡tg(t) = t\ln t:

u1′(t)=−y2(t)g(t)W(t)=−t2⋅tln⁡tt2=−tln⁡t.u_1'(t) = \frac{-y_2(t) g(t)}{W(t)} = \frac{-t^2 \cdot t\ln t}{t^2} = -t \ln t.

Integrate by parts (∫tln⁡t dt=t22ln⁡t−t24\int t \ln t\, dt = \tfrac{t^2}{2}\ln t - \tfrac{t^2}{4}):

u1(t)=−∫tln⁡t dt=−t22ln⁡t+t24.u_1(t) = -\int t \ln t \, dt = -\frac{t^2}{2}\ln t + \frac{t^2}{4}.

Next,

u2′(t)=y1(t)g(t)W(t)=t⋅tln⁡tt2=ln⁡t,u_2'(t) = \frac{y_1(t) g(t)}{W(t)} = \frac{t \cdot t \ln t}{t^2} = \ln t,

so, integrating by parts (∫ln⁡t dt=tln⁡t−t\int \ln t\, dt = t\ln t - t),

u2(t)=∫ln⁡t dt=tln⁡t−t.u_2(t) = \int \ln t \, dt = t\ln t - t.

Assemble:

yp(t)=u1(t)y1(t)+u2(t)y2(t)=(−t22ln⁡t+t24)t+(tln⁡t−t) t2.y_p(t) = u_1(t) y_1(t) + u_2(t) y_2(t) = \left(-\frac{t^2}{2}\ln t + \frac{t^2}{4}\right)t + (t\ln t - t)\,t^2.

Expand:

yp(t)=−t32ln⁡t+t34+t3ln⁡t−t3=t32ln⁡t−3t34.y_p(t) = -\frac{t^3}{2}\ln t + \frac{t^3}{4} + t^3 \ln t - t^3 = \frac{t^3}{2}\ln t - \frac{3t^3}{4}.

Since −34t3-\tfrac{3}{4}t^3 is not a homogeneous solution (the homogeneous solutions are t,t2t, t^2, not t3t^3), this term must remain — a good asymmetry check distinguishing this from Example 1, where a stray homogeneous term appeared and could be absorbed. Check by direct substitution. With yp=12t3ln⁡t−34t3y_p = \tfrac{1}{2}t^3\ln t - \tfrac34 t^3:

yp′=32t2ln⁡t+12t2−94t2=32t2ln⁡t−74t2,y_p' = \frac{3}{2}t^2 \ln t + \frac12 t^2 - \frac94 t^2 = \frac32 t^2 \ln t - \frac74 t^2,
yp′′=3tln⁡t+32t−72t=3tln⁡t−2t.y_p'' = 3t\ln t + \frac32 t - \frac72 t = 3t \ln t - 2t.

Now compute t2yp′′−2typ′+2ypt^2 y_p'' - 2t y_p' + 2 y_p:

t2(3tln⁡t−2t)−2t(32t2ln⁡t−74t2)+2(12t3ln⁡t−34t3)t^2(3t\ln t - 2t) - 2t\left(\frac32 t^2 \ln t - \frac74 t^2\right) + 2\left(\frac12 t^3 \ln t - \frac34 t^3\right)
=3t3ln⁡t−2t3−3t3ln⁡t+72t3+t3ln⁡t−32t3=t3ln⁡t(3−3+1)+t3(−2+72−32)=t3ln⁡t+0.= 3t^3 \ln t - 2t^3 - 3t^3\ln t + \frac72 t^3 + t^3 \ln t - \frac32 t^3 = t^3 \ln t \left(3 - 3 + 1\right) + t^3\left(-2 + \frac72 - \frac32\right) = t^3 \ln t + 0.

This matches the original right-hand side t3ln⁡tt^3 \ln t exactly, confirming the solution. The general solution is

y(t)=c1t+c2t2+12t3ln⁡t−34t3,t>0.y(t) = c_1 t + c_2 t^2 + \frac{1}{2}t^3\ln t - \frac{3}{4}t^3, \qquad t>0.
CounterexampleWhy linear independence of y1,y2y_1, y_2 (nonvanishing Wronskian) is essential

Drop the hypothesis that y1,y2y_1, y_2 form a fundamental set, and instead pick two homogeneous solutions that are linearly dependent. Consider again y′′+y=tan⁡ty'' + y = \tan t on (−π/2,π/2)(-\pi/2, \pi/2), but instead of the correct fundamental set, take

y~1(t)=sin⁡t,y~2(t)=2sin⁡t.\tilde y_1(t) = \sin t, \qquad \tilde y_2(t) = 2\sin t.

Both solve y′′+y=0y'' + y = 0 (any scalar multiple of a homogeneous solution is a homogeneous solution), but y~2=2y~1\tilde y_2 = 2\tilde y_1, so they are linearly dependent. Their Wronskian is

W(t)=y~1y~2′−y~1′y~2=sin⁡t(2cos⁡t)−cos⁡t(2sin⁡t)=0for all t.W(t) = \tilde y_1 \tilde y_2' - \tilde y_1' \tilde y_2 = \sin t (2\cos t) - \cos t (2\sin t) = 0 \quad \text{for all } t.

Attempting the variation-of-parameters system,

(sin⁡t2sin⁡tcos⁡t2cos⁡t)(u1′u2′)=(0tan⁡t),\begin{pmatrix} \sin t & 2\sin t \\ \cos t & 2\cos t\end{pmatrix} \begin{pmatrix} u_1' \\ u_2' \end{pmatrix} = \begin{pmatrix} 0 \\ \tan t\end{pmatrix},

has coefficient matrix with determinant W(t)≡0W(t) \equiv 0, hence it is never invertible on any subinterval. Cramer's rule breaks down (division by zero), and in fact the system is either inconsistent or has infinitely many solutions at each tt rather than a unique one — the derivation in Step 3 of the theorem's proof collapses entirely, since the very first step (inverting the coefficient matrix) is impossible. No consistent choice of continuous u1′,u2′u_1', u_2' solving both (A) and (B) can be extracted by this method. The deeper reason: with y~1,y~2\tilde y_1, \tilde y_2 dependent, {y~1,y~2}\{\tilde y_1, \tilde y_2\} spans only a one-dimensional space of functions, so u1y~1+u2y~2=2u1sin⁡t+2u2sin⁡tu_1 \tilde y_1 + u_2 \tilde y_2 = 2u_1 \sin t + 2 u_2 \sin t can only ever produce multiples of sin⁡t\sin t, regardless of how u1,u2u_1, u_2 are chosen — it cannot produce the needed extra "boost" (−cos⁡tln⁡∣sec⁡t+tan⁡t∣-\cos t \ln|\sec t + \tan t|, found in Example 1) that lies outside span{sin⁡t}\mathrm{span}\{\sin t\}. This confirms that the nonvanishing-Wronskian hypothesis is not a technical convenience but is load-bearing: without it the ansatz yp=u1y1+u2y2y_p = u_1 y_1 + u_2 y_2 cannot reach the required particular solution at all.

Scope, edge cases & common traps

SituationWhat happensCorrect handling
Equation not in standard form y′′+py′+qy=gy''+py'+q y = gUsing the raw gg from a(t)y′′+b(t)y′+c(t)y=g(t)a(t)y''+b(t)y'+c(t)y=g(t)Divide through by a(t)a(t) first; the formula needs the standard-form g/a(t)g/a(t)
gg is a "nice" function (polynomial × exponential × sinusoid)Both methods workUndetermined coefficients is usually faster; variation of parameters always works too
g(t)=tan⁡t,sec⁡t,ln⁡t,1/t,et/tg(t) = \tan t, \sec t, \ln t, 1/t, e^t/t, etc.Undetermined coefficients fails (no finite trial family)Variation of parameters is the only elementary route
Interval where W(t)=0W(t) = 0 at isolated pointsFormula's integrals may diverge or be undefinedRestrict to a subinterval where W≠0W \neq 0 throughout
Homogeneous solutions chosen linearly dependentW≡0W \equiv 0, system uninvertible everywhereAlways verify W≠0W \neq 0 before proceeding — see the counterexample
Resulting ypy_p contains a homogeneous-solution termLooks "wrong" compared to a textbook answerIt is still correct; such a term can be absorbed into c1y1+c2y2c_1 y_1 + c_2 y_2

The mathematician behind it

Origins · 1 minJoseph-Louis Lagrange and how this was discovered
JL
Joseph-Louis Lagrange
1736–1813 · 18th-century mathematical physics and analysis

Lagrange, born in Turin and later a central figure at the Berlin Academy and the Paris École Polytechnique, developed the method of variation of arbitrary constants (his own term for what is now called variation of parameters) in his work on celestial mechanics during the 1770s and 1780s. He needed a way to describe how the orbital "constants" of a two-body Kepler orbit — semi-major axis, eccentricity, and so on — slowly drift under the gravitational perturbation of a third body. Treating these constants as slowly varying functions of time, governed by a system of differential equations derived exactly as in the proof above, became one of the most durable techniques in both pure and applied analysis, later reappearing as the foundation of perturbation theory in mechanics and in the modern treatment of first-order linear systems.

History
- 1736: Lagrange born in Turin, Kingdom of Sardinia.
- 1766: Lagrange succeeds Euler as director of mathematics at the Prussian Academy of Sciences in Berlin.
- 1775–1782: Lagrange develops variation of arbitrary constants to handle secular perturbations in planetary orbit theory.
- 1788: Publication of Mécanique analytique, consolidating variational methods in mechanics.
- 1813: Lagrange dies in Paris, having reshaped analysis, mechanics, and the calculus of variations.
Do I need to memorize the boxed integral formula, or is it enough to know the derivation?

Either works, but knowing the derivation is far more robust. The boxed formula yp=−y1∫y2g/W dt+y2∫y1g/W dty_p = -y_1\int y_2 g/W\,dt + y_2 \int y_1 g/W\,dt is easy to misremember (sign errors, swapped subscripts), while the derivation — impose u1′y1+u2′y2=0u_1'y_1+u_2'y_2=0, substitute to get u1′y1′+u2′y2′=gu_1'y_1'+u_2'y_2'=g, solve the 2×22\times2 system via the Wronskian, integrate — regenerates the correct formula every time and also makes clear exactly what "standard form" means for gg. For exams, deriving u1′,u2′u_1', u_2' from scratch on the given equation is safer than recalling the formula verbatim.

Does variation of parameters work when the homogeneous equation has variable coefficients, not just constant coefficients?

Yes — this is exactly where variation of parameters is indispensable, since undetermined coefficients requires constant coefficients (or at least a finite-dimensional annihilator structure) and simply does not apply to variable-coefficient equations. Example 2 above is a Cauchy–Euler (variable-coefficient) equation, and the method worked without modification, using whatever fundamental set y1,y2y_1, y_2 happens to solve the homogeneous variable-coefficient equation. The only requirements are that p,q,gp, q, g be continuous on the interval and that a fundamental set with nonvanishing Wronskian be known or found by other means (such as the Cauchy–Euler trial solution y=try=t^r, or reduction of order given one solution).

What if I cannot find y1y_1 and y2y_2 explicitly?

Then variation of parameters cannot get started, because the entire formula is built from y1,y2y_1, y_2 and their Wronskian. The method presupposes that the homogeneous equation has already been solved. If only one homogeneous solution y1y_1 is known, the technique of reduction of order can sometimes produce a second, linearly independent solution y2y_2, after which variation of parameters applies as usual. For homogeneous equations with no closed-form solution at all, one typically resorts to power series methods or numerical integration instead.

Is variation of parameters ever the wrong tool even when it technically applies?

Yes, in the sense of practicality. If g(t)g(t) is a polynomial, exponential, sine/cosine, or product of these, and the equation has constant coefficients, undetermined coefficients is almost always faster because it avoids computing integrals (sometimes quite involved ones, as in Examples 1–2 above, requiring integration by parts or logarithms of trigonometric expressions). Variation of parameters is best reserved for forcing functions like tan⁡t\tan t, sec⁡t\sec t, ln⁡t\ln t, or 1/t1/t that undetermined coefficients cannot handle at all, or for variable-coefficient equations where undetermined coefficients does not apply in principle.

Why does the formula involve dividing by W(t)W(t) rather than just by y1y_1 or y2y_2 individually?

Because the system for u1′,u2′u_1', u_2' is a genuine 2×22\times2 linear system, not two separate one-variable equations. Cramer's rule for such a system always produces a determinant (here, the Wronskian) in every denominator, reflecting the fact that u1′u_1' and u2′u_2' each depend on both rows of the original system simultaneously. Dividing by y1y_1 or y2y_2 alone would implicitly assume the system decouples, which it does not — the two conditions u1′y1+u2′y2=0u_1'y_1+u_2'y_2=0 and u1′y1′+u2′y2′=gu_1'y_1'+u_2'y_2'=g are coupled equations in u1′,u2′u_1', u_2' together.

Can this method produce a particular solution that already contains a piece of the homogeneous solution?

Yes, and this is not an error. Example 1 above produced yp=sin⁡t−cos⁡tln⁡∣sec⁡t+tan⁡t∣y_p = \sin t - \cos t\ln|\sec t+\tan t|, where the sin⁡t\sin t term is itself a homogeneous solution. Since the constant t0t_0 in the definite integrals is arbitrary, different choices of t0t_0 shift ypy_p by constants times y1,y2y_1, y_2 — all such choices give equally valid particular solutions, and they all get absorbed into the arbitrary constants c1,c2c_1, c_2 when writing the general solution y=c1y1+c2y2+ypy = c_1y_1+c_2y_2+y_p.

How does this generalize beyond second-order equations?

For an nnth-order linear equation with fundamental set y1,…,yny_1,\dots,y_n, the ansatz yp=∑uiyiy_p = \sum u_i y_i is supplemented by n−1n-1 auxiliary conditions analogous to (A), plus one final condition analogous to (B) coming from substitution, giving an n×nn\times n linear system for u1′,…,un′u_1',\dots,u_n' whose coefficient matrix determinant is again the Wronskian of y1,…,yny_1,\dots,y_n. The same idea, phrased in matrix form using a fundamental matrix Φ(t)\Phi(t), gives the variation-of-parameters (Duhamel) formula for general first-order linear systems x′=A(t)x+g(t)\mathbf{x}'=A(t)\mathbf{x}+\mathbf{g}(t), which is the natural setting explored in Systems of First-Order Linear ODEs.

Before this

Where this leads