# # Two 2nd order non-homogeneous ODEs are solved from beginning to end # using method of undetermined coefficients. Maple is used only to do # calculations involved in the technique. # # Dr. Kirschner, MATH 308-506, March 1. # # This is a help sheet for Undetermined coefficients. BDP (means Boyce and DiPrima) # # # BDP, p 162 #10. # # A NON_HOMOGENEOUS DE: # # > diffeq_h:=diff(u(x),x$2)+omega^2*u(x)=cos(omega*x); / 2 \ | d | 2 diffeq_h := |----- u(x)| + omega u(x) = cos(omega x) | 2 | \ dx / # # # THE FIRST STEP IS TO SOLVE THE HOMOGENEOUS PROBLEM > diffeq_h:=diff(u(x),x$2)+omega^2*u(x)=0; / 2 \ | d | 2 diffeq_h := |----- u(x)| + omega u(x) = 0 | 2 | \ dx / > char_eq:=r^2+omega^2=0; solve(",r); 2 2 char_eq := r + omega = 0 I omega, - I omega # The general solution to the homogeneous equation is # > u_h(x):=c1*cos(omega*x)+c2*sin(omega*x); u_h(x) := c1 cos(omega x) + c2 sin(omega x) # The particular solution will be a polynomial of degree zero times cos(omega*x)+a polynomial of # degree zero times sin(omega*x), all times x to avoid a conflict with the homogeneous equation. # (Notice that if you have not gotten the homogeneous solution, you cannot see collisions!) # > diffeq:=diff(u(x),x$2)+omega^2*u(x)=cos(omega*x); / 2 \ | d | 2 diffeq := |----- u(x)| + omega u(x) = cos(omega x) | 2 | \ dx / > u_p(x):=(c1*cos(omega*x)+c2*sin(omega*x))*x; u_p(x) := (c1 cos(omega x) + c2 sin(omega x)) x # Now substitute the particular solution into the nonhomogeneous equation, and treat the result as # an identity in x. (Note that this is one of the few cases in Maple where a word in the output does not # mean that Maple doesn't understand what is happening.) > subs(u(x)=u_p(x),diffeq): identity(",x); identity( 2 2 (- c1 cos(omega x) omega - c2 sin(omega x) omega ) x - 2 c1 sin(omega x) omega 2 + 2 c2 cos(omega x) omega + omega (c1 cos(omega x) + c2 sin(omega x)) x = cos(omega x), x) # # Solve for the undetermined coefficients. # > csol:=solve(",{c1,c2}); 1 csol := {c2 = -------, c1 = 0} 2 omega # Substitute the values for the coefficients into the sum of the homogeneous and particular solutions. # > sol:=u(x)=subs(csol,u_h(x)+u_p(x)); sin(omega x) sin(omega x) x sol := u(x) = 1/2 ------------ + 1/2 -------------- omega omega # Check your result. # > subs(",diffeq): expand("); cos(omega x) = cos(omega x) > omega:=Pi; sol;with(plots): plot(rhs(sol),x=0..10); omega := Pi sin(Pi x) sin(Pi x) x u(x) = 1/2 --------- + 1/2 ----------- Pi Pi > restart; # # BDP, p 162 #13. # > diffeq_h:=diff(y(x),x$2)+diff(y(x),x)-2*y(x)=0; / 2 \ | d | / d \ diffeq_h := |----- y(x)| + |---- y(x)| - 2 y(x) = 0 | 2 | \ dx / \ dx / > char_eq:=r^2+r-2=0; ev:=solve(",r); 2 char_eq := r + r - 2 = 0 ev := 1, -2 > y_h(x):=c1*exp(1*x)+c2*exp( -2*x); y_h(x) := c1 exp(x) + c2 exp(- 2 x) > diffeq:=diff(y(x),x$2)+diff(y(x),x)-2*y(x)=2*x; inits:=y(0)=0,D(y)(0)=1; / 2 \ | d | / d \ diffeq := |----- y(x)| + |---- y(x)| - 2 y(x) = 2 x | 2 | \ dx / \ dx / inits := y(0) = 0, D(y)(0) = 1 # Since the rhs is a polynomial of degree 1, the particular solution is the most general solution of # degree 1. (Note that there are no conflicts with the homogeneous solution.) # > y_p(x):=a*x+b; subs(y(x)=y_p(x),diffeq); identity(",x); y_p(x) := a x + b / 2 \ | d | / d \ |----- (a x + b)| + |---- (a x + b)| - 2 a x - 2 b = 2 x | 2 | \ dx / \ dx / identity(a - 2 a x - 2 b = 2 x, x) > csol:=solve(",{a,b}); csol := {a = -1, b = -1/2} > sol:=y(x)=subs(csol,y_h(x)+y_p(x)); sol := y(x) = c1 exp(x) + c2 exp(- 2 x) - x - 1/2 # Check. # > subs(",diffeq): expand("); 2 x = 2 x # Now solve for the constants c1 and c2. # > subs(x=0,rhs(sol))=0: eq1:=simplify("); eq1 := c1 + c2 - 1/2 = 0 > subs(x=0,diff(rhs(sol),x))=1: eq2:=simplify("); eq2 := c1 - 2 c2 - 1 = 1 > csol2:=solve({eq1,eq2},{c1,c2}); csol2 := {c2 = -1/2, c1 = 1} > sol3:=subs(csol2,sol); sol3 := y(x) = exp(x) - 1/2 exp(- 2 x) - x - 1/2 # PLotting. # > plot(rhs(sol3), x=0..10); # VERIFYING: > subs(x=0,rhs(sol3)): simplify("); 0 > subs(x=0,diff(rhs(sol3),x)): simplify("); 1 > subs(sol3,diffeq): expand("); 2 x = 2 x > >