<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout bullet="dot" leftmargin="0.0" name="_pstyle31" rightmargin="0.0" spaceabove="3.0" spacebelow="3.0"/><Layout leftmargin="0.0" name="_pstyle28" rightmargin="0.0"/><Layout leftmargin="0.0" name="_pstyle27" rightmargin="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" name="_pstyle26" rightmargin="0.0" spaceabove="8.0" spacebelow="4.0"/><Layout leftmargin="0.0" name="_pstyle25" rightmargin="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle24" rightmargin="0.0" spaceabove="8.0" spacebelow="4.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle23" rightmargin="0.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle22" rightmargin="0.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle21" rightmargin="0.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle20" rightmargin="0.0"/><Layout leftmargin="0.0" name="Normal" rightmargin="0.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle19" rightmargin="0.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle18" rightmargin="0.0"/><Layout leftmargin="0.0" name="_pstyle17" rightmargin="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle14" rightmargin="0.0" spaceabove="8.0" spacebelow="2.0"/><Layout alignment="centred" leftmargin="0.0" name="_pstyle13" rightmargin="0.0" spaceabove="12.0" spacebelow="12.0"/><Layout leftmargin="0.0" name="_pstyle33" rightmargin="0.0"/><Layout leftmargin="0.0" name="_pstyle32" rightmargin="0.0"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="2D Math" readonly="false" underline="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="2D Comment" readonly="false" underline="false"/><Font background="[0,0,0]" family="Times New Roman" name="Page Number" underline="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="ParagraphStyle3" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="ParagraphStyle2" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" executable="false" name="ParagraphStyle1" readonly="false"/><Font background="[0,0,0]" executable="false" foreground="[0,128,128]" italic="false" name="Hyperlink" readonly="false" underline="true"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle33" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle32" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" name="_cstyle31" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" name="_cstyle30" readonly="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Monospaced" foreground="[255,0,0]" name="_cstyle29" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle28" readonly="false" underline="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle27" readonly="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" italic="false" name="_cstyle25" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" name="_cstyle24" readonly="false" size="18"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="_cstyle23" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle22" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle21" readonly="false" size="18" underline="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle20" readonly="false"/><Font background="[0,0,0]" executable="false" name="_pstyle33" readonly="false"/><Font background="[0,0,0]" executable="false" name="_pstyle32" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle19" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle18" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle17" readonly="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="_cstyle16" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Text" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle13" readonly="false" size="14" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" name="_cstyle12" readonly="false" size="18" underline="true"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="_pstyle28" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle27" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" executable="false" name="_pstyle25" readonly="false"/><Font background="[0,0,0]" executable="false" name="_pstyle17" readonly="false"/></Styles><Page-Numbers enabled="false" first-number="1" first-numbered-page="1" horizontal-location="right" style="Page Number" vertical-location="bottom"/><Group><Input><Text-field layout="_pstyle13" style="_cstyle12">Partial Differential Equations</Text-field><Text-field layout="_pstyle14" style="_cstyle13">The vibrating string: d'Alembert's formula.</Text-field><Text-field layout="_pstyle17" style="_pstyle17"/><Text-field layout="_pstyle18" style="Hyperlink"><Hyperlink family="Times New Roman" hyperlink="true" linktarget="http://www.math.lsa.umich.edu/~adzham/" style="Hyperlink">Anton Dzhamay</Hyperlink></Text-field><Text-field layout="_pstyle18" style="Hyperlink"><Hyperlink family="Times New Roman" hyperlink="true" linktarget="http://www.math.lsa.umich.edu/" style="Hyperlink">Department of Mathematics</Hyperlink></Text-field><Text-field layout="_pstyle18" style="Hyperlink"><Hyperlink family="Times New Roman" hyperlink="true" linktarget="http://www.umich.edu/" style="Hyperlink">The University of Michigan</Hyperlink></Text-field><Text-field layout="_pstyle19" style="_cstyle16">Ann Arbor, MI 48109</Text-field><Text-field layout="_pstyle17" style="_pstyle17"/><Text-field layout="_pstyle20" style="ParagraphStyle1"><Font style="_cstyle17">wPage: </Font><Hyperlink family="Times New Roman" hyperlink="true" linktarget="http://www.math.lsa.umich.edu/~adzham/" style="Hyperlink">http://www.math.lsa.umich.edu/~adzham</Hyperlink></Text-field><Text-field layout="_pstyle21" style="ParagraphStyle1"><Font style="_cstyle18">email: </Font><Hyperlink family="Times New Roman" hyperlink="true" linktarget="mailto:adzham@umich.edu" style="Hyperlink">adzham@umich.edu</Hyperlink></Text-field><Text-field layout="_pstyle17" style="_pstyle17"/><Text-field layout="_pstyle22" style="_cstyle19"><Font encoding="ISO8859-1">Copyright \251  2004  by Anton Dzhamay</Font></Text-field><Text-field layout="_pstyle23" style="_cstyle20">All rights reserved</Text-field><Text-field layout="_pstyle17" style="_pstyle17"/></Input></Group><Section collapsed="true"><Title><Text-field layout="_pstyle24" style="_cstyle21">Packages</Text-field></Title><Group><Input><Text-field layout="_pstyle25" style="_cstyle22">Some packages that we use in this worksheet:</Text-field><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">restart: with(plottools): with(plots):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_pstyle25"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Introduction</Text-field></Title><Text-field layout="_pstyle27" style="ParagraphStyle2"><Font style="Text">The goal of this worksheet is to illustrate the use of the method of characteristics and d'Alembert's formula for the one-dimentional wave equation (i.e., the vibrating string). The equation is </Font><Equation input-equation="diff(u(x, t), `$`(t, 2)) = c^2*(diff(u(x, t), `$`(x, 2)))" style="2D Math">NiMvLSUlZGlmZkc2JC0lInVHNiQlInhHJSJ0Ry0lIiRHNiRGKyIiIyomJSJjR0YvLUYlNiRGJy1GLTYkRipGLyIiIg==</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text">. Since the equation is second order in </Font><Equation input-equation="t" style="2D Math">NiMlInRH</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text">, we need to specify the initial position </Font><Equation input-equation="u(x,0) = f(x)" style="2D Math">NiMvLSUidUc2JCUieEciIiEtJSJmRzYjRic=</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> and the initial velocity </Font><Equation input-equation="diff(u(x,0),t) = g(x);" style="2D Comment">NiMvLSUlZGlmZkc2JC0lInVHNiQlInhHIiIhJSJ0Ry0lImdHNiNGKg==</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Comment"> </Font><Font style="Text">. If we consider this equation on the whole real line, then we do not need to worry about boundary conditions and the solution is given by the d'Alembert's formula:</Font></Text-field><Text-field layout="_pstyle27" style="_pstyle27"/><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">u:=(x,t)-&gt;(f(x-c*t)+f(x+c*t))/2+int(1/(2*c)*g(v),v=x-c*t..x+c*t);</Text-field></Input></Group><Text-field layout="_pstyle27" style="Text">For semi-infinite and finite intervals with homogeneous Dirichlet or Neumann boundary conditions the strategy is to extend the initial data to the whole real line in such a way that the boundary conditions are satisfied. It turns out that one has to take the odd extension about the boundary point for the Dirichlet boundary condition and the even extension for the Neumann boundary condition. In the examples below we illustrate this technique.</Text-field><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Text-field layout="_pstyle27" style="_pstyle27"/></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Initialization</Text-field></Title><Text-field layout="_pstyle27" style="ParagraphStyle2"><Font style="Text">First we initialize some of the variables. Below </Font><Equation input-equation="T" style="2D Math">NiMlIlRH</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> is the time interval we are interested in, </Font><Equation input-equation="nch" style="2D Math">NiMlJG5jaEc=</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> is the number of characteristic curves that we want to plot per unit interval, and </Font><Equation input-equation="ntsteps" style="2D Math">NiMlKG50c3RlcHNH</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> is the number of steps in the </Font><Equation input-equation="t" style="2D Math">NiMlInRH</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> variable.</Font></Text-field><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="Maple Input">c:=2: nch:=3: T:=3: ntsteps:=25:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">The shift command below allows us to combine the graph of the characteristics (which is two-dimensional) with the graph of the solution (three-dimensional).</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">shift:=transform((x,y)-&gt;[x,y,-0.1]):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">In order to satisfy different boundary conditions we need to take even and odd extensions of functions about </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> for half-line or about  </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> and </Font><Equation input-equation="x = L;" style="2D Comment">NiMvJSJ4RyUiTEc=</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> for a finite interval.</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle1"><Font style="_cstyle27">We define the </Font><Font style="_cstyle29">oddext0</Font><Font style="_cstyle27"> (</Font><Font style="_cstyle23">evenext0</Font><Font style="_cstyle27">) procedures that takes a function or an expression </Font><Font style="_cstyle30">expr</Font><Font style="_cstyle27"> in a variable </Font><Font style="_cstyle30">var</Font><Font style="_cstyle27"> and returns a functional operator in </Font><Font style="_cstyle30">var</Font><Font style="_cstyle27"> that is the odd (even) extension of </Font><Font style="_cstyle30">expr</Font><Font style="_cstyle27"> about the origin. </Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">oddext0:=proc(expr,var)
   unapply(signum(var)*unapply(expr,var)(abs(var)),var);
