# Math 2280 Maple Project 3, Laplace Applications # NAME ________________________________________ # L3-1 # (a) opts:=ytickmarks=3,color=red,labels=[x,'f(x)'], title="square wave",numpoints=100,discont=true,thickness=2; f1:=x ->(-1)^floor(x); h1:=x->piecewise(x<1,1,x<2,-1,0); f2:=x -> x-floor(x); f3:=x -> 1/2+(f2(x)-1/2)*f1(x); f4:=x->abs(sin(x)); f5:=x->(1/2*(sin(x)+abs(sin(x)))); p:= x -> (2-x)*x: f6:=x->p(2*f2(x/2))*f1(x/2); q:=x->piecewise(xq(2*Pi*f2(x/2/Pi)); # Maple details for the example opt1:=ytickmarks=3,color=red,labels=[x,'f(x)'],title="square wave"; opt2:=numpoints=100,thickness=2,discont=true; opts:=opt1,opt2; f1:=x->(-1)^(floor(x)); T:=2; # T = period = 2 g:=x->x-T*floor(x/T); h1:=x->piecewise(x<1,1,x<2,-1,0); H1:=x->h1(g(x)); # T-periodic extension plot(H1(x)-f1(x),x=0..3*T,opts); # Should plot as y=0 (the x-axis) # What is not done here is to write solutions for (a), (b) for functions f2 --> f7. # You are expected to write code for h2 --> h7. Then devise the # corresponding answer check. Functions h1 --> h7 are pulses, not # periodic functions. This is why f1(t) = h1(t) is FALSE, but it is # TRUE that f1(t) = h1(2*f2(t/2)) [the composition is periodic]. # L3-2 DE:=diff(x(t),t,t)+9*x(t)=3*Dirac(t-3); IC:=x(0)=1,D(x)(0)=0; dsolve({DE,IC},x(t),method=laplace); # x(t) = cos(3*t)+Heaviside(t-3)*sin(-9+3*t) convert(%,piecewise);combine(%,trig); # x(t) = cos(3*t) for t < 3,cos(3*t)+sin(-9+3*t) for t>3, undef t=3. DE1:=diff(x(t),t,t)+9*x(t)=5*Dirac(t-3); IC1:=x(0)=-1,D(x)(0)=1; DE2:=diff(x(t),t,t)+9*x(t)=6*Dirac(t-3); IC2:=x(0)=1,D(x)(0)=-1; DE3:=diff(x(t),t,t)+9*x(t)=8*Dirac(t-3); IC3:=x(0)=0,D(x)(0)=-1; DE4:=diff(x(t),t,t)+9*x(t)=9*Dirac(t-3); IC4:=x(0)=1,D(x)(0)=0; # The input 3*Dirac(t-3) is an impulse or hammer hit of impulse=3 at time t=3 # The mass is pulled down 1 unit below equilibrium (x(0)=1) and then # released from rest (x'(0)=0). # L3-3 with(inttrans): # (a) Laplace method steps required # Example (a) # 5y ''(t) + 4y(t) = cos(t), y (0) = 1, y'(0)=0 DE:=5*diff(y(t),t,t)+4*y(t)=cos(t);IC:=y(0)=1,D(y)(0)=0; with(inttrans): # PHASE 1: Laplace's method, then isolate L(y(t)) left phase1a:=laplace(DE,t,s); phase1b:=subs(IC,phase1a); phase1c:=solve(phase1b,laplace(y(t),t,s)); # PHASE 2: Backward table and Lerch's theorem phase2:=invlaplace(phase1c,s,t); # Answer check with dsolve dsolve([DE,IC],y(t)); # Answer: y(t)=-cos(t)+2*cos(2*t/sqrt(5)) # (b), (c) answer check # dsolve({DE,IC},x(t),method=laplace); will work. # L3-4 # (a) f := x -> 2/10+7/10*sin(x)+1/10*cos(5*x): T:=2: # T==period g:=x->x-T*floor(x/T); # g==triangular wave of period T h:= x -> f(g(x)): # h == Extension of f as a periodic function plot(f(x),x=0..T); # Periodic function f on base interval [0,T] plot(h(x),x=-10..10,discont=true); # (b) f:=x->(1/10)*cos(5*x); # Test the periodic function rule formula T:=2: # T==period g:=x->x-T*floor(x/T); # g==triangular wave of period T int(f(g(t))*exp(-s*t),t=0..T)/(1-exp(-s*T)); #ans:=1/10*(-s+exp(-2*s)*s*cos(10)-5*exp(-2*s)*sin(10))/ # ((s^2+25)*(1-exp(-2*s))); Now repeat the code above using f := x -> 2/10+7/10*sin(x)+1/10*cos(5*x): T:=2: # T==period g:=x->x-T*floor(x/T); # g==triangular wave of period T int(f(g(t))*exp(-s*t),t=0..T)/(1-exp(-s*T)); # (c) pulse:=(t,a,b)->Heaviside(t-a)-Heaviside(t-b); T:=2: # T==period f := x -> 2/10+7/10*sin(x): h:= t->sum(f(t-n*T)*pulse(t,n*T,n*T+T),n=0..infinity); inttrans[laplace](h(t),t,s); eval(%) assuming n::positive; pulse:=(t,a,b)->Heaviside(t-a)-Heaviside(t-b); f := x -> 2/10+7/10*sin(x)+(1/10)*cos(5*x): h:= t->sum(f(t-n*T)*pulse(t,n*T,n*T+T),n=0..infinity); inttrans[laplace](h(t),t,s); eval(%) assuming n::positive; # This seems to work in xmaple 18 and xmaple 2015 # L3-5 with(LinearAlgebra):with(inttrans): A:=Matrix([[1,0],[0,2]]); u0:=Vector([alpha,beta]); B:=(s*IdentityMatrix(2)-A)^(-1).u0; u:=Map(invlaplace,B,s,t); # end of maple L3 text