SetDirectory[StringJoin[$HomeDirectory,"/Dropbox/PDEBOOK/Wave"]]

SetDirectory[StringJoin[$HomeDirectory,"/Documents/handouts/math467/dAlembert"]]

Partial Derivatives

TreePlot[{{u->ξ,"((∂u)/(∂ξ))"},{u->η,"((∂u)/(∂η))"},{ξ->x,"((∂ξ)/(∂x))"},{ξ->y,"((∂ξ)/(∂y))"},{η->"x","((∂η)/(∂x))"},{η->"y","((∂η)/(∂y))"}},EdgeLabels->Automatic,EdgeLabelStyle->Medium,VertexSize->Large,VertexShapeFunction->"Circle",VertexLabels->Placed[Automatic,Center],VertexLabelStyle->Large]

Export["firstpartialderivatives.pdf",%,"PDF"]

Export["firstpartialderivatives.eps",%%,"EPS"]

TreePlot[{{"(Subscript[u, x])"->ξ,"((∂(Subscript[u, x]))/(∂ξ))"},{"(Subscript[u, x])"->η,"((∂(Subscript[u, x]))/(∂η))"},{ξ->x,"((∂ξ)/(∂x))"},{ξ->y,"((∂ξ)/(∂y))"},{η->"x","((∂η)/(∂x))"},{η->"y","((∂η)/(∂y))"}},EdgeLabels->Automatic,EdgeLabelStyle->Medium,VertexSize->Large,VertexShapeFunction->"Circle",VertexLabels->Placed[Automatic,Center],VertexLabelStyle->Large]

Export["secondpartialderivativesx.pdf",%,"PDF"]

Export["secondpartialderivativesx.eps",%%,"EPS"]

TreePlot[{{"(Subscript[u, t])"->ξ,"((∂(Subscript[u, t]))/(∂ξ))"},{"(Subscript[u, t])"->η,"((∂(Subscript[u, t]))/(∂η))"},{ξ->x,"((∂ξ)/(∂x))"},{ξ->y,"((∂ξ)/(∂y))"},{η->"x","((∂η)/(∂x))"},{η->"y","((∂η)/(∂y))"}},EdgeLabels->Automatic,EdgeLabelStyle->Medium,VertexSize->Large,VertexShapeFunction->"Circle",VertexLabels->Placed[Automatic,Center],VertexLabelStyle->Large]

Export["secondpartialderivativest.pdf",%,"PDF"]

Export["secondpartialderivativest.eps",%%,"EPS"]

Example

f[x_]:=Piecewise[{{3x/10,0≤x≤1/3},{3(1-x)/20,1/3<x≤1}}]

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

2Integrate[f[x]Sin[n π x],{x,0,1},Assumptions->{n∈Integers}]

c[n_Integer]:=9Sin[n π/3]/(10(n^2)(π^2))

u[n_Integer][x_,t_]:=c[n]Sin[n π x]Cos[n π t]

Table[D[u[n][x,t],x,x]-D[u[n][x,t],t,t],{n,1,10,1}]

DSolve[{D[u[x,t],t,t]==D[u[x,t],x,x],u[0,t]==0,u[1,t]==0,u[x,0]==f[x],(D[u[x,t],t]/.t->0)==0},u[x,t],{x,t}]

Example 01

PeriodicExtension[f_,L_][x_]:=f[Mod[x,2L,-L]]

EvenExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{f[-#],-L≤#≤0}}]&,L][x]

OddExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{-f[-#],-L≤#≤0}}]&,L][x]

f[x_]:=Piecewise[{{3x/10,0≤x<1/3},{3(1-x)/20,1/3≤x≤1}}]

Plot[OddExtension[f,1][x],{x,-3,3},AxesLabel->{"x","f(x)"},PlotTheme->"Monochrome"]

Export["example01init.eps",%,"EPS"]

Export["example01init.pdf",%%,"PDF"]

u[x_,t_]:=(OddExtension[f,1][x+t]+OddExtension[f,1][x-t])/2

Plot[{u[x,0],u[x,1/4],u[x,1/2],u[x,3/4],u[x,1]},{x,0,1},PlotTheme->{"Monochrome","Detailed"},FrameLabel->{"x","u"}]

Export["example01.eps",%,"EPS"]

Export["example01.pdf",%%,"PDF"]

Legended[Show[Plot[u[x,1/6],{x,0,1},PlotTheme->"Monochrome",PlotStyle->Thick],Plot[{OddExtension[f,1][x+1/6]/2,OddExtension[f,1][x-1/6]/2},{x,-3,3},PlotTheme->"Monochrome",PlotStyle->{Dashed,Dotted}],AxesLabel->{"x",""},PlotRange->{{-3,3},{-1/10,1/10}}],LineLegend[{Thick,Dashed,Dotted},{"u(x,1/6)","(1/2)f(x+1/6)","(1/2)f(x-1/6)"}]]

Export["example01t1over6.eps",%,"EPS"]

Export["example02t1over6.pdf",%%,"PDF"]

Legended[Show[Plot[u[x,1/3],{x,0,1},PlotTheme->"Monochrome",PlotStyle->Thick],Plot[{OddExtension[f,1][x+1/3]/2,OddExtension[f,1][x-1/3]/2},{x,-3,3},PlotTheme->"Monochrome",PlotStyle->{Dashed,Dotted}],AxesLabel->{"x",""},PlotRange->{{-3,3},{-1/10,1/10}}],LineLegend[{Thick,Dashed,Dotted},{"u(x,1/3)","(1/2)f(x+1/3)","(1/2)f(x-1/3)"}]]

Export["example01t1over3.eps",%,"EPS"]

Export["example02t1over3.pdf",%%,"PDF"]

Legended[Show[Plot[u[x,2/3],{x,0,1},PlotTheme->"Monochrome",PlotStyle->Thick],Plot[{OddExtension[f,1][x+2/3]/2,OddExtension[f,1][x-2/3]/2},{x,-3,3},PlotTheme->"Monochrome",PlotStyle->{Dashed,Dotted}],AxesLabel->{"x",""},PlotRange->{{-3,3},{-1/10,1/10}}],LineLegend[{Thick,Dashed,Dotted},{"u(x,2/3)","(1/2)f(x+2/3)","(1/2)f(x-2/3)"}]]

Export["example01t2over3.eps",%,"EPS"]

Export["example02t2over3.pdf",%%,"PDF"]

Example 02

PeriodicExtension[f_,L_][x_]:=f[Mod[x,2L,-L]]

EvenExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{f[-#],-L≤#≤0}}]&,L][x]

OddExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{-f[-#],-L≤#≤0}}]&,L][x]

g[x_]:=Piecewise[{{1,1/2≤x≤1},{0,x<1/2},{0,x>1}}]

Plot[g[x],{x,0,2}]

(2/(n π c))Integrate[g[x]Sin[n π x/2],{x,0,2},Assumptions->{n∈Integers}]

d[n_Integer]:=4(Cos[n π/4]-Cos[n π/2])/((n^2)(π^2)c)

u[n_Integer][x_,t_]:=d[n]Sin[n π c t/2]Sin[n π x/2]

Table[(c^2)D[u[n][x,t],x,x]-D[u[n][x,t],t,t],{n,1,10,1}]

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

Integrate[OddExtension[g,2][s],{s,x-c t,x+c t}]

Plot[{Integrate[OddExtension[g,2][s],{s,x-t,x+t}/.{t->0}]/2,Integrate[OddExtension[g,2][s],{s,x-t,x+t}/.{t->1/4}]/2,Integrate[OddExtension[g,2][s],{s,x-t,x+t}/.{t->1/2}]/2,Integrate[OddExtension[g,2][s],{s,x-t,x+t}/.{t->3/4}]/2,Integrate[OddExtension[g,2][s],{s,x-t,x+t}/.{t->1}]/2},{x,0,2},PlotRange->All,PlotTheme->"Monochrome",AxesLabel->{"x","u"},PlotLegends->LineLegend[{"u(x,0)","u(x,1/4)","u(x,1/2)","u(x,3/4)","u(x,1)"}]]

Export["example02.eps",%,"EPS"]

Export["example02.pdf",%%,"PDF"]

Example 03

ContourPlot[{x-t==-1,x-t==1,x+t==-1,x+t==1},{x,-3,3},{t,0,3},FrameLabel->{"x","t"},FrameTicks->{{{{1,"1/c"},{2,"2/c"}},None},Automatic},PlotLegends->LineLegend[{"x - c t = -1","x - c t = 1","x + c t = -1","x + c t = 1"}],AspectRatio->1/2,Epilog->{Text["Region 1",{-2.5,1/4}],Text["Region 2",{0,1/4}],Text["Region 3",{2.5,1/4}],Text["Region 6",{-2.5,5/2}],Text["Region 5",{0,5/2}],Text["Region 4",{2.5,5/2}]}]

Export["chars.eps",%,"EPS"]

Export["chars.pdf",%%,"PDF"]

Legended[Graphics[{EdgeForm[],FaceForm[GrayLevel[0]],Triangle[{{-3,0},{-1,0},{-3,3}}],,Triangle[{{3,0},{1,0},{3,2}}],FaceForm[GrayLevel[0.5]],Polygon[{{-1,0},{1,0},{3,2},{3,3},{-3,3},{-3,2},{-1,0}}],FaceForm[GrayLevel[1]],Triangle[{{-1,0},{1,0},{0,1}}],FaceForm[GrayLevel[0]],Triangle[{{-2,3},{0,1},{2,3}}]},Frame->True,FrameTicks->{Automatic,{{2,"2/c"}}},FrameLabel->{"x","t"},AspectRatio->1],SwatchLegend[GrayLevel/@{0,1/2,1},{"u(x,t) = 0","u(x,t) = 1","u(x,t) = 2"}]]

Legended[Show[{Graphics[{EdgeForm[],FaceForm[GrayLevel[0]],Triangle[{{-3,0},{-1,0},{-3,3}}],,Triangle[{{3,0},{1,0},{3,2}}],FaceForm[GrayLevel[0.5]],Polygon[{{-1,0},{1,0},{3,2},{3,3},{-3,3},{-3,2},{-1,0}}],FaceForm[GrayLevel[1]],Triangle[{{-1,0},{1,0},{0,1}}],FaceForm[GrayLevel[0]],Triangle[{{-2,3},{0,1},{2,3}}],Text["u=2",{0,1/4},Background->White],Text["u=1",{-1,5/4},Background->White],Text["u=1",{1,5/4},Background->White],Text["u=0",{-2,1/4},Background->White],Text["u=0",{2,1/4},Background->White],Text["u=0",{0,2},Background->White]}],ContourPlot[{x-t==-1,x-t==1,x+t==-1,x+t==1},{x,-3,3},{t,0,3},ContourStyle->Thick]},Frame->True,FrameTicks->{{{{1,"1/c"},{2,"2/c"}},None},{Automatic,None}},FrameLabel->{"x","t"},AspectRatio->1/2],LineLegend[{Directive[RGBColor[0.368417`,0.506779`,0.709798`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.880722`,0.611041`,0.142051`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.560181`,0.691569`,0.194885`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.922526`,0.385626`,0.209179`],AbsoluteThickness[1.6`]]},{"x - c t = -1","x - c t = 1","x + c t = -1","x + c t = 1"}]]

Export["dens.eps",%,"EPS"]

Export["dens.pdf",%%,"PDF"]

u[x_,t_]:=Piecewise[{{0,x+c t<-1},{2,And[-1<x-c t<1,-1<x+c t<1]},{0,1<x-c t},{1,And[1<x+c t,-1<x-c t<1]},{0,And[1<x+c t,x-c t<-1]},{1,And[-1<x+c t<1,x-c t<-1]}}]

ParametricPlot3D[Evaluate[Table[{x,t,u[x,t]}/.c->1,{t,0,3,1/2}]],{x,-3,3},Boxed->False,AxesLabel->{"x","t","u(x,t)"},Ticks->{Automatic,Table[{s,s/c},{s,0,3,1}],Automatic}]

Export["snaps01.pdf",%,"PDF"]

Export["snaps01.eps",%%,"EPS"]

Plot3D[u[x,t]/.c->1,{x,-3,3},{t,0,3},PlotPoints->50,Exclusions->{x+t==1,x+t==-1,x-t==1,x-t==-1},ExclusionsStyle->{None,Red},ColorFunction->GrayLevel,Mesh->None,AxesLabel->{"x","t","u(x,t)"},BaseStyle->FontSize->12]

Export["surf01.pdf",%,"PDF"]

Export["surf01.eps",%%,"EPS"]

ParametricPlot[Evaluate[Table[{x,u[x,t]}/.c->1,{t,0,3,1/2}]],{x,-3,3},AxesLabel->{"x","u"}]

Plot[u[x,0]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,0)",PlotTheme->"Monochrome",PlotRange->{-0.02,2},Exclusions->{x==-1,x==1}]

Export["example03t0.eps",%,"EPS"]

Export["example03t0.pdf",%%,"PDF"]

Plot[u[x,1/2]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,1/(2c))",PlotTheme->"Monochrome",PlotRange->{-0.02,2},Exclusions->{x==-3/2,x==3/2,x==-1/2,x==1/2}]

Export["example03t1over2c.eps",%,"EPS"]

Export["example03t1over2c.pdf",%%,"PDF"]

Plot[u[x,1]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,1/c)",PlotTheme->"Monochrome",PlotRange->{-0.02,2},Exclusions->{x==-2,x==2}]

Export["example03t1overc.eps",%,"EPS"]

Export["example03t1overc.pdf",%%,"PDF"]

Plot[u[x,2]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,2/c)",PlotTheme->"Monochrome",PlotRange->{-0.02,2},Exclusions->{x==-1,x==1}]

Export["example03t2overc.eps",%,"EPS"]

Export["example03t2overc.pdf",%%,"PDF"]

Example 03 (Alternate)

u[x_,t_]:=Piecewise[{{0,x+c t<-1},{1,And[-1<x+c t<1,x-c t<-1]},{1,x-c t<-1},{0,And[x+c t>1,x-c t<-1]},{1,And[x+c t>1,-1<x-c t<1]},{0,x-c t>1},{2,And[-1<x-c t<1,-1<x+c t≤1]}}]

DensityPlot[u[x,t]/.c->1,{x,-5,5},{t,0,5},FrameLabel->{"x","t"},PlotPoints->100,PlotTheme->{"Detailed","Monochrome"}]

Graphics[{EdgeForm[],FaceForm[GrayLevel[0.1]],Triangle[{{-5,0},{-1,0},{-5,4}}],,Triangle[{{5,0},{1,0},{5,4}}],FaceForm[GrayLevel[0.45]],Polygon[{{-1,0},{1,0},{5,4},{5,5},{-5,5},{-5,4},{-1,0}}],FaceForm[GrayLevel[0.9]],Triangle[{{-1,0},{1,0},{0,1}}]},Frame->True,FrameLabel->{"x","t"}]

Legended[Graphics[{EdgeForm[],FaceForm[GrayLevel[0]],Triangle[{{-5,0},{-1,0},{-5,4}}],,Triangle[{{5,0},{1,0},{5,4}}],FaceForm[GrayLevel[0.5]],Polygon[{{-1,0},{1,0},{5,4},{5,5},{-5,5},{-5,4},{-1,0}}],FaceForm[GrayLevel[1]],Triangle[{{-1,0},{1,0},{0,1}}]},Frame->True,FrameLabel->{"x","t"},AspectRatio->1],BarLegend[{"GrayTones",{0,2}}]]

Export["Example01a.eps",%]

Export["Example01a.pdf",%%]

Plot[u[x,0]/.c->1,{x,-5,5},AxesLabel->{"x","u(x,0)"},PlotTheme->"Monochrome"]

Export["Example01b.eps",%]

Export["Example01b.pdf",%%]

Plot[u[x,1/2]/.c->1,{x,-5,5},AxesLabel->{"x","u(x,1/2c)"},PlotTheme->"Monochrome"]

Export["Example01c.eps",%]

Export["Example01c.pdf",%%]

Plot[u[x,1]/.c->1,{x,-5,5},AxesLabel->{"x","u(x,1/c)"},PlotTheme->"Monochrome"]

Export["Example01d.eps",%]

Export["Example01d.pdf",%%]

Plot[u[x,1]/.c->2,{x,-5,5},AxesLabel->{"x","u(x,2/c)"},PlotTheme->"Monochrome"]

Export["Example01e.eps",%]

Export["Example01e.pdf",%%]

Plot[{u[x,0]/.c->1,u[x,1/2]/.c->1,u[x,1]/.c->1,u[x,2]/.c->1},{x,-5,5},AxesLabel->{"x","u(x,t)"},PlotTheme->{"Detailed","Monochrome"}]

Plot3D[u[x,t]/.c->1,{x,-5,5},{t,0,5},AxesLabel->{"x","t","u(x,t)"},PlotPoints->50,ColorFunction->Function[{x,y,z},GrayLevel[z]],Mesh->False,PlotTheme->{"Monochrome"}]

Example 04

G[x_]:=Piecewise[{{-1,x<-1},{x,-1≤x≤1},{1,x>1}}]

PiecewiseExpand[G[x+c t]-G[x-c t]]

Plot[G[x],{x,-5,5},AxesLabel->{"x","G(x)"},PlotTheme->"Monochrome"]

u[x_,t_]:=Piecewise[{{0,x+c t<-1},{2c t,And[-1<x-c t,x+c t<1]},{0,1<x-c t},{1-x+c t,And[1<x+c t,-1<x-c t<1]},{2,And[1<x+c t,x-c t<-1]},{1+x+c t,And[-1<x+c t<1,x-c t<-1]}}]/(2c)

DensityPlot[u[x,t]/.c->1,{x,-3,3},{t,0,3},FrameLabel->{"x","t"},PlotPoints->100]

Legended[Show[{DensityPlot[u[x,t]/.c->1,{x,-3,3},{t,0,3}],ContourPlot[{x-t==-1,x-t==1,x+t==-1,x+t==1},{x,-3,3},{t,0,3},ContourStyle->Thick]},Frame->True,FrameTicks->{{{{1,"1/c"},{2,"2/c"}},None},{Automatic,None}},FrameLabel->{"x","t"},AspectRatio->1/2],LineLegend[{Directive[RGBColor[0.368417`,0.506779`,0.709798`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.880722`,0.611041`,0.142051`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.560181`,0.691569`,0.194885`],AbsoluteThickness[1.6`]],Directive[RGBColor[0.922526`,0.385626`,0.209179`],AbsoluteThickness[1.6`]]},{"x - c t = -1","x - c t = 1","x + c t = -1","x + c t = 1"}]]

Export["example04dens.eps",%,"EPS"]

Export["example04dens.pdf",%%,"PDF"]

ParametricPlot[Evaluate[Table[{x,u[x,t]}/.c->1,{t,0,3,1/2}]],{x,-3,3},AxesLabel->{"x","u"}]

Plot3D[u[x,t]/.c->1,{x,-3,3},{t,0,3},PlotPoints->50,AxesLabel->{"x","t","u(x,t)"},Ticks->{Automatic,{{1,"1/c"},{2,"2/c"}},Automatic},MeshFunctions->{#2&},MeshStyle->Thick]

Export["example04surf.pdf",%,"PDF"]

Export["example04surf.eps",%%,"EPS"]

Legended[Show[RegionPlot[And[-1<x-t<1,-1<x+t<1],{x,-1,1},{t,0,1},BoundaryStyle->None,ColorFunction->Function[{x,t},GrayLevel[(t+1)/2]],ColorFunctionScaling->False],RegionPlot[And[-1<x+t<1,x-t<-1],{x,-3,0},{t,0,3},BoundaryStyle->None,ColorFunction->Function[{x,t},GrayLevel[(x+t+1)/2]],ColorFunctionScaling->False],Graphics[{EdgeForm[],FaceForm[GrayLevel[1/2]],Triangle[{{-3,0},{-1,0},{-3,2}}],,Polygon[{{0,1},{1,0},{3,0},{3,3},{2,3},{0,1}}],FaceForm[GrayLevel[1]],Triangle[{{-2,3},{0,1},{2,3}}]}],Frame->True,FrameTicks->{Automatic,{{2,"2/c"}}},FrameLabel->{"x","t"},AspectRatio->1,PlotRange->{{-3,3},{0,3}}],BarLegend[{GrayLevel,{-2,2}}]]

Plot[u[x,0]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,0)",PlotTheme->"Monochrome",PlotRange->{-2,2}]

Export["example04t0.eps",%,"EPS"]

Export["example04t0.pdf",%%,"PDF"]

Plot[u[x,1/2]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,1/(2c))",PlotTheme->"Monochrome",PlotRange->{-2,2},Exclusions->{x==-3/2,x==3/2,x==-1/2,x==1/2}]

Export["example04t1over2c.eps",%,"EPS"]

Export["example04t1over2c.pdf",%%,"PDF"]

Plot[u[x,1]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,1/c)",PlotTheme->"Monochrome",PlotRange->{-2,2},Exclusions->{x==-2}]

Export["example04t1overc.eps",%,"EPS"]

Export["example04t1overc.pdf",%%,"PDF"]

Plot[u[x,2]/.c->1,{x,-3,3},AxesLabel->{"x",""},PlotLabel->"u(x,2/c)",PlotTheme->"Monochrome",PlotRange->{-2,2},Exclusions->{x==-1,x==1}]

Export["example04t2overc.eps",%,"EPS"]

Export["example04t2overc.pdf",%%,"PDF"]

Example 05

PeriodicExtension[f_,L_][x_]:=f[Mod[x,2L,-L]]

EvenExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{f[-#],-L≤#≤0}}]&,L][x]

OddExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{-f[-#],-L≤#≤0}}]&,L][x]

g[x_]:=Piecewise[{{0,0<x<L/4},{1,L/4≤x≤3L/4},{0,3L/4<x<L}}]

Integrate[g[s],{s,0,x},Assumptions->{L>0,x∈Reals}]

Plot[OddExtension[g,1][x]/.L->1,{x,-3,3},Exclusions->Table[(2n-1)/4,{n,-7,7}],ExclusionsStyle->Dashed,PlotStyle->Thick,AxesLabel->{"x","(Subscript[g, o])(x)"}]

Export["godd.pdf",%,"PDF"]

Export["godd.eps",%%,"EPS"]

Plot[{Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}/.{t->0}]/2,Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}/.{t->1/8}]/2,Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}/.{t->1/4}]/2,Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}/.{t->3/8}]/2,Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}/.{t->1/2}]/2},{x,0,1},PlotRange->All,Ticks->{{{0,"0"},{1/4,"L/4"},{1/2,"L/2"},{3/4,"3L/4"},{1,"L"}},{{1/8,"L/8"},{1/4,"L/4"}}},AxesLabel->{"x","u"},PlotLegends->LineLegend[{"u(x,0)","u(x,L/8c)","u(x,L/4c)","u(x,3L/8c)","u(x,L/2c)"}]]

Export["example05snaps.eps",%,"EPS"]

Export["example05snaps.pdf",%%,"PDF"]

G[x_]:=Piecewise[{{0,0<x<L/4},{x-L/4,L/4≤x≤3L/4},{L/2,3L/4<x<L}}]

Plot[G[x]/.L->1,{x,0,1},AxesLabel->{"x","G(x)"},PlotTheme->"Monochrome",Ticks->{{{0,"0"},{1/4,"L/4"},{3/4,"3L/4"},{1,"L"}},{{1/4,"L/4"},{1/2,"L/2"}}}]

Export["Example04G.eps",%]

Export["Example04G.pdf",%%]

u[x_,t_]:=Piecewise[{{0,x+c t<L/4},{x+c t-L/4,And[x-c t≤L/4,L/4≤x+c t≤3L/4]},{L/2,And[L/4≤x-c t,3L/4≤x+c t]},{L/2-(x-c t-L/4),And[L/4≤x-c t≤3L/4,x+c t≥3L/4]},{-(x-c t)+L/4,L/4≤x-c t≤3L/4≤x+c t≤L},{L/2,L/4≤x-c t≤x+c t≤3L/4}}]/(2c)

DensityPlot[Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}]/2,{x,0,1},{t,0,1},PlotPoints->50,FrameLabel->{"x","t"}]

Plot3D[Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}]/2,{x,0,1},{t,0,1},PlotPoints->50,AxesLabel->{"x","t","u(x,t)"},MeshFunctions->{#2&},MeshStyle->Thick]

Plot3D[Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}]/2,{x,0,1},{t,0,2},PlotPoints->50,AxesLabel->{"x","t","u(x,t)"},MeshFunctions->{#2&},MeshStyle->Thick,BoxRatios->{1,2,1/2}]

Export["example05surf.pdf",%,"PDF"]

Export["example05surf.eps",%%,"EPS"]

ContourPlot[{x+t==1/4,x+t==3/4,x+t==5/4,x+t==7/4,x-t==-3/4,x-t==1/4,x-t==3/4,x-t==-1/4},{x,0,1},{t,0,1},ContourStyle->Thick]

Export["Example04.eps",%]

Export["Example04.pdf",%%]

DensityPlot[Integrate[OddExtension[g,1][s]/.L->1,{s,x-t,x+t}]/2,{x,0,2},{t,0,2},PlotPoints->50,FrameLabel->{"x","t"}]

Example 06

PeriodicExtension[f_,L_][x_]:=f[Mod[x,2L,-L]]

EvenExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{f[-#],-L≤#≤0}}]&,L][x]

OddExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{-f[-#],-L≤#≤0}}]&,L][x]

g[x_]:=x Cos[x]

Plot[OddExtension[g,π/2][x],{x,-3π/2,3π/2},Ticks->{{-3π,-2π,-1π,0π,1π,2π,3π}/2,Automatic}]

Plot[{NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}/.{t->0}]/2,NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}/.{t->1/2}]/2,NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}/.{t->1}]/2,NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}/.{t->3/2}]/2,NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}/.{t->2}]/2},{x,0,π/2},PlotRange->All,PlotTheme->"Monochrome",Ticks->{Table[k π/8,{k,0,4,1}],Automatic},AxesLabel->{"x","u"},PlotLegends->LineLegend[{"u(x,0)","u(x,1/2)","u(x,1)","u(x,3/2)","u(x,2)"}]]

Export["example06snaps.eps",%,"EPS"]

Export["example06snaps.pdf",%%,"PDF"]

DensityPlot[NIntegrate[OddExtension[g,π/2][s],{s,x-t,x+t}]/2,{x,0,π/2},{t,0,1},PlotPoints->50,FrameLabel->{"x","t"},PlotTheme->{"Detailed","Monochrome"}]

DensityPlot[Integrate[OddExtension[g,π/2][s],{s,x-t,x+t}]/2,{x,0,π},{t,0,2},PlotPoints->50,FrameLabel->{"x","t"}]

Normal Modes

Plot[{Sin[π x],Sin[2π x],Sin[3π x]},{x,0,1},AxesLabel->{"x",""},PlotTheme->"Monochrome",Ticks->{Table[{k,k"L"},{k,0,1,1/5}],Automatic},PlotLegends->LineLegend[{Automatic,Dashed,Dotted},{"sin(π x/L)","sin(2π x/L)","sin(3π x/L)"}]]

Export["normalmodes.eps",%,"EPS"]

Export["normalmodes.pdf",%%,"PDF"]

Domain of Dependence

Graphics[{EdgeForm[],FaceForm[GrayLevel[1/2]],Triangle[{{-1,0},{1,0},{0,1}}],Thick,Line[{{-1,0},{0,1}}],Line[{{1,0},{0,1}}],Text["((Subscript[x, 0]), (Subscript[t, 0]))",{0,1.1}]},Axes->True,AxesLabel->{"x","t"},AxesOrigin->{-5/4,0},Ticks->{{{-1,"(Subscript[x, 0]) - c (Subscript[t, 0])"},{0,"(Subscript[x, 0])"},{1,"(Subscript[x, 0]) + c (Subscript[t, 0])"}},{{1,"(Subscript[t, 0])"}}}]

Export["domdep.eps",%,"EPS"]

Export["domdep.pdf",%%,"PDF"]

Domain of Influence

Graphics[{EdgeForm[],FaceForm[GrayLevel[1/2]],Triangle[{{-1,1},{0,0},{1,1}}],Thick,Line[{{-1,1},{0,0}}],Line[{{1,1},{0,0}}],Text["((Subscript[x, 0]), (Subscript[t, 0]))",{0,-0.1}],Text["x = (Subscript[x, 0]) - c(t - (Subscript[t, 0]))",{-4/5,1/2}],Text["x = (Subscript[x, 0]) + c(t - (Subscript[t, 0]))",{4/5,1/2}]},Axes->True,AxesLabel->{"x","t"},AxesOrigin->{-5/4,-1/4},Ticks->{{{0,"(Subscript[x, 0])"}},{{0,"(Subscript[t, 0])"}}}]

Export["dominf.eps",%,"EPS"]

Export["dominf.pdf",%%,"PDF"]

Example 07

FourierSinCoefficient[x,x,n,FourierParameters->{1,π/L}]

D[2(ω^2)(((-1))^n)/(n π((ω^2)-((Subscript[ω, n])^2)))Sin[ω t],t]/.t->0

D[ω(((-1))^n)/(n π)t Cos[ω t],t]/.t->0

DSolve[{y''[t]+(((n π c/L))^2)y[t]+2(((-1))^n)(ω^2)/(n π) Sin[ω t]==0,y[0]==0,y'[0]==0},y[t],t]//Simplify

DSolve[{y''[t]+(((n π c/L))^2)y[t]+2(((-1))^n)(ω^2)/(n π) Sin[ω t]==0,y[0]==0,y'[0]==0}/.ω->n π c/L,y[t],t]//Simplify

NDSolve[{D[u[x,t],t,t]==D[u[x,t],x,x],u[0,t]==0,u[1,t]==Sin[t],u[x,0]==0,Derivative[0,1][u][x,0]==0},u,{x,0,1},{t,0,1}]

Plot3D[u[x,t]/.First[%9],{x,0,1},{t,0,1},AxesLabel->{"x","t","u"}]

Example

ContourPlot[{x+2t==1/4,x+2t==3/4,x-2t==1/4,x-2t==3/4},{x,0,1},{t,0,1/2},PlotLegends->"Expressions",FrameLabel->{"x","t"},Epilog->{Text["Region 1",{0.08,0.02}],Text["Region 2",{0.5,0.02}],,Text["Region 3",{0.9,0.02}],Text["Region 6",{0.08,0.2}],Text["Region 5",{0.5,0.2}],,Text["Region 4",{0.9,0.2}]}]

Export["regionsredux.pdf",%,"PDF"]

Export["regionsredux.eps",%%,"EPS"]

u[x_,t_]:=Piecewise[{{0,x+2t<1/4},{4t,(1/4<x-2t<3/4)&&(1/4<x+2t<3/4)},{0,3/4<x-2t},{3/4-x+2t,(1/4<x-2t<3/4)&&(3/4<x+2t)},{1/2,(x-2t<1/4)&&(3/4<x+2t)},{x+2t-1/4,(x-2t<1/4)&&(1/4<x+2t<3/4)}}]

Plot[u[x,1/2],{x,0,1}]

Plot[Evaluate[Table[u[x,t],{t,0,1/4,1/32}]],{x,0,1},AxesLabel->{"x","u"}]