Variation of parameters

Undetermined coefficients is a good trick as long as the right-hand side of a linear ODE looks like something you could have guessed — a polynomial, an exponential, a sine. The moment the forcing term is sec⁡x\sec x, tan⁡x\tan x, ln⁡x\ln x, or 1/x1/x, the guess-a-trial-form method has nothing to guess. Variation of parameters is the fallback that never runs out of road: instead of guessing a particular integral, it promotes the two arbitrary constants of the complementary function into unknown functions of xx, then pins those functions down by direct substitution into the ODE. It works for any continuous right-hand side and even for equations with variable coefficients, provided the complementary function is already known. This article builds the method from the standard-form ODE up to a fully solved trigonometric example, the natural next step after mastering undetermined coefficients.

The core insight

Replacing the constants C1,C2C_1, C_2 in the complementary function yc=C1y1+C2y2y_c = C_1y_1+C_2y_2 by unknown functions u1(x),u2(x)u_1(x), u_2(x), and imposing one convenient auxiliary condition, converts the ODE into a solvable linear system for u1′u_1' and u2′u_2' — giving a particular integral for any right-hand side R(x)R(x), not just standard trial forms.

The core idea

Where it fits. Variation of parameters is presented in the MA10001 ODE unit as the general-purpose alternative to undetermined coefficients: reach for it when R(x)R(x) is not polynomial, exponential, or sinusoidal, or when the ODE has non-constant coefficients. It leans entirely on the complementary function already found from the auxiliary-equation method, so that earlier topic is a hard prerequisite here.

The setup. Write the ODE in standard form, leading coefficient equal to one:

y′′+P(x)y′+Q(x)y=R(x),y'' + P(x)y' + Q(x)y = R(x),

where: P(x),Q(x)P(x), Q(x) are the coefficient functions and R(x)R(x) is the forcing term after dividing through by whatever multiplied y′′y'' originally. Suppose the complementary function is already known,

yc=C1y1(x)+C2y2(x),y_c = C_1y_1(x) + C_2y_2(x),

where: y1,y2y_1, y_2 are two linearly independent solutions of the homogeneous equation y′′+Py′+Qy=0y'' + Py' + Qy = 0. The method looks for a particular integral of the same shape but with the constants promoted to unknown functions,

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

Two unknown functions need two equations. One comes from substituting ypy_p into the ODE; the other is a free choice — imposed purely to keep the algebra from spiralling into second derivatives of u1,u2u_1, u_2. The standard choice is u1′y1+u2′y2=0u_1'y_1 + u_2'y_2 = 0. Together with the equation the ODE forces, this yields the pair

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

The picture below shows the shift in strategy this represents: undetermined coefficients hands you a fixed trial shape to match against R(x)R(x); variation of parameters instead lets the "constants" of the complementary function flex into functions, solved for by the system above.

Figure
A comparison diagram showing undetermined coefficients matching a fixed trial form against R of x on one side, and variation of parameters promoting constants C1 C2 into functions u1 of x u2 of x solved from a linear system on the other side
Two routes to a particular integral Undetermined coefficients R(x) is polynomial, exp, sin/cos guess a trial y_p with unknown constant coefficients match coefficients term by term fails for sec x, tan x, ln x, 1/x Variation of parameters R(x) can be anything continuous promote C1, C2 to u1(x), u2(x) solve the 2x2 system with the Wronskian, then integrate works for any R(x)

Solving the 2×22\times2 system by Cramer's rule, using the Wronskian W=y1y2′−y2y1′W = y_1y_2' - y_2y_1' as the determinant, gives closed forms for the two derivatives:

u1′=−y2 R(x)W,u2′=y1 R(x)W.u_1' = \frac{-y_2\,R(x)}{W}, \qquad u_2' = \frac{y_1\,R(x)}{W}.

Integrating each gives u1(x)u_1(x) and u2(x)u_2(x); the particular integral is then yp=u1y1+u2y2y_p = u_1y_1 + u_2y_2, and the general solution is y=yc+ypy = y_c + y_p, exactly as with undetermined coefficients. Nothing here required R(x)R(x) to have any particular shape — that is the entire point of the method.

Derivation ASolving for u1 prime and u2 prime by variation of parameters

The goal of this derivation is to justify, from the two simultaneous equations above, the specific formulas u1′=−y2R/Wu_1' = -y_2R/W and u2′=y1R/Wu_2' = y_1R/W that let a student read off both derivatives directly once the complementary function and R(x)R(x) are known, rather than re-deriving the linear-algebra step from scratch on every problem.

