# # A second order DE is completely solved and checked using Variation of Parameters. # # Art Belmonte # Mon, 27/May/96 # Math 308-509 [Maple V Release 4] (Worksheet A) # Sections 3.7, 4.4: The Method of Variation of Parameters # # ("The government taught me, and they taught me well..." # --- The Smuggler's Blues) [P.S.: Thanks, Maury!] # # T-169/13a: # # x^2 y'' - 2 y = 3 x^2 - 1 # # 0. Make sure the DE is in standard form (coefficient of highest order # derivative must be 1). # # 1. If necessary, construct a fundamental set of solutions {y1, ..., # yn} to the corresponding homogeneous differential equation. (The # problem statement may simply give you this, as in our current # problem.) > with(linalg): > unassign('y'); proviso:=x > 0; proviso := 0 < x > h_deq:={diff(y(x), x$2) - 2/x^2*y(x) = 0}; / 2 \ |d | y(x) h_deq := {|--- y(x)| - 2 ---- = 0} | 2 | 2 \dx / x > n_deq:={diff(y(x), x$2) - 2/x^2*y(x) = 3 - 1/x^2}; / 2 \ |d | y(x) 1 n_deq := {|--- y(x)| - 2 ---- = 3 - ----} | 2 | 2 2 \dx / x x > y1:=x->x^2; y2:=x->1/x; 2 y1 := x -> x y2 := x -> 1/x # T-169/13b: # # 2. Next, verify that the functions y1, ..., yn are linearly # independent solutions to the corresponding homogeneous differential # equation. To do this, show that: # # a. They each give an identity when substituted into the homogeneous # DE. Also collect the functional EXPRESSIONS into a list [y1, ..., yn] # and label it hsols. # # b. Their Wronskian determinant is nonzero (here on x > 0, the proviso # stated in this particular problem). Maple's linalg routine Wronskian # produces the Wronskian matrix (which we'll also need and hence will # label WW since W is reserved--Lambert's omega function), then hitting # it with the linalg routine det produces the determinant `o` Wronski. > y1_satisfies_h_deq:=simplify(subs(y(x)=y1(x), h_deq)); y1_satisfies_h_deq := {0 = 0} > y2_satisfies_h_deq:=simplify(subs(y(x)=y2(x), h_deq)); y2_satisfies_h_deq := {0 = 0} > hsols:=[y1(x), y2(x)]; 2 hsols := [x , 1/x] > WW:=Wronskian(hsols, x); WW_det:=det(WW); [ 2 ] [x 1/x ] [ ] WW := [ 1 ] [2 x - ----] [ 2 ] [ x ] WW_det := -3 > # T-169/13c: # # 3. Form the n x 1 column matrix G, each of whose entries is zero # EXCEPT the last one, which is the functional expression corresponding # to g, the function on the RHS of the nonhomogeneous DE. > G:=matrix(2, 1, [0, 3 - 1/x^2]); [ 0 ] [ ] G := [ 1 ] [3 - ----] [ 2 ] [ x ] # T-169/13d: # # 4. Solve the matrix equation (WW)(uprimes) = G for uprimes, then # integrate each component of the result via the map command. ("Why do # them one at a time, when you can do them ALL at once?!") Convert the # result to a vector, then to a list, naming the result u (since you # integrated u' to obtain it!). > uprimes:=linsolve(WW, G); map(int, uprimes, x); [ 2 ] [ 3 x - 1] [1/3 --------] uprimes := [ 3 ] [ x ] [ ] [ 2 ] [ -x + 1/3 ] [ 1 ] [ln(x) + 1/6 ----] [ 2 ] [ x ] [ ] [ 3 ] [- 1/3 x + 1/3 x] > convert(", vector); u:=convert(", list); [ 1 3 ] [ln(x) + 1/6 ----, - 1/3 x + 1/3 x] [ 2 ] [ x ] 1 3 u := [ln(x) + 1/6 ----, - 1/3 x + 1/3 x] 2 x # T-169/13e: # # 5. To obtain a particular solution yp to the nonhomogeneous DE, take # the dot product of u and hsols. Simplify to taste... > dotprod(u, hsols); yp:=simplify("); 3 2 - 1/3 x + 1/3 x ln(x) x + 1/6 + ---------------- x 2 2 yp := ln(x) x + 1/2 - 1/3 x # T-169/13f: # # 6. Finally, obtain the general solution y to the nonhomogeneous DE by # adding the particular solution yp to the general solution yc of the # homogeneous DE, collecting like terms and renaming constants as # necessary. A check shows that we have indeed produced the general # solution! > dotprod([c1, c2], hsols) + yp; 2 c2 2 2 c1 x + ---- + ln(x) x + 1/2 - 1/3 x x > y:=unapply(k1*x^2 + k2/x + 1/2 + x^2*ln(x), x); 2 k2 2 y := x -> k1 x + ---- + 1/2 + ln(x) x x > check:=simplify(n_deq); 2 2 3 x - 1 3 x - 1 check := {-------- = --------} 2 2 x x # VICTORY!!! >