4.6.15Ordinary Differential Equations

Non-homogeneous — variation of parameters

1,962 words9 min readdifficulty · medium

Setting up the derivation (from scratch)

HOW we pin down two unknown functions: we have one equation (the ODE) but two unknowns. So we are free to impose one extra condition of our choosing. We choose it to make the algebra collapse.

Differentiate once: yp=u1y1+u2y2+(u1y1+u2y2)set=0y_p' = u_1 y_1' + u_2 y_2' + \underbrace{(u_1' y_1 + u_2' y_2)}_{\text{set} = 0}

So Condition 1:   u1y1+u2y2=0\;u_1' y_1 + u_2' y_2 = 0.

Now yp=u1y1+u2y2y_p' = u_1 y_1' + u_2 y_2'. Differentiate again: yp=u1y1+u2y2+u1y1+u2y2y_p'' = u_1 y_1'' + u_2 y_2'' + u_1' y_1' + u_2' y_2'

Plug yp,yp,ypy_p, y_p', y_p'' into y+py+qy=gy'' + p y' + q y = g: (u1y1+u2y2+u1y1+u2y2)+p(u1y1+u2y2)+q(u1y1+u2y2)=g\big(u_1 y_1'' + u_2 y_2''+ u_1'y_1' + 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 by u1u_1 and u2u_2: u1(y1+py1+qy1)=0+u2(y2+py2+qy2)=0+(u1y1+u2y2)=gu_1\underbrace{(y_1'' + p y_1' + q y_1)}_{=0} + u_2\underbrace{(y_2'' + p y_2' + q y_2)}_{=0} + (u_1'y_1' + u_2'y_2') = g

The two bracketed terms vanish because y1,y2y_1,y_2 solve the homogeneous equation — that's the whole point. Left with Condition 2:   u1y1+u2y2=g\;u_1' y_1' + u_2' y_2' = g.

Solve by Cramer's rule. The determinant of the matrix is the Wronskian: W=y1y2y1y2=y1y2y2y1W = \begin{vmatrix} y_1 & y_2 \\ y_1' & y_2'\end{vmatrix} = y_1 y_2' - y_2 y_1'

Figure — Non-homogeneous — variation of parameters

Worked example 1 — secx\sec x (impossible for undetermined coeff.)

Solve y+y=secxy'' + y = \sec x.

Step 1 — homogeneous solutions. r2+1=0r=±ir^2+1=0 \Rightarrow r=\pm i, so y1=cosx, y2=sinxy_1=\cos x,\ y_2=\sin x. Why this step? We always need the homogeneous solutions first — they are the raw material ypy_p is built from.

Step 2 — Wronskian. W=cosxcosxsinx(sinx)=cos2x+sin2x=1W = \cos x\cdot\cos x - \sin x\cdot(-\sin x) = \cos^2 x+\sin^2 x = 1. Why? WW appears in the denominator; a clean W=1W=1 simplifies the integrals.

Step 3 — u1,u2u_1', u_2'. With g=secxg=\sec x: u1=sinxsecx1=tanx,u2=cosxsecx1=1u_1' = -\frac{\sin x\sec x}{1} = -\tan x,\qquad u_2' = \frac{\cos x\sec x}{1} = 1

Step 4 — integrate. u1=tanxdx=lncosx,u2=1dx=xu_1 = -\int\tan x\,dx = \ln|\cos x|, \qquad u_2 = \int 1\,dx = x Why drop the +C+C? The constants just regenerate the homogeneous part; we only need one particular solution.

Step 5 — assemble. yp=cosxlncosx+xsinxy_p = \cos x\,\ln|\cos x| + x\sin x General solution: y=c1cosx+c2sinx+cosxlncosx+xsinxy = c_1\cos x + c_2\sin x + \cos x\ln|\cos x| + x\sin x.


Worked example 2 — exponential RHS, W1W\neq1

Solve y3y+2y=exy'' - 3y' + 2y = e^{x}.

Step 1. r23r+2=(r1)(r2)=0y1=ex, y2=e2xr^2-3r+2=(r-1)(r-2)=0\Rightarrow y_1=e^{x},\ y_2=e^{2x}.

Step 2 — Wronskian. W=exe2xex2e2x=ex2e2xe2xex=e3xW = \begin{vmatrix} e^x & e^{2x}\\ e^x & 2e^{2x}\end{vmatrix} = e^x\cdot 2e^{2x} - e^{2x}\cdot e^x = e^{3x}

Step 3. g=exg=e^x: u1=e2xexe3x=1,u2=exexe3x=exu_1' = -\frac{e^{2x}e^x}{e^{3x}} = -1,\qquad u_2' = \frac{e^x e^x}{e^{3x}} = e^{-x}

Step 4. u1=x,u2=exu_1 = -x,\quad u_2 = -e^{-x}.

Step 5. yp=ex(x)+e2x(ex)=xexexy_p = e^x(-x) + e^{2x}(-e^{-x}) = -x e^x - e^x The ex-e^x is a homogeneous piece (absorb into c1c_1), so essentially yp=xexy_p = -xe^x. General: y=c1ex+c2e2xxexy = c_1 e^x + c_2 e^{2x} - x e^{x}. (Matches undetermined coefficients — good sanity check.)


Worked example 3 — non-constant coefficients

Solve x2y2xy+2y=x3x^2 y'' - 2x y' + 2y = x^3, given y1=x, y2=x2y_1=x,\ y_2=x^2 solve the homogeneous part.

Step 0 — standard form! Divide by x2x^2:   y2xy+2x2y=x\;y'' - \tfrac{2}{x}y' + \tfrac{2}{x^2}y = x. So g=xg=x (NOT x3x^3). Why this step? The formula assumes leading coefficient 11. Forgetting this is the #1 error.

Step 2 — Wronskian. W=x2xx21=2x2x2=x2W = x\cdot 2x - x^2\cdot 1 = 2x^2 - x^2 = x^2.

Step 3. u1=x2xx2=x,u2=xxx2=1u_1' = -\frac{x^2\cdot x}{x^2} = -x,\qquad u_2' = \frac{x\cdot x}{x^2} = 1

Step 4. u1=x22,u2=xu_1 = -\tfrac{x^2}{2},\quad u_2 = x.

Step 5. yp=x(x22)+x2(x)=x32+x3=x32.y_p = x(-\tfrac{x^2}{2}) + x^2(x) = -\tfrac{x^3}{2} + x^3 = \tfrac{x^3}{2}. General: y=c1x+c2x2+x32y = c_1 x + c_2 x^2 + \tfrac{x^3}{2}.


Recall Feynman: explain it to a 12-year-old

You already have two "building-block" wiggles that perfectly balance a seesaw when nobody pushes it. Now someone is pushing the seesaw (that's g(x)g(x)). Instead of inventing brand-new wiggles, you take your two building blocks and let their strengths change over time — sometimes use more of block 1, sometimes more of block 2 — exactly enough to cancel the pusher. The two little equations tell you, moment by moment, how much of each block to mix. The Wronskian is just a "fairness scale" making sure the two blocks are genuinely different and not secretly the same.


Flashcards

What ansatz defines variation of parameters?
yp=u1(x)y1(x)+u2(x)y2(x)y_p = u_1(x)y_1(x) + u_2(x)y_2(x), where y1,y2y_1,y_2 solve the homogeneous equation and u1,u2u_1,u_2 are functions to find.
What is the convenient extra condition imposed, and why?
u1y1+u2y2=0u_1'y_1 + u_2'y_2 = 0; it prevents second derivatives of the unknowns from appearing, keeping the system first-order.
State the two simultaneous equations for u1,u2u_1',u_2'.
u1y1+u2y2=0u_1'y_1+u_2'y_2=0 and u1y1+u2y2=g(x)u_1'y_1'+u_2'y_2'=g(x).
Define the Wronskian WW of y1,y2y_1,y_2.
W=y1y2y2y1W = y_1 y_2' - y_2 y_1'.
Give u1u_1' and u2u_2' from Cramer's rule.
u1=y2g/Wu_1' = -y_2 g / W, u2=+y1g/Wu_2' = +y_1 g / W.
What must you do before reading off g(x)g(x)?
Put the ODE in standard form (leading coefficient 1) by dividing through; gg is then the RHS.
Why does variation of parameters beat undetermined coefficients?
It works for ANY continuous gg (e.g. secx\sec x, lnx\ln x, 1/x1/x), not just polynomial/exp/sin/cos forms.
For y+y=secxy''+y=\sec x, what is WW and ypy_p?
W=1W=1; yp=cosxlncosx+xsinxy_p=\cos x\ln|\cos x| + x\sin x.
Why can we drop the integration constants in u1,u2u_1,u_2?
They only reproduce the complementary function c1y1+c2y2c_1y_1+c_2y_2; we need just one particular solution.

Connections

  • Wronskian — measures linear independence; non-zero WW guarantees the method works.
  • Method of Undetermined Coefficients — faster but limited to special g(x)g(x); VoP is the general tool.
  • Second-order linear homogeneous ODE — supplies y1,y2y_1,y_2, the prerequisite.
  • Cramer's Rule — solves the 2×22\times2 system for u1,u2u_1',u_2'.
  • Green's function — VoP integral is exactly the Green's-function representation of the solution.
  • Reduction of Order — alternative when only one y1y_1 is known.

Concept Map

general soln

vary constants

two unknowns one ODE

choose to kill bracket

plug into ODE

homogeneous terms vanish

solve by Cramer

gives u1' and u2'

works for any g

requires

Homogeneous solutions y1 y2

c1 y1 plus c2 y2

Ansatz yp equals u1 y1 plus u2 y2

Freedom for extra condition

Condition 1: u1' y1 plus u2' y2 equals 0

Substitute yp yp' yp''

Condition 2: u1' y1' plus u2' y2' equals g

Two simultaneous equations

Wronskian W equals y1 y2' minus y2 y1'

Formula for yp with integrals

More general than undetermined coefficients

Standard form leading coeff 1

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, idea bilkul simple hai. Homogeneous equation y+py+qy=0y''+py'+qy=0 ke do independent solutions y1y_1 aur y2y_2 already mil chuke hote hain, aur general solution hota hai c1y1+c2y2c_1y_1+c_2y_2 jisme c1,c2c_1,c_2 constants hain. Ab jab right side pe g(x)g(x) aa jata hai (non-homogeneous), toh hum ek chhota sa jugaad karte hain — constants ko functions bana dete hain: c1u1(x)c_1\to u_1(x), c2u2(x)c_2\to u_2(x). Isi liye naam hai "variation of parameters" — parameters (constants) ko vary kar rahe hain.

Do unknown functions hain par equation ek hi hai, toh humein freedom milti hai ek extra condition apni marzi se lagane ki. Hum chunte hain u1y1+u2y2=0u_1'y_1+u_2'y_2=0, taaki second derivatives wala mess na aaye. Phir ODE me daalne par homogeneous wale terms khud-ba-khud zero ho jaate hain (kyunki y1,y2y_1,y_2 unhe satisfy karte hain), aur bachta hai u1y1+u2y2=gu_1'y_1'+u_2'y_2'=g. Ye do equations Cramer's rule se solve karo: u1=y2g/Wu_1'=-y_2 g/W, u2=+y1g/Wu_2'=+y_1 g/W, jahan W=y1y2y2y1W=y_1y_2'-y_2y_1' Wronskian hai. Bas integrate karke u1,u2u_1,u_2 nikaalo aur yp=u1y1+u2y2y_p=u_1y_1+u_2y_2 likh do.

Important baat: equation ko pehle standard form me lao (leading coefficient 1), tabhi gg sahi milega — warna sabse common galti yahi hoti hai. Ye method ki sabse badi taakat ye hai ki ye kisi bhi g(x)g(x) ke liye chalti hai — secx\sec x, lnx\ln x, 1/x1/x sab — jabki undetermined coefficients sirf polynomial, exponential, sin/cos pe kaam karti hai. Toh jab guessing fail ho jaye, variation of parameters tumhara pakka hathiyar hai.

Go deeper — visual, from zero

Test yourself — Ordinary Differential Equations

Connections