Why undetermined coefficients fails here
The right side g(x)=secx has derivatives that generate ever more complicated expressions:
dxdsecx=secxtanx,dx2d2secx=secx(sec2x+tan2x),…
Unlike polynomials, exponentials, and trig functions, the successive derivatives of secx don't close into a finite-dimensional span. No finite guess works. Undetermined coefficients is out; we need a more general method.
What variation of parameters does
Starting from the homogeneous solution yh=C1y1+C2y2, the idea is to replace the constants C1,C2 with unknown functions u1(x),u2(x):
yp(x)=u1(x)y1(x)+u2(x)y2(x).
We then pick the ui to satisfy the full non-homogeneous ODE, plus one convenient extra constraint that keeps the algebra tidy.
For the ODE in standard form y′′+p(x)y′+q(x)y=g(x), the ui must satisfy:
u1′y1+u2′y2=0
u1′y1′+u2′y2′=g(x)
This is a 2x2 linear system in u1′,u2′. Its determinant is the Wronskian W(y1,y2)=y1y2′−y2y1′ (see #195). Cramer's rule gives
u1′=−Wy2g,u2′=Wy1g.
Then integrate to get u1,u2 — and yp=u1y1+u2y2.
Step-by-step solution
Step 1 — Standard form
y′′+y=secx.
Already standard; p(x)=0, q(x)=1, g(x)=secx.
Step 2 — Homogeneous solution
r2+1=0⟹r=±i, so y1=cosx, y2=sinx.
Step 3 — Wronskian
W=y1y2′−y2y1′=cosx⋅cosx−sinx⋅(−sinx)=cos2x+sin2x=1.
(Clean: the Wronskian of cos and sin is 1. Good omen.)
Step 4 — Compute u1′ and u2′
u1′=−Wy2g=−1sinx⋅secx=−cosxsinx=−tanx
u2′=Wy1g=1cosx⋅secx=1
Step 5 — Integrate
u1=∫−tanxdx=ln∣cosx∣+C3
u2=∫1dx=x+C4
The constants of integration C3,C4 only contribute multiples of y1,y2 respectively — they get absorbed into yh. Drop them: take u1=ln∣cosx∣ and u2=x.
Step 6 — Assemble yp and general solution
yp=u1y1+u2y2=cosx⋅ln∣cosx∣+xsinx.
General solution:
y(x)=C1cosx+C2sinx+cosxln∣cosx∣+xsinx
Verification
Differentiate yp=cosxln∣cosx∣+xsinx:
yp′=−sinxln∣cosx∣+cosx⋅cosx−sinx+sinx+xcosx
=−sinxln∣cosx∣−sinx+sinx+xcosx=−sinxln∣cosx∣+xcosx
yp′′=−cosxln∣cosx∣−sinx⋅cosx−sinx+cosx−xsinx
=−cosxln∣cosx∣+cosxsin2x+cosx−xsinx
=−cosxln∣cosx∣+cosxsin2x+cos2x−xsinx
=−cosxln∣cosx∣+secx−xsinx
Add yp:
yp′′+yp=(−cosxln∣cosx∣+secx−xsinx)+(cosxln∣cosx∣+xsinx)=secx✓
Why the "extra constraint" u1′y1+u2′y2=0?
When you compute yp′ using the product rule:
yp′=u1′y1+u1y1′+u2′y2+u2y2′=(u1′y1+u2′y2)+(u1y1′+u2y2′).
Setting the first parenthetical to zero forces yp′ into the cleaner form u1y1′+u2y2′, which makes yp′′ manageable. Without this constraint, yp′′ would involve u1′′ and u2′′, creating a mess. It's not a sacrifice — the constraint reduces two unknowns (u1,u2) to satisfying just two conditions, which is exactly right.
Advantages over undetermined coefficients
- Works for any g(x) (as long as you can integrate yig/W). No table of "acceptable" right-hand sides.
- No resonance issue — the method naturally handles it because ui are functions, not constants.
- Unified — one recipe regardless of what g looks like.
Downside: you have to integrate, which can be hard or intractable in closed form. For textbook g's like polynomials and exponentials, undetermined coefficients is usually faster.
General-order statement
For an n-th order linear ODE y(n)+…=g(x) with homogeneous basis {y1,…,yn}, the method generalises: solve the n×n system
ui′yi(k),k=0,…,n−1
(the Wronskian matrix is the coefficient matrix, and its determinant is W(y1,…,yn)). Cramer's rule gives each ui′ as a ratio involving modified Wronskians.
Common mistakes
- Forgetting to divide the RHS into standard form. If the leading coefficient is not 1, divide first so that g means what the formula expects.
- Dropping the absolute value in ln∣cosx∣. The domain where cosx>0 (e.g. ∣x∣<π/2) lets you skip it, but in general keep it.
- Confusing yp's integration constants with those in yh. The integration constants from u1,u2 fold into yh's constants — don't double-count.
- Computing u1′y1 instead of u1y1 in the final yp. The integrand is u1′; the thing you plug into yp is u1 (the integrated version).
Try it in the visualization
Switch g(x) between a sin (handled by undetermined coefficients) and a sec (handled only by variation of parameters). Watch the particular solution emerge from the Wronskian integral; overlay the homogeneous + particular decomposition so you can see each piece.