Example 4 (Periodic Function)
Clear[f]
f[t_]:=(UnitStep[t]-UnitStep[t-Pi])-(UnitStep[t-Pi]-UnitStep[t-2 Pi])+
(UnitStep[t-2 Pi]-UnitStep[t-3 Pi])-(UnitStep[t-3 Pi]-UnitStep[t-4 Pi])
Plot[Evaluate[f[t]],{t,0,4 Pi}];The function is written in that way for your benefit. If you had a longer interval, you would need to be clever about it.
Clear[g]
g[t_]:=Sum[(-1)^k (UnitStep[t-k Pi]-UnitStep[t-(k+1) Pi]),{k,0,7}]
Plot[Evaluate[g[t]],{t,0,8 Pi}];
Clear[de,tde,newtde,Y,y]
Here's the differential equation:
de=y''[t]+3 y'[t]+2 y[t]==f[t]
Here is the transformed differential equation:
tde=LaplaceTransform[de,t,s]
Let's make use of the initial values:
newtde=tde/.{y[0]->0,y'[0]->0}Now solve this equation for Y[s].
Solve[newtde,LaplaceTransform[y[t],t,s]]; Y[s_]:=Evaluate[LaplaceTransform[y[t],t,s]/.Flatten[%]] Y[s]
Expect to wait for this one. Maybe go out for lunch.
y[t_]:=InverseLaplaceTransform[Y[s],s,t] y[t]
Plot[Evaluate[y[t]],{t,0,4 Pi}];Up to Solving Constant Coefficient Initial Value Problems with Special Forcing Functions