MATH 330 Differential Equations II
19 September 2023

Problem 3

c = 1; (* wave speed *)
f[x_] := Piecewise[{{x,0<x<1},{2-x,1<=x<2},{0,True}}];  (* initial position *)
u[t_,x_] := (1/2)(f[x-c t] + f[x+ c t]);(* d'Alembert's solution *)

Manipulate[Plot[{(1/2)f[x-c t],(1/2)f[x+c t],u[t,x]},{x,-4,6},PlotRange->{0,2},PlotLegends->{"left wave","right wave","u(x,t)"},AxesLabel->{"x","u"},PlotStyle->{Dashed, Dashed, Thick} ],{t,0,4,0.1}]

Manipulate[Plot[{(1/2)f[x-c t],(1/2)f[x+c t]},{x,-4,6},PlotRange->{0,2},PlotLegends->{"left wave","right wave"},AxesLabel->{"x","u"},PlotStyle->{Dashed, Dashed} ],{t,0,4,0.1}]

Problem 4

c = 1/2; (* wave speed *)
g[x_] := Cos[x];  (* initial velocity *)
u[t_,x_]:=(1/(2c))Sin[x+c t]-(1/(2c))Sin[x-c t] (* d'Alembert's solution *)

Manipulate[Plot[u[t,x],{x,-20,20},PlotRange->{-4,4}],{t,0,20,0.01}]

Manipulate[Plot[{(1/(2c))Sin[x+c t],(1/(2c))Sin[x-c t],u[t,x]},{x,-20,20},PlotRange->{-4,4},
PlotLegends->{"left wave","right wave","u(x,t)"},AxesLabel->{"x","u"},PlotStyle->{Dashed, Dashed, Thick} ],{t,0,30,0.1}]

Problem 5(a)

c = 1; (* wave speed *)
f[x_] = Piecewise[{{-1,-1<x<0},{1,0<=x<1},{0,True}}];  (* initial position *)
u[t_,x_] = (1/2)(f[x-c t] + f[x+ c t]);(* d'Alembert's solution *)

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

Manipulate[Plot[{(1/2)f[x-c t],(1/2)f[x+c t],u[t,x]},{x,-6,6},PlotRange->{-1,1},PlotLegends->{"left wave","right wave","u(x,t)"},AxesLabel->{"x","u"},PlotStyle->{Dashed, Dashed, Thick} ],{t,0,4,0.1}]

Problem 5(b)

c = 1; (* wave speed *)
f[x_] = Piecewise[{{x,-1<x<1},{0,True}}];  (* initial position *)
u[t_,x_] = (1/2)(f[x-c t] + f[x+ c t]);(* d'Alembert's solution *)

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

Manipulate[Plot[{(1/2)f[x-c t],(1/2)f[x+c t],u[t,x]},{x,-6,6},PlotRange->{-1,1},PlotLegends->{"left wave","right wave","u(x,t)"},AxesLabel->{"x","u"},PlotStyle->{Dashed, Dashed, Thick} ],{t,0,4,0.1}]