end proc:</Text-field><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">evenext0:=proc(expr,var)
   unapply(unapply(expr,var)(abs(var)),var);
end proc:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">The procedures for even, odd, and periodc extensions of fucntions over the finite interval are defined similarly.</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">pext:=proc(expr,var,L)
   unapply(unapply(expr,var)(var - floor((var+L)/(2*L))*2*L),var)
end proc:
oddext:=proc(expr,var,L)
   local x;
   x:=var - floor((var+L)/(2*L))*2*L;
   unapply(signum(x)*unapply(expr,var)(abs(x)),var)
end proc:
evenext:=proc(expr,var,L)
   local x;
   x:=var - floor((var+L)/(2*L))*2*L;
   unapply(unapply(expr,var)(abs(x)),var)
end proc:
</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_pstyle25"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 1: "Pick"</Text-field></Title><Text-field layout="_pstyle27" style="ParagraphStyle2"><Font style="Text">In this example we take </Font><Equation input-equation="g(x) = 0" style="2D Math">NiMvLSUiZ0c2IyUieEciIiE=</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> and take </Font><Equation input-equation="f(x)" style="2D Math">NiMtJSJmRzYjJSJ4Rw==</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> to look like a "guitar pick" (note that this function has discontinuous derivatives, and so the corresponding solution is the </Font><Font style="_cstyle31">weak</Font><Font style="Text"> solution):</Font></Text-field><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">f:=x-&gt;piecewise(x &lt; 1,0,x &lt; 2,x-1,x &lt; 3,3-x,0):g:=x-&gt;0:
plot([f(x),g(x)],x=-1..5,color=[red,green],thickness=2,
scaling=constrained,title="Initial Conditions",legend=["f(x)","g(x)"]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Now we can see how the initial profile changes in time:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=-1..5,color=red,thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true,title="Pick");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">The plot below helps to see how the initial profile splits into the left and right moving waves.</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">display([seq(plot([u(x,t/ntsteps),1/2*f(x-c*t/ntsteps),1/2*f(x+c*t/ntsteps)],x=-1..5,
color=[red,green,blue],thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">And this is how the graph of the solution looks like (from the top). We color it according to the height of the solution, and this makes it easy to see the left and right waves. The characteristics are plotted below, rotate the graph to see them.</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">char_r:=display([seq(plot([c*t+1/nch*x,t,t=0..T],color=red,thickness=1),x=-1*nch..5*nch)]):
char_l:=display([seq(plot([-c*t+1/nch*x,t,t=0..T],color=black,thickness=1),x=-1*nch..5*nch)]):</Text-field><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([plot3d(u(x,t),x=-1..5,t=0..T,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue),
shift(char_r),shift(char_l)],orientation=[-90,0],view=[-1..5,0..T,-0.1..1]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" style="_pstyle28"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 2: "Hammer Blow"</Text-field></Title><Text-field layout="_pstyle27" style="ParagraphStyle2"><Font style="Text">In this example we take </Font><Equation input-equation="f(x) = 0;" style="2D Math">NiMvLSUiZkc2IyUieEciIiE=</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> and take </Font><Equation input-equation="g(x);" style="2D Math">NiMtJSJnRzYjJSJ4Rw==</Equation><Font bold="false" foreground="[0,0,0]" italic="false" size="12" style="2D Math"> </Font><Font style="Text"> to represent kicking the string by a hammer:</Font></Text-field><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">f:=x-&gt;0:g:=x-&gt;piecewise(x &lt; 2,0,x &lt; 3,1,0):
plot([f(x),g(x)],x=-1..5,color=[red,green],thickness=2,
scaling=constrained,title="Initial Conditions",legend=["f(x)","g(x)"]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Now we can see how the initial profile changes in time (this calculation may take a while):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=-1..5,color=red,thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true,title="Hammer Blow");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">View from the top and the characteristics:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">char_r:=display([seq(plot([c*t+1/nch*x,t,t=0..T],color=red,thickness=1),x=-1*nch..5*nch)]):
char_l:=display([seq(plot([-c*t+1/nch*x,t,t=0..T],color=black,thickness=1),x=-1*nch..5*nch)]):</Text-field><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([plot3d(u(x,t),x=-1..5,t=0..T,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue),
shift(char_r),shift(char_l)],orientation=[-90,0],view=[-1..5,0..T,-0.1..0.3]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Note that there are different (color) zones, in each of these zones the solution is given by a different analytic formula.The following "close-up" picture helps to see the zones more clearly</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="Maple Input">display([plot3d(u(x,t),x=1.5..3.5,t=0..1,axes=boxed,numpoints=2000,
style=patchcontour,shading=zhue),
shift(char_r),shift(char_l)],orientation=[-90,0],view=[1.5..3.5,0..1,-0.1..0.3]);</Text-field></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 3: Left Wall (Dirichlet BC)</Text-field></Title><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">In order to satisfy the Dirichlet BC at </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> we need to extend our functions from the right half-line to the whole line by taking the </Font><Font style="_cstyle30">odd</Font><Font style="_cstyle27"> extension about 0.  </Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">ff:=piecewise(x &lt; 1,0,x &lt; 2,x-1,x &lt; 3,3-x,0):g:=x-&gt;0:
f:=oddext0(ff,x):
plot([ff(x),f(x)],x=-5..5,color=[red,green],thickness=2,
scaling=constrained,title="f(x) and its odd extension");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">f(x);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Now we can see how the initial profile changes in time:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">T:=4:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=0..5,color=red,thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true,title="Left Wall (Dirichlet)");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">It looks like the left-moving wave hits the wall and gets flipped and reflected. Note that </Font><Equation input-equation="u(0,t) = 0;" style="2D Comment">NiMvLSUidUc2JCIiISUidEdGJw==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> for all </Font><Equation input-equation="t;" style="2D Comment">NiMlInRH</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27">. Peeking "behind" the wall we see the "image" right-moving wave emerging from the wall simultaneously with the left-moving wave disappearing into the wall:</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">movie:=display([seq(plot([u(x,t/ntsteps),1/2*f(x-c*t/ntsteps),1/2*f(x+c*t/ntsteps)],x=-5..5,
color=[red,green,blue],thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">display([movie,rectangle([-5,5],[0,-5],color=grey)],view=[-3..5,-1..1],title="Left Wall (Dirichlet)");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">And this is how the graph of the solution looks like (from the top). </Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">plot3d(u(x,t),x=0..5,t=0..T,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue,orientation=[-90,0]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" style="_pstyle28"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 4: Left Wall (Neumann BC)</Text-field></Title><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">In order to satisfy the Neumann BC at </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> we need to extend our functions from the right half-line to the whole line by taking the even extension about </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27">.</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">ff:=x-&gt;piecewise(x &lt; 1,0,x &lt; 2,x-1,x &lt; 3,3-x,0):g:=x-&gt;0:
f:=evenext0(ff(x),x):
plot([ff(x),f(x)],x=-5..5,color=[red,green],thickness=2,numpoints=2000,
scaling=constrained,title="f(x) and its even extension");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">T:=4:</Text-field><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=0..5,color=red,thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true,title="Left Wall (Neumann)");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Again, let's "peek" behind the wall:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">movie:=display([seq(plot([u(x,t/ntsteps),1/2*f(x-c*t/ntsteps),1/2*f(x+c*t/ntsteps)],x=-5..5,
color=[red,green,blue],thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">display([movie,rectangle([-5,5],[0,-5],color=grey)],view=[-3..5,-1..1],title="Left Wall (Neumann BC)");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">plot3d(u(x,t),x=0..5,t=0..T,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue,orientation=[-90,0]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" style="_pstyle28"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 5: Two Walls (Mixed)</Text-field></Title><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">In order to satisfy the Neumann BC at </Font><Equation input-equation="x = L;" style="2D Comment">NiMvJSJ4RyUiTEc=</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> we take an </Font><Font style="_cstyle30">even</Font><Font style="_cstyle27"> extension about </Font><Equation input-equation="x = L;" style="2D Comment">NiMvJSJ4RyUiTEc=</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> and then to satisfy the Dirichlet BC at </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> we take an </Font><Font style="_cstyle30">odd</Font><Font style="_cstyle27"> extension about the origin. This gives us the correct extension on the interval </Font><Equation input-equation="[-2*L, 2*L];" style="2D Comment">NiM3JCwkKiYiIiMiIiIlIkxHRichIiJGJQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27">, and then we extend it periodically to the whole real line. (In the example below </Font><Equation input-equation="L = 4;" style="2D Comment">NiMvJSJMRyIiJQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27">.) This is a very non-optimal way to define such an extension, but it is enough for our purposes.</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">ff:=x-&gt;piecewise(x &lt; 1,0,x &lt; 2,x-1,x &lt; 3,3-x,0):g:=x-&gt;0:
f:=pext(oddext0(evenext(ff(x),x,4)(x),x)(x),x,8):
plot([ff(x),f(x)],x=-10..10,color=[red,green],thickness=2,
scaling=constrained,title="f(x) and its extension");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Now we can see how the initial profile changes in time:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">T:=8: ntsteps:=15:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=0..4,color=red,thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true,title="Left Dirichlet and Right Neumann BC");</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">"Peeking behind the walls" shows us the left and right moving waves:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">movie:=display([seq(plot([u(x,t/ntsteps),1/2*f(x-c*t/ntsteps),1/2*f(x+c*t/ntsteps)],x=-5..9,
color=[red,green,blue],thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">display([movie,rectangle([-5,5],[0,-5],color=grey),
rectangle([4,5],[9,-5],color=grey)],view=[-5..9,-1..1]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">Looking at the graph of the solution (from the top) we can see the characteristics "bounching off the walls":</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">plot3d(u(x,t),x=0..4,t=0..T,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue,orientation=[-90,0]);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" style="_pstyle28"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Example 6: Two Walls (Dirichlet)</Text-field></Title><Group><Input><Text-field layout="_pstyle25" style="ParagraphStyle3"><Font style="_cstyle27">This time we need to take the </Font><Font style="_cstyle30">odd</Font><Font style="_cstyle27"> extension of </Font><Equation input-equation="f(x);" style="2D Comment">NiMtJSJmRzYjJSJ4Rw==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> about both </Font><Equation input-equation="x = 0;" style="2D Comment">NiMvJSJ4RyIiIQ==</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27"> and </Font><Equation input-equation="x = L;" style="2D Comment">NiMvJSJ4RyUiTEc=</Equation><Font style="_cstyle28"> </Font><Font style="_cstyle27">. </Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">ff:=x-&gt;x^2*(1-x):g:=x-&gt;0:
f:=oddext(ff(x),x,1):
plot([ff(x),f(x)],x=-3..3,color=[red,green],thickness=2,
scaling=constrained,title="f(x) and its odd extension",view=-1/2..1/2);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">T:=4:</Text-field><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">display([seq(plot(u(x,t/ntsteps),x=0..1,color=red,thickness=2),
t=0..T*ntsteps)],scaling=unconstrained,insequence=true);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" style="_cstyle27">And here are the left and right-waves (set animation to cycle for a better movie):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">movie:=display([seq(plot([u(x,t/ntsteps),1/2*f(x-c*t/ntsteps),1/2*f(x+c*t/ntsteps)],x=-2..3,
color=[red,green,blue],thickness=2),
t=0..T*ntsteps)],scaling=constrained,insequence=true):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle25" prompt="&gt; " style="_cstyle23">display([movie,rectangle([-5,0.2],[0,-0.2],color=grey),rectangle([1,0.2],[3,-0.2],color=grey)],
scaling=unconstrained);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle28" prompt="&gt; " style="_cstyle25">plot3d(u(x,t),x=0..1,t=0..3,axes=boxed,scaling=constrained,numpoints=2000,
style=patchnogrid,shading=zhue,orientation=[-90,0]);</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Group><Input><Text-field layout="_pstyle28" style="_pstyle28"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">References</Text-field></Title><Group><Input><Text-field layout="_pstyle31" style="_cstyle32">Walter A. Strauss, Partial Differential Equations: An Introduction, Wiley, 1992</Text-field><Text-field layout="_pstyle31" style="_cstyle32">Richard Haberman, Elementary Applied Partial Differential Equations, 3rd edition, Prentice Hall</Text-field></Input></Group><Text-field layout="_pstyle17" style="_pstyle17"/></Section><Section collapsed="true"><Title><Text-field layout="_pstyle26" style="_cstyle24">Disclaimer</Text-field></Title><Text-field layout="_pstyle17" style="_cstyle33">"While every effort has been made to validate the solutions in this worksheet, Waterloo Maple Inc. and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material." </Text-field></Section><Text-field layout="_pstyle32" style="_pstyle32"/><Text-field layout="_pstyle33" style="_pstyle33"/><Text-field/></Worksheet>