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)"}]

Animations for Section 1.2 #6

c=1;
λ=1;

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

α[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,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->{"t","u"}],
{t,0,6},
AnimationRunning->False]

Visualizing solution for characteristic coordinates example

u0[x_]=Exp[-x^2]

Plot[u0[x],{x,-4,4}]

u[x_,t_]=u0[x Exp[-t]]

Animate[Plot[u[x,t],{x,-10,10},PlotRange->{0,1}],{t,0,4},AnimationRunning->False]