> # A nonhomogeneous 2nd order ODE with constant coefficients is # solved from beginning to end using the Method of Undetermined # Coefficients. -------------------------------------------------------------------------------- # # Art Belmonte # Thu, 15/Feb/96 # Math 308-509 (Worksheet B) # Text, Sections 3.6, 4.3: Another problem involving the Method of # Undetermined Coefficients. # # The LZ procedure provides a short cut to construct linear DEs with # the auxillary equation. # > 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);\ #d:=convert(L(y)(x)=0, diff);\ [eval(L), eval(Z)]\ end;\ protect(LZ): -------------------------------------------------------------------------------- # Ex 1-0 (M-103/2): Solution to 2nd order linear nonhomogenous # IVP; setup. > unassign('y'); setup:=LZ([1, 4, 5]);\ L:=setup[1]; Z:=setup[2];\ homog_deq:=convert(L(y)(x)=0, diff);\ nonhomog_deq:=convert(L(y)(x)=60*exp(-2*x)*sin(x), diff); -------------------------------------------------------------------------------- # Ex 1-1: Find general solution, yc, of the corresponding # homogeneous problem. > rt:=solve(Z(r)=0, r);\ yc:=unapply(c1*exp(-2*x)*cos(x)+c2*exp(-2*x)*sin(x), x);\ check:=simplify(subs(y(x)=yc(x), homog_deq)); -------------------------------------------------------------------------------- # 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); -------------------------------------------------------------------------------- # Ex 1-3: Set up the subproblems, one for each term in g(x). > unassign('y');\ nh1:=nonhomog_deq; -------------------------------------------------------------------------------- # 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); -------------------------------------------------------------------------------- # 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));\ sol:=solve(identity(", x), {a, b});\ yp1:=unapply(subs(sol, yp1(x)), 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);\ check:=simplify(nonhomog_deq); -------------------------------------------------------------------------------- # "Victory at sea..." >