Variation of Parameters
Undetermined
coefficients is fast, but it lives on a short list of forcing terms — polynomials,
exponentials, sines and cosines, and their products. Feed it something off the menu —
\sec x, \tan x,
\ln x, 1/x — and there is simply
no form to guess. The method has nothing to substitute.
Variation of parameters is the method that never runs out. Given the two
homogeneous solutions y_1 and y_2, it
writes down a particular solution of
y'' + p(x)\,y' + q(x)\,y = g(x)
for any continuous g(x) — no guessing, no lucky
list. The price is a couple of integrals, which may or may not be pretty; the guarantee is that
the recipe always gives you those integrals.
The idea: let the constants vary
The homogeneous solution is y_h = C_1 y_1 + C_2 y_2, with
C_1, C_2 constant. Lagrange's trick — the one that names the
method — is to promote the constants to functions and look for a particular
solution of the same shape:
y_p = u_1(x)\,y_1 + u_2(x)\,y_2.
We have two unknown functions but only one equation to satisfy, so we get to impose one
extra condition of our own choosing. Differentiate once:
y_p' = \big(u_1' y_1 + u_2' y_2\big) + \big(u_1 y_1' + u_2 y_2'\big).
The clever choice is to kill the first bracket — the imposed condition:
-
Require u_1' y_1 + u_2' y_2 = 0. This keeps
y_p' free of the second derivatives of
u_1, u_2, so the algebra stays linear and first-order in the
unknowns.
With that bracket gone, y_p' = u_1 y_1' + u_2 y_2'. Differentiate
again and substitute y_p, y_p', y_p'' into the ODE. Every term
containing only u_1, u_2 collapses, because
y_1 and y_2 each solve the homogeneous
equation. What survives is a second, clean equation:
u_1' y_1' + u_2' y_2' = g(x).
Now stack the two conditions as a linear system in u_1' and
u_2':
\begin{cases} u_1' y_1 + u_2' y_2 = 0, \\[2pt] u_1' y_1' + u_2' y_2' = g(x). \end{cases}
The Wronskian solves it
The coefficient matrix of that system is exactly the pair
y_1, y_2 and their derivatives, and its determinant is the
Wronskian
of the homogeneous solutions:
W = W(y_1, y_2) = \begin{vmatrix} y_1 & y_2 \\ y_1' & y_2' \end{vmatrix} = y_1 y_2' - y_2 y_1'.
Because y_1, y_2 are linearly independent solutions,
W \neq 0 everywhere, so Cramer's rule cracks the
system straight open:
-
\displaystyle u_1' = \frac{-\,y_2\, g}{W}, so
\displaystyle u_1 = -\int \frac{y_2\, g}{W}\,dx.
-
\displaystyle u_2' = \frac{\;y_1\, g}{W}, so
\displaystyle u_2 = \int \frac{y_1\, g}{W}\,dx.
-
The particular solution is
y_p = u_1 y_1 + u_2 y_2, and the general solution is
y = C_1 y_1 + C_2 y_2 + y_p.
That is the whole method. Notice the shape of it: you need nothing about the forcing
g except that you can integrate y_2 g / W
and y_1 g / W. No form to match, no resonance special-case — a term
that overlaps y_h just gets absorbed into
C_1, C_2 automatically.
Undetermined coefficients is a pattern-matcher: it only works because a polynomial forcing has
a polynomial y_p, an exponential has an exponential, and so on — the
derivative keeps you inside a small, closed family. But
\dfrac{d}{dx}\sec x = \sec x \tan x, and differentiating again
spawns \sec^3 x: the family never closes, so there is no finite
trial form to write down. Variation of parameters sidesteps the whole question — it does not
care what family g belongs to, because it never differentiates
g. It integrates it. That is why it is the general method
and undetermined coefficients is the shortcut.
Worked example 1: y'' + y = \sec x
Here g(x) = \sec x is nowhere on the undetermined-coefficients menu,
so variation of parameters is the only game in town.
Step 1 — homogeneous solutions. The characteristic equation
r^2 + 1 = 0 gives r = \pm i, so
y_1 = \cos x, \qquad y_2 = \sin x.
Step 2 — the Wronskian.
W = y_1 y_2' - y_2 y_1' = \cos x\cos x - \sin x(-\sin x) = \cos^2 x + \sin^2 x = 1.
A Wronskian of 1 — the integrals will be as clean as they get.
Step 3 — the two derivatives. With g = \sec x = 1/\cos x,
u_1' = \frac{-y_2\,g}{W} = -\sin x \cdot \frac{1}{\cos x} = -\tan x, \qquad u_2' = \frac{y_1\,g}{W} = \cos x \cdot \frac{1}{\cos x} = 1.
Step 4 — integrate.
u_1 = -\int \tan x\,dx = \ln|\cos x|, \qquad u_2 = \int 1\,dx = x.
(We drop the integration constants — they only re-create C_1 y_1 + C_2 y_2.)
Step 5 — assemble y_p = u_1 y_1 + u_2 y_2.
y_p = \cos x\,\ln|\cos x| + x\,\sin x.
So the general solution is
y = C_1 \cos x + C_2 \sin x + \cos x\,\ln|\cos x| + x\,\sin x.
Try producing that with a lucky guess — the \ln|\cos x| could
never come from a finite trial form.
Worked example 2: a sanity check on y'' - y = e^{x}
This forcing is on the undetermined-coefficients menu, so we can grade our machine
against a method we trust. (Watch the resonance: e^x already solves
the homogeneous equation.)
Step 1 — homogeneous solutions.
r^2 - 1 = 0 \Rightarrow r = \pm 1, so
y_1 = e^{x}, y_2 = e^{-x}.
Step 2 — Wronskian.
W = e^{x}(-e^{-x}) - e^{-x}(e^{x}) = -1 - 1 = -2.
Step 3 — derivatives with g = e^{x}:
u_1' = \frac{-y_2 g}{W} = \frac{-e^{-x}e^{x}}{-2} = \tfrac12, \qquad u_2' = \frac{y_1 g}{W} = \frac{e^{x}e^{x}}{-2} = -\tfrac12 e^{2x}.
Step 4 — integrate.
u_1 = \tfrac12 x, \qquad u_2 = -\tfrac14 e^{2x}.
Step 5 — assemble.
y_p = \tfrac12 x\,e^{x} - \tfrac14 e^{2x}\,e^{-x} = \tfrac12 x\,e^{x} - \tfrac14 e^{x}.
The -\tfrac14 e^{x} is just a multiple of
y_1 — absorb it into C_1 — leaving the
essential particular solution y_p = \tfrac12 x\,e^{x}. That is exactly
the x\,e^{x} resonance form undetermined coefficients would force by
hand. The two methods agree, and variation of parameters found the
x-factor on its own.
Three traps sink most attempts:
-
Standard form first. The formulas assume the coefficient of
y'' is 1. For
3y'' + \dots = h(x) you must divide through, so the
g in u_i' = \pm y_j g / W is
h(x)/3, not h(x). Read
g off the standardised equation.
-
Wronskian of the homogeneous solutions.
W = y_1 y_2' - y_2 y_1' uses
y_1, y_2 — the solutions of the homogeneous equation, not
anything involving g.
-
Don't forget the imposed condition. The whole derivation rests on choosing
u_1' y_1 + u_2' y_2 = 0. Skip it and you have one equation for two
unknowns and the second-derivative terms never cancel — the tidy formulas simply do not
follow.
See the answer take shape
This is the full solution of y'' + y = \sec x on
(-\tfrac{\pi}{2}, \tfrac{\pi}{2}), where
\cos x > 0. The faint curve is the particular part
y_p = \cos x\,\ln(\cos x) + x\sin x alone; the bold curve is the
general solution y = C_1\cos x + C_2\sin x + y_p. Slide
C_1 and C_2 — the homogeneous constants
slide the answer around, while the particular part carries the response to the forcing. Notice
y_p diving toward -\infty near the edges:
that is \ln(\cos x) as \cos x \to 0.