> > # Several Second Order differential equations are solved and checked. # An auxiliary procedure LZ is used to facilitate the solutions. -------------------------------------------------------------------------------- # # Art Belmonte # Thu, 08/Feb/96 # Lecture, introducing: # LZ: Set up for 2nd order homogeneous constant coefficient # differential equations # > 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 (S3.1, T-120/7) > unassign('y'); setup:=LZ([1, -9, 9]);\ L:=setup[1]; Z:=setup[2];\ deq:={convert(L(y)(x)=0, diff)};\ rt:=solve(Z(r)=0, r);\ y:=unapply(c1*exp(rt[1]*x) + c2*exp(rt[2]*x), x);\ check:=simplify(deq); -------------------------------------------------------------------------------- # Ex 2 (S3.1, T-120/11) > unassign('y'); setup:=LZ([6, -5, 1]);\ L:=setup[1]; Z:=setup[2];\ deq:={convert(L(y)(x)=0, diff)};\ IC:={y(0)=4, D(y)(0)=0}; IVP:=deq union IC;\ rt:=solve(Z(r)=0, r);\ y:=unapply(c1*exp(rt[1]*x) + c2*exp(rt[2]*x), x);\ eqs:=IC; sol:=solve(eqs, {c1, c2});\ y:=unapply(subs(sol, y(x)), x);\ check:=simplify(IVP); -------------------------------------------------------------------------------- # Ex 3 (S3.4, T-142/11) > unassign('y'); setup:=LZ([1, 6, 13]);\ L:=setup[1]; Z:=setup[2];\ deq:={convert(L(y)(x)=0, diff)};\ rt:=solve(Z(r)=0, r);\ y:=unapply(c1*exp(Re(rt[1])*x)*cos(Im(rt[1])*x)\ + c2*exp(Re(rt[1])*x)*sin(Im(rt[1])*x), x);\ check:=simplify(deq); -------------------------------------------------------------------------------- # Ex 4 (S3.4, T-142/18) > unassign('y'); setup:=LZ([1, 4, 5]);\ L:=setup[1]; Z:=setup[2];\ deq:={convert(L(y)(x)=0, diff)};\ IC:={y(0)=1, D(y)(0)=0}; IVP:=deq union IC;\ rt:=solve(Z(r)=0, r);\ y:=unapply(c1*exp(Re(rt[1])*x)*cos(Im(rt[1])*x)\ + c2*exp(Re(rt[1])*x)*sin(Im(rt[1])*x), x);\ eqs:=IC; sol:=solve(eqs, {c1, c2});\ y:=unapply(subs(sol, y(x)), x);\ check:=simplify(IVP); -------------------------------------------------------------------------------- # Ex 5 (S 3.5, 150/11) > unassign('y'); setup:=LZ([9, -12, 4]);\ L:=setup[1]; Z:=setup[2];\ deq:={convert(L(y)(x)=0, diff)};\ IC:={y(0)=2, D(y)(0)=-1}; IVP:=deq union IC;\ rt:=solve(Z(r)=0, r);\ y:=unapply(c1*exp(rt[1]*x) + c2*x*exp(rt[2]*x), x);\ eqs:=IC; sol:=solve(eqs, {c1, c2});\ y:=unapply(subs(sol, y(x)), x);\ check:=simplify(IVP); -------------------------------------------------------------------------------- # >