# A nonhomogeneous 2nd order ODE with constant coefficients is solved # from # beginning to end using the Method of Undetermined Coefficients. # # Art Belmonte # Mon, 27/May/96 # Math 308-509 [Maple V Release 4] (Worksheet B) # Text, Sections 3.6, 4.3: Another problem involving the Method of # Undetermined Coefficients. # # Ex 1-0 (M-103/2): Solution to 2nd order linear nonhomogenous IVP; # setup. > > unprotect(LZ): > LZ:=proc(c) > local a, d, k, L, n, p, r, s, x, y, Z; > n:=nops(c) - 1; > a:=array(0..n, c); > p:=0; s:=0; > for k from 0 to n do > p:=p + a[k]*r^(n-k); > s:=s + a[k]*(D@@(n-k))(y) > od; > L:=unapply(s, y); > Z:=unapply(p, r); > [eval(L), eval(Z)] > end: > protect(LZ): > > unassign('y'); setup:=LZ([1, 4, 5]); (2) 2 setup := [y -> (D )(y) + 4 D(y) + 5 y, r -> y + 4 y + 5] > L:=setup[1]; Z:=setup[2]; (2) L := y -> (D )(y) + 4 D(y) + 5 y 2 Z := r -> r + 4 r + 5 > homog_deq:=convert(L(y)(x)=0, diff); / 2 \ |d | /d \ homog_deq := |--- y(x)| + 4 |-- y(x)| + 5 y(x) = 0 | 2 | \dx / \dx / > nonhomog_deq:=convert(L(y)(x)=60*exp(-2*x)*sin(x), diff); nonhomog_deq := / 2 \ |d | /d \ |--- y(x)| + 4 |-- y(x)| + 5 y(x) = 60 exp(-2 x) sin(x) | 2 | \dx / \dx / # Ex 1-1: Find general solution, yc, of the corresponding homogeneous # problem. > rt:=solve(Z(r)=0, r); rt := -2 + I, -2 - I > yc:=unapply(c1*exp(-2*x)*cos(x)+c2*exp(-2*x)*sin(x), x); yc := x -> c1 exp(-2 x) cos(x) + c2 exp(-2 x) sin(x) > check:=simplify(subs(y(x)=yc(x), homog_deq)); check := 0 = 0 # Ex 1-2: Ensure that (the terms of) g(x), the RHS in the nonhomogeneous # DE, is of the form in Table 3.6.1 (T-159) or Table 4.3.1 (T-204). # Otherwise, use the method of variation of parameters. It is in this # case, the method of undetermined coefficients is the ticket! > rhs(nonhomog_deq); 60 exp(-2 x) sin(x) # Ex 1-3: Set up the subproblems, one for each term in g(x). > unassign('y'); > nh1:=nonhomog_deq; / 2 \ |d | /d \ nh1 := |--- y(x)| + 4 |-- y(x)| + 5 y(x) = 60 exp(-2 x) sin(x) | 2 | \dx / \dx / # Ex 1-4: For each subproblem, assume the form of the particular # solution to the corresponding nonhomogeneous subproblems. Looking at # the Notes beneath Table 3.6.1, we see that s = 1 = #times alpha+beta*I # = -2+1*I is a root of the characteristic equation Z(r)=0. > yp1:=unapply( x* ( a*(exp(-2*x)*cos(x)) > + b*(exp(-2*x)*sin(x))), x); yp1 := x -> x (a exp(-2 x) cos(x) + b exp(-2 x) sin(x)) # Ex 1-5: Find the particular solution to each subproblem. Then sum them # to form a particular solution to the full nonhomogeneous problem. # (HELLO! -> THIS IS THE NEW IDENTITY CONSTRUCT THAT TOM KIFFE # INTRODUCED IN CHAPTER 6 OF _SOLVING ODES WITH MAPLE V_; MUCH SLICKER # THAN THE OLD WAY!) > simplify(subs(y(x)=yp1(x), nh1)); -2 a exp(-2 x) sin(x) + 2 b exp(-2 x) cos(x) = 60 exp(-2 x) sin(x) > sol:=solve(identity(", x), {a, b}); sol := {b = 0, a = -30} > yp1:=unapply(subs(sol, yp1(x)), x); yp1 := x -> -30 x exp(-2 x) cos(x) # Ex 1-6: Finally, obtain the general solution to the full # nonhomogeneous problem by adding the general solution to the # homogeneous problem and the particular solution to the full # nonhomogeneous problem. > y:=unapply(yc(x)+yp1(x), x); y := x -> c1 exp(-2 x) cos(x) + c2 exp(-2 x) sin(x) - 30 x exp(-2 x) cos(x) > check:=simplify(nonhomog_deq); check := 60 exp(-2 x) sin(x) = 60 exp(-2 x) sin(x) # "Victory at sea..." >