Section 2.4 #3

Clear[f,g,u]

f[x_]=x Exp[-x]

g[x_]=Piecewise[{{-f[-x],x<0},{f[x],x≥0}}]

Plot[g[x],{x,-5,5}]

Plot[{g[x-1],g[x+1],(g[x-1]+g[x+1])/2},{x,-10,10}]

Plot[{g[x-1],g[x+1],(g[x-1]+g[x+1])/2},{x,-10,10},PlotStyle->{Red,Green,{AbsoluteThickness[1.5],Black}}]

Animate[Plot[{g[x-t],g[x+t],(g[x-t]+g[x+t])/2},{x,-30,30},PlotStyle->{Red,Green,{AbsoluteThickness[1.5],Black}},PlotRange->{-0.5,0.5}],{t,0,20},AnimationRunning->False]

Animate[Plot[{g[x-t],g[x+t],(g[x-t]+g[x+t])/2},{x,0,30},PlotStyle->{Red,Green,{AbsoluteThickness[1.5],Black}},PlotRange->{-0.5,0.5}],{t,0,20},AnimationRunning->False]

Clear[c]

u[x_,t_]=Piecewise[{{(f[x+ c t]+f[x-c t])/2,x>=c t},{(f[x+c t]-f[-(x-c t)])/2,x<=c t}}]

c=1

Plot[u[x,3],{x,0,15}]

Animate[Plot[u[x,t],{x,0,30},PlotRange->{-0.5,0.5}],{t,0,30},AnimationRunning->False]

Another initial condition

f[x_]=Piecewise[{{x-8,8<x<10},{-x+12,10<x<12}}]

Plot[f[x],{x,0,30}]

g[x_]:=Piecewise[{{-f[-x],x<0},{f[x],x≥0}}]

Plot[g[x],{x,-30,30}]

Animate[Plot[{g[x-t],g[x+t],(g[x-t]+g[x+t])/2},{x,-30,30},PlotStyle->{Red,Green,{AbsoluteThickness[1.5],Black}},PlotRange->{-4,4}],{t,0,20},AnimationRunning->False]

Animate[Plot[{g[x-t],g[x+t],(g[x-t]+g[x+t])/2},{x,0,30},PlotStyle->{Red,Green,{AbsoluteThickness[1.5],Black}},PlotRange->{-4,4}],{t,0,20},
AnimationRunning->False]

Heaviside step function

Plot[HeavisideTheta[t],{t,-2,2}]

HeavisideTheta[0]

Plot[UnitStep[t],{t,-2,2}]

UnitStep[0]

D[HeavisideTheta[t],t]

Clear[a]

LaplaceTransform[HeavisideTheta[t-a],t,s,Assumptions->a>0]