Why is my verse so barren of new pride,
        So far from variation or quick change?
        Why, with the time, do I not glance aside
        To new-found methods and to compounds strange?
  Shakespeare, Sonnet 76

Variation of Parameters

Steve Dunbar

Department of Mathematics and Statistics
University of Nebraska-Lincoln
Lincoln, NE 68588-0323
sdunbar@mathlab01.unl.edu

Math 221H, Fall 1993

Covers Nagle & Saff Section 4.10

Example 1

The following is equivalent to problem 9, page 222 in Zill. 
Solve the initial value problem
	y'' + 16 y = Sin 8 t
	y(0) = 0
	y'(0) = 0

hde = y''[t] + 16 y[t] == 0

DSolve[ hde, y[t], t]

yh = y[t] /. First[First[%]]

<<Algebra/Trigonometry.m

yh = TrigCanonical[yh]

y1 = Cos[4 t]

y2 = Sin[ 4 t]

W = Det[ { { y1, y2}, {D[y1,t], D[y2,t]} } ]

W = Simplify[ W, Trig -> True]

v1 = Integrate[ -y2 * Sin[8 t]/W, t]

v2 = Integrate[ y1 * Sin[ 8 t], t]

y = yh + v1 * y1 + v2 * y2

ic1 = ( y /. t -> 0) == 0

ic2 = (D[y, t] /. t -> 0) == 0

Solve[ {ic1, ic2}, {C[1], C[2]}]

y = y /. %

y = First[y]

Clear[y,t, yh, y1,y2]

Example 2

Here is a more interesting example. 
9 y'' -  6 y' +  y = ( t et) 1/3

Clear[y,t, yh, y1,y2]

DSolve[ 9 y''[t] - 6 y'[t] +  y[t] == 0, y[t], t]

yh = Expand[ y[t] /. First[First[%]]]

y1 = Exp[t/3]

y2 = t Exp[t/3]

W = Det[ { { y1, y2}, {D[y1,t], D[y2,t]} } ]

g = (t Exp[t])^(1/3)/9

v1 = Integrate[ -y2 * g/W, t]

v2 = Integrate[ y1 * g/W,t]

yp = v1 * y1 + v2 * y2

Simplify[ 9*D[yp, {t,2}] - 6* D[yp, t] + yp]

Example 3

Clear[y,t, yh, y1,y2, v1, v2]

DSolve[ y''[t] +  y[t] == 0, y[t], t]

yh = y[t] /. First[First[%]]

y1 = Cos[t]

y2 = Sin[t]

W = Det[ { { y1, y2}, {D[y1,t], D[y2,t]} } ]

W = Simplify[ W, Trig -> True]

g = 1/t

v1 = Integrate[ -y2 * g/W, t]

v2 = Integrate[ y1 * g/W,t]

y = yh + v1*y1 + v2*y2

ic1 = ( y /. t -> 1) == 0

ic2 = (D[y, t] /. t -> 1) == 0

Solve[ {ic1, ic2}, {C[1], C[2]}]

N[%]

y =y/. %

Plot[ y, {t,1, 30}]

Exercise

(Nagel and Saff, page 191, # 35)  Find the  solution of 

	y'' + y = sec(x),   y(0) = 1, y'(0) = 0

Note:  the Mathemtica name for the secant function is   Sec[x].