Step 1. Start from the pair of equations obtained by substituting yp=u1y1+u2y2y_p = u_1y_1+u_2y_2 into the ODE and imposing the auxiliary condition:

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

Treat u1′u_1' and u2′u_2' as the two unknowns of a linear system, with y1,y2,y1′,y2′,R(x)y_1, y_2, y_1', y_2', R(x) all known functions of xx at this stage.

Step 2. Write the system in matrix form to expose its determinant:

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

The determinant of the coefficient matrix is precisely the Wronskian, W=y1y2′−y2y1′W = y_1y_2' - y_2y_1'. Because y1,y2y_1, y_2 are linearly independent solutions of the homogeneous equation, W≠0W \neq 0 everywhere on the interval of interest, so the system has a unique solution — this is exactly why the method never gets stuck.

Step 3. Apply Cramer's rule for u1′u_1': replace the first column of the coefficient matrix with the right-hand side column and divide by WW.

u1′=∣0y2R(x)y2′∣W=0⋅y2′−y2⋅R(x)W=−y2R(x)W.u_1' = \frac{\begin{vmatrix} 0 & y_2 \\ R(x) & y_2' \end{vmatrix}}{W} = \frac{0\cdot y_2' - y_2\cdot R(x)}{W} = \frac{-y_2R(x)}{W}.

Step 4. Apply Cramer's rule for u2′u_2': replace the second column instead.

u2′=∣y10y1′R(x)∣W=y1⋅R(x)−0⋅y1′W=y1R(x)W.u_2' = \frac{\begin{vmatrix} y_1 & 0 \\ y_1' & R(x) \end{vmatrix}}{W} = \frac{y_1\cdot R(x) - 0\cdot y_1'}{W} = \frac{y_1R(x)}{W}.

Step 5. Both formulas are now purely in terms of the known complementary-function pair y1,y2y_1, y_2, their derivatives, the Wronskian WW, and R(x)R(x). Integrating u1′u_1' and u2′u_2' with respect to xx (dropping the constants of integration, since they only reproduce the C1,C2C_1, C_2 already present in ycy_c) gives u1(x)u_1(x) and u2(x)u_2(x), and yp=u1y1+u2y2y_p = u_1y_1+u_2y_2 follows immediately.

Worked example

Problem. Solve y′′+y=sec⁡xy'' + y = \sec x using variation of parameters.

Step 1. Find the complementary function. The auxiliary equation is m2+1=0  ⟹  m=±im^2+1=0 \implies m = \pm i, giving y1=cos⁡xy_1 = \cos x, y2=sin⁡xy_2 = \sin x, and yc=C1cos⁡x+C2sin⁡xy_c = C_1\cos x + C_2\sin x. Undetermined coefficients cannot be used here since sec⁡x\sec x is not a standard trial type — this is exactly the signal to reach for variation of parameters.

Step 2. Compute the Wronskian: W=y1y2′−y2y1′=cos⁡x(cos⁡x)−sin⁡x(−sin⁡x)=cos⁡2x+sin⁡2x=1W = y_1y_2' - y_2y_1' = \cos x(\cos x) - \sin x(-\sin x) = \cos^2x+\sin^2x = 1.

Step 3. Compute u1′u_1' and u2′u_2' using the boxed formulas, with R(x)=sec⁡xR(x)=\sec x: u1′=−y2R/W=−sin⁡xsec⁡x=−tan⁡xu_1' = -y_2R/W = -\sin x\sec x = -\tan x, and u2′=y1R/W=cos⁡xsec⁡x=1u_2' = y_1R/W = \cos x\sec x = 1.

Step 4. Integrate: u1=∫−tan⁡x dx=ln⁡∣cos⁡x∣u_1 = \int -\tan x\,dx = \ln|\cos x|, and u2=∫1 dx=xu_2 = \int 1\,dx = x.

Step 5. Assemble the particular integral: yp=u1y1+u2y2=cos⁡xln⁡∣cos⁡x∣+xsin⁡xy_p = u_1y_1+u_2y_2 = \cos x\ln|\cos x| + x\sin x.

Step 6. State the general solution: y=C1cos⁡x+C2sin⁡x+cos⁡xln⁡∣cos⁡x∣+xsin⁡x\boxed{y = C_1\cos x + C_2\sin x + \cos x\ln|\cos x| + x\sin x}.

Competitive stretch

The same machine handles repeated roots and non-trigonometric R(x)R(x) together. For y′′−2y′+y=ex/xy''-2y'+y = e^x/x (x>0x>0), the auxiliary equation (m−1)2=0(m-1)^2=0 gives the repeated-root complementary function y1=exy_1=e^x, y2=xexy_2=xe^x, with Wronskian W=ex(ex+xex)−xex(ex)=e2xW = e^x(e^x+xe^x)-xe^x(e^x) = e^{2x}. Then u1′=−xex⋅(ex/x)/e2x=−1u_1' = -xe^x\cdot(e^x/x)/e^{2x} = -1 and u2′=ex⋅(ex/x)/e2x=1/xu_2' = e^x\cdot(e^x/x)/e^{2x} = 1/x, so u1=−xu_1=-x and u2=ln⁡xu_2=\ln x. That gives yp=−xex+xexln⁡x=xex(ln⁡x−1)y_p = -xe^x + xe^x\ln x = xe^x(\ln x-1), and the general solution is y=(C1+C2x)ex+xex(ln⁡x−1)\boxed{y=(C_1+C_2x)e^x + xe^x(\ln x-1)} — note the −xex-xe^x piece could be absorbed into C2xexC_2xe^x but is left explicit for clarity of derivation.

Common traps

  • Skipping the auxiliary condition u1′y1+u2′y2=0u_1'y_1+u_2'y_2=0. That condition is what turns one second-order ODE into a solvable pair of first-order equations for two unknowns; omit it and the system is underdetermined.
  • Forgetting to reduce to standard form first. If the given equation is a(x)y′′+b(x)y′+c(x)y=R0(x)a(x)y''+b(x)y'+c(x)y=R_0(x) with a(x)≠1a(x)\neq1, divide through by a(x)a(x) before reading off R(x)=R0(x)/a(x)R(x)=R_0(x)/a(x) — using R0R_0 directly gives a wrong particular integral.
  • Sign slip between u1′u_1' and u2′u_2'. Remember u1′=−y2R/Wu_1'=-y_2R/W carries a minus sign while u2′=y1R/Wu_2'=y_1R/W does not; swapping the signs is the single most common arithmetic error in this method.
  • Reaching for undetermined coefficients on a non-standard R(x)R(x) such as sec⁡x\sec x, tan⁡x\tan x, ln⁡x\ln x, or 1/x1/x instead of recognising that only variation of parameters applies to these forcing terms.

Ask the tutor: if the Wronskian setup or the sign in u1′=−y2R/Wu_1'=-y_2R/W keeps tripping you up, ask the AI tutor to walk through a fresh variation-of-parameters problem with you line by line.

Why do we need the extra condition u1 prime y1 plus u2 prime y2 equals zero — where does it actually come from?

It is a free choice, not something forced by the ODE. Differentiating yp=u1y1+u2y2y_p=u_1y_1+u_2y_2 once gives terms in u1′,u2′u_1', u_2' as well as y1′,y2′y_1', y_2'; substituting a second time into the ODE would otherwise drag in second derivatives of u1,u2u_1, u_2, making the algebra much messier. Setting u1′y1+u2′y2=0u_1'y_1+u_2'y_2=0 deliberately kills those extra terms before the second differentiation, so only first derivatives of u1,u2u_1, u_2 survive. It is consistent because we still have two unknown functions and, with this condition plus the equation the ODE forces, exactly two equations to pin them down.

Can variation of parameters be used even when undetermined coefficients would also work?

Yes — variation of parameters is fully general and will reproduce the same particular integral (up to reabsorbing a constant into ycy_c) for any R(x)R(x) that undetermined coefficients can also handle, such as a polynomial or an exponential. It is simply more work: undetermined coefficients skips the Wronskian and the integration steps entirely by guessing a trial form. In practice, use undetermined coefficients whenever R(x)R(x) is a standard trial type, and switch to variation of parameters only when it is not, or when the coefficients P(x),Q(x)P(x), Q(x) are not constants.

What happens if the two solutions y1 and y2 chosen for the complementary function are not linearly independent?

Then the Wronskian W=y1y2′−y2y1′W=y_1y_2'-y_2y_1' is identically zero, and the formulas u1′=−y2R/Wu_1'=-y_2R/W, u2′=y1R/Wu_2'=y_1R/W involve division by zero — the method breaks down completely, because a single solution repeated cannot span the two-dimensional solution space of a second-order ODE. This is why the complementary function must always be built from two genuinely independent solutions (for a repeated root mm, that means emxe^{mx} and xemxxe^{mx}, not emxe^{mx} twice); a nonzero Wronskian is exactly the algebraic test for that independence.

Before this

Where this leads