Piecewise defined functions

f[x_]=Piecewise[{{1,x<2},{5,x>2}}]

f[2]

f[x_]=Piecewise[{{1,x<2},{5,x>2}},17]

f[2]

f[x_]=Piecewise[{{1,x<2},{5,x>2}},Null]

f[2]

Plot[f[x],{x,0,4},PlotRange->{0,6},AxesLabel->{"x","f(x)"}]

Visualizations for Section 1.2 #6

Constant

Clear[g,c,λ]

c=1;
λ=1;

g[t_]=1

α[y_]=Piecewise[{{g[-y/c]*Exp[-λ/c y],y<0},{0,y>0}}]

Plot[α[y],{y,-2,2},PlotStyle->Thick]

u[x_,t_]=α[x-c t]Exp[-λ t]

Plot[u[x,4],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
AxesLabel->{"t","u"}]

Animate[
Plot[u[x,t],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
Exclusions->{t},
AxesLabel->{"x","u"}],
{t,0,10},
AnimationRunning->False]

Plot3D[u[x,t],{x,0,5},{t,0,10},MeshFunctions->{#3&}]

Piecewise blip

Clear[g,c,λ]

c=1;
λ=2;

g[t_]=Piecewise[{{1,2<t<3}}]

Plot[g[t],{t,0,10}]

α[y_]=Piecewise[{{g[-y/c]*Exp[-λ/c y],y<0},{0,y>0}}]

Plot[α[y],{y,-5,2},PlotStyle->Thick]

u[x_,t_]=α[x-c t]Exp[-λ t]

Plot[u[x,4],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
AxesLabel->{"x","u"}]

Plot[u[1,t],{t,0,20},
PlotStyle->Thick,
PlotRange->{-0.1,2},
AxesLabel->{"t","u"}]

Animate[
Plot[u[x,t],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
Exclusions->{t},
AxesLabel->{"x","u"}],
{t,0,10},
AnimationRunning->False]

Plot3D[u[x,t],{x,0,5},{t,0,10},MeshFunctions->{#3&}]

Sinusiodal

Clear[g,c,λ]

c=1;
λ=1;

g[t_]=1+Sin[t]

α[y_]=Piecewise[{{g[-y/c]*Exp[-λ/c y],y<0},{0,y>0}}]

Plot[α[y],{y,-20,2},PlotStyle->Thick]

u[x_,t_]=α[x-c t]Exp[-λ t]

Plot[u[x,3],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
AxesLabel->{"x","u"}]

Animate[
Plot[u[x,t],{x,0,5},
PlotStyle->Thick,
PlotRange->{-0.1,2},
Exclusions->{t},
AxesLabel->{"x","u"}],
{t,0,20},
AnimationRunning->False,
AnimationRate->1]

Plot3D[u[x,t],{x,0,5},{t,0,20},MeshFunctions->{#3&},PlotRange->All]