Sections24-01.mws

Unit 5: Boundary Value Problems for Partial Differential Equations

Chapter 24: Wave Equation

Sections24.1: the plucked string

Copyright

Copyright * 2001 by Addison Wesley Longman, Inc.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Initializations

> restart;

> interface(showassumed=0);
assume(n,integer);

> with(plots):
with(plottools):

Warning, the name changecoords has been redefined

>

The following Maple code defines the PX command which creates a periodic extension of a function. See lesson 2-4-1 for details of installation and behavior.

> PX := proc(h, g)
local f, var, d;
if type(h, procedure) then RETURN(subs(
{'D' = rhs(g) - lhs(g), 'F' = h, 'L' = lhs(g)}, proc(
x::algebraic)
local y;
y := floor((x - L)/D); F(x - y*D)
end))
fi;
if type(g, equation) then var := lhs(g); d := rhs(g) fi;
f := unapply(h, var);
subs({'L' = lhs(d), 'D' = rhs(d) - lhs(d), 'F' = f}, proc(
x::algebraic)
local y;
y := floor((x - L)/D); F(x - y*D)
end)
end:

>

Wave Equation on the Finite String

An idealized string, uniform and without internal friction, is stretched along an x -axis from to x = L . The ends are fixed, the string is taut, and it is constrained to move in a vertical plane. The equilibrium position for the string coincides with the interval [0, L] on the x -axis, and displacements in the string are measured vertically by u . At time t , and at location x in [0, L] , the displacement of the string from equilibrium is u(x,t) . For fixed t = t^`^` , the shape of the string is given by u(x,t^`^`) .

Figure 24.1, below, shows the shape of the string at a particular instant t^`^` `>`*0 .

> p1 := plot(x*(1-x),x=0..1,color=black):
p2 := textplot([1,-.05,`L`], font=[TIMES,ITALIC,12]):
p3 := arrow([.5,.09],[.5,0],.01,.03,.2,color=black):
p4 := arrow([.5,.16],[.5,.25],.01,.03,.2,color=black):
p5 := textplot([.5,.125,`u(x,t)`]):
### WARNING: note that `I` is no longer of type `^`
p6 := textplot([.525,.136,`^`]):
display([p||(1..6)],scaling=constrained, labels=[x,u], xtickmarks=[-1,2], ytickmarks=[-1,1], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

Wave Equation (1) u[tt] = c^2*u[xx] for t*`>`*0

fixed left end (2) u(0,t) = 0

fixed right end (3) u(L,t) = 0

initial shape (4) u(x,0) = f(x)

initial velocity (5) u[t](x,0) = g(x)

__________________________________________________

Table 24.1

As we will derive in Sections24.4, displacements in the string are governed by u[tt] = c^2*u[xx] , the wave equation (1) in Table 24.1. This is a partial differential equation (PDE) in the two independent variables x and t . The parameter c will turn out to be the wave speed , the speed at which a disturbance can propagate horizontally along the string. The boundary conditions (2) and (3) in Table 24.1 assure that the endpoints of the string remain fized. Because they proscribe values of u at the endpoints, they are called Dirichlet conditions. Since the prescribed values are zero, these conditions are homogeneous Dirichlet conditions. The initial conditions (4) and (5) in Table 24.1 give the initial shape and velocity of the string. At first, we will take g(x) = 0 , so that the string is given a (small) initial displacement f(x) , and released. This corresponds to a gentle plucking of the string, much like the action in a harpsichord.

Together, the five equations in Table 24.1 constitute an initial-boundary value problem (or BVP) for the finite string. Our goal is to obtain a solution to this BVP, and to understand how the function u(x,t) so determined describes the physical motion of the string.

>

Example 24.1

We will show that u(x,t) = sin(x)*cos(3*t) is a solution to the BVP in Table 24.1 when c = 3, L = Pi, g(x) = 0 , and f(x) = sin(x) . A calculation shows

u[tt] = -9*sin(x)*cos(3*t)

and

c^2*u[xx] = 3^2*(-sin(x))*cos(3*t)

To implement this calculation in Maple, set c = 3 so c^2 = 9 in the equation

> q := diff(u(x,t),t,t) = 9*diff(u(x,t),x,x);

q := diff(u(x,t),`$`(t,2)) = 9*diff(u(x,t),`$`(x,2)...

>

Write u(x,t) as

> U := sin(x)*cos(3*t);

U := sin(x)*cos(3*t)

>

and make the substitution

> simplify(subs(u(x,t)=U,q));

-9*sin(x)*cos(3*t) = -9*sin(x)*cos(3*t)

>

Moreover, u(0,t) = u(Pi,t) = 0, as we see by

> eval(subs(x=0,U));

0

>

and

> eval(subs(x=Pi,U));

0

>

Finally, u(x,0) = sin(x) = f(x) , as we see by

> eval(subs(t=0,U));

sin(x)

>

Figure 24.2 consisting of Figures 24.2a and 24.2 b, shows the shape of the string at two different times.

Figure 24.2a is

> U := sin(x)*cos(3*t):
p1 := plot(subs(t=.3,U),x=0..Pi,color=black, scaling=constrained, xtickmarks=[0], ytickmarks=[-1,1], labels=[x,u], labelfont=[TIMES,ITALIC,12]):
p2 := textplot([Pi,-.1,`p`],font=[SYMBOL,10]):
p3 := textplot([2.7,.56,`t = .3`]):
display([p||(1..3)]);

[Maple Plot]

>

and Figure 24.2b is

> p1 := plot(subs(t=1.5,U),x=0..Pi,color=black, scaling=constrained, xtickmarks=[0], ytickmarks=[-1,1], labels=[x,u], labelfont=[TIMES,ITALIC,12]):
p2 := textplot([Pi,-.1,`p`],font=[SYMBOL,10]):
p3 := textplot([2.7,-.25,`t = 1.5`]):
display([p||(1..3)]);

[Maple Plot]

>

Figure 24.3 shows the solution surface whereby u(x,t) is graphed as a surface in the xt -plane.

> p1 := plot3d(U,x=0..Pi,t=0..4*Pi/3, axes=frame, labels=[` x`,` t`,`u `], labelfont=[TIMES,ITALIC,12], color=red, style=hidden, tickmarks=[3,4,3], orientation=[45,60]):
p1;

[Maple Plot]

>

Figure 24.4 shows several snapshots of the string superimposed on the solution surface.

> F := z -> spacecurve([x,z,sin(x)*cos(3*z),x=0..Pi], color=black, thickness=3):
p2 := display3d([seq(F(2*Pi/30*k),k=0..20)]):
display3d([p1,p2],orientation=[25,80], scaling=constrained, axes=frame);

[Maple Plot]

>

The solution surface is traced out in time by a succession of moving images of the dynamic string, or equivalently, the plane sections of the solution surface are snapshots in time of the physical motion of the string. The obvious animation of the string tracing out the solution surface follows.

> p2 := display3d([seq(F(2*Pi/30*k),k=0..20)], insequence=true):
display3d([p1,p2],orientation=[25,80], scaling=constrained, axes=frame);

[Maple Plot]

>

Figures 24.3 and 24.4 show that the motion of the string is an example of a standing wave because the points of zero displacement do not translate along the string.

In fact, a complete animation of the motion of the string is given by

> animate(U,x=0..Pi,t=0..2*Pi/3, frames=20, color=black, labels=[x,u], labelfont=[TIMES,ITALIC,12], xtickmarks=3, ytickmarks=3);

[Maple Plot]

>

Example 24.2

A wave free to move along the string is called a traveling wave. Suppose the initial disturbance in the string has the shape shown in figure 24.5, below.

> g := x -> piecewise(x<3*Pi/8,0, x<Pi/2,x-3*Pi/8, x<5*Pi/8,Pi/8, x<3*Pi/4,3*Pi/4-x,0):
plot(g,0..Pi, scaling=constrained, labels=[x,u], labelfont=[TIMES,ITALIC,12], xtickmarks=3, ytickmarks=[0,.4]);

[Maple Plot]

>

Under the action of the wave equation, that initial disturbance would travel along the string, reflecting at the endpoints, and bouncing back and forth between between them. Figure 24.6 (consisting of Figures 24.6a and 24.6b) shows the traveling wave at two successive times after t = 0 .

Figure 24.6a is

> g1 := piecewise(x<0,-g(-x), x<Pi,g(x)):
G := PX(g1,x=-Pi..Pi):
U1 := (G(x-t)+G(x+t))/2:
pp1:=plot(subs(t=.7,U1),x=0..Pi,color=red,xtickmarks=3, ytickmarks=[-.4,0,.4], scaling=constrained, view=[0..Pi,-.4.. .4]):
pp2 := textplot([2.9,.3,`t = .7`]):
display([pp1,pp2], labels=[x,u], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

while Figure 24.6b is

> pp3 := plot(subs(t=1.47,U1),x=0..Pi, color=red, xtickmarks=3, ytickmarks=[-.4,0,.4], scaling=constrained, view=[0..Pi,-.4.. .4]):
pp4:=textplot([2.9,.3,`t = 1.47`]):
display([pp3,pp4], labels=[x,u], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

The complete animation showing how the initial energy in the string is distributed under the action of the wave equation is given by

> g1 := piecewise(x<0,-g(-x), x<Pi,g(x)):
G := PX(g1,x=-Pi..Pi):
U1 := (G(x-t)+G(x+t))/2:
animate(U1,x=0..Pi,t=0..2*Pi, frames=63, color=red, scaling=constrained, labels=[x,u], labelfont=[TIMES,ITALIC,12], xtickmarks=3, ytickmarks=[-.4,0,.4]);

[Maple Plot]

>

The initial energy splits into two equal parts, with each new wave traveling in opposite directions. When the wave reaches the boundary, it is absorbed, and then re-transmitted, only now, with a reflection. Figure 24.7 shows the solutoin surface for the traveling wave.

> plot3d(U1,x=0..Pi,t=0..2*Pi,axes=boxed, labels=[x,t,u], labelfont=[TIMES,ITALIC,12], color=black, style=hidden, shading=zgrayscale, tickmarks=[[0,1,2,3],5,[0]], grid=[25,50], scaling=constrained, orientation=[50,60]);

>

[Maple Plot]

>

The initial disturbance splits into two waves of half the initial height, one traveling left, and one traveling right. Without changing shape, these waves move in the xt -plane along characteristics , the lines x + c*t = constant, which are therefore said to "carry the initial information."

A more dynamic view of the propagation of the initial shape is given by the following animation.

> ff := z -> spacecurve([x,z,subs(t=z,U1),x=0..Pi], color=black, thickness=3, tickmarks=[2,2,[0]]):
display3d([seq(ff(2*Pi/50*k),k=0..50)], insequence=true, axes=boxed, labels=[x,t,u], labelfont=[TIMES,ITALIC,14], scaling=constrained, orientation=[55,65]);

[Maple Plot]

>

Solution by Separation of Variables

The classical method of solution for such BVPs is the method of separation of variables . Assume a solution of the separated form

u(x,t) = X(x)*T(t)

a product of one function just containing x and one function just containing t . Recall the initial example

u(x,t) = sin(x)*cos(3*t)

from above.

Now, generalize this to the product u(x,t) = X(x)*T(t) , that is, to

> U := X(x)*T(t);

U := X(x)*T(t)

>

to which we next apply the fixed endpoint conditions, obtaining

X(0)*T(t) = 0

and

X(L)*T(t) = 0

that is,

> subs(x=0,U) = 0;
subs(x=L,U) = 0;

X(0)*T(t) = 0

X(L)*T(t) = 0

>

Ruling out the choice T(t) = 0 because that implies u(x,t) = 0 (identically), we conclude X(0) = X(L) = 0.

Under the assumption of a separated solution, the initial conditions become

u(x,0) = X(x)*T(0) = f(x)

ans

u[t](x,0) = X(x) T'(0) = g(x)

Unless either f(x) or g(x) is zero, no conclusion can be drawn from these two equations. Assuming for simplicity that the initial velocity is zero, so that g(x) = 0 , we conclude

u[t](x,0) = X(x) T'(0) = 0 => T'(0) = 0

The initial condition u(x,0) = f(x) can be satisfied with the aid of a Fourier series. Before we can see that, we must apply the separation assumption to the PDE itself, namely

> q := diff(u(x,t),t,t) = c^2*diff(u(x,t),x,x);

q := diff(u(x,t),`$`(t,2)) = c^2*diff(u(x,t),`$`(x,...

>

giving

X(x)*`T''`(t) = c^2*`X''`(x)*T(t)

that is,

> q1 := eval(subs(u(x,t)=U,q));

q1 := X(x)*diff(T(t),`$`(t,2)) = c^2*diff(X(x),`$`(...

>

We have just deliberately committed a notational no-no. The derivatives on the left are with respect to t , while the derivatives on the right are with respect to x . Yet, we have used the same symbol for each differentiation, a mathematical imprecision and ambiguity that is too convenient to avoid.

Next, divide by c^2*u(x,t) , with u(x,t) in the form

u(x,t) = X(x)*T(t)

This general strategy, which seems to work with linear second-order PDEs, gives

`T''`(t)/(c^2)/T(t) = `X''`(x)/X(x)

that is,

> q2 := q1/(c^2*U);

q2 := diff(T(t),`$`(t,2))/(c^2*T(t)) = diff(X(x),`$...

>

the separated form of the PDE wherein each side of the equation is a function of only one of the variables. Since on the left there is a function purely of t , and on the right, a function purely of x , and these two functions must be equal for all values of x and t , each must be equal to the same constant.

This argument is generally not transparent to the novice. Consider the following. Student A is asked to state a "favorite function of t ." Student B is asked to state a "favorite function of x ." Typically, the functions now written on the board are something like t^2 and sin(x) . Student C is asked to select a "favorite value of t ," and student D is asked for a "favorite value of x ." The functions t^2 and sin(x) are now computed at values such as t = 1 and x = Pi . The students then realize that because 1^2 <> sin(Pi) = 0, the only way for a function of t to equal, consistently, a function of x is for the two functions to be the same constant function.

This constant is typically taken as lambda and is called the Bernoulli separation constant . Hence, we have the two ordinary differential equations

`X''`(x)/X(x) = lambda

and

`T''`(t)/(c^2)/T(t) = lambda

which, together with the relevant data, form the two problems

`X''`(x)-lambda*X(x) = 0

X(0) = X(L) = 0

and

`T''`(t)-c^2*lambda*T(t) = 0

`T'`(0) = 0

The first problem is a Sturm-Liouville eigenvalue problem, while the second is a modified initial value problem.

Obtaining the two separated ordinary differential equations in Maple is not a simple task. For example, we begin with

> q3 := rhs(q2) = lambda;
q4 := lhs(q2) = lambda;

q3 := diff(X(x),`$`(x,2))/X(x) = lambda

q4 := diff(T(t),`$`(t,2))/(c^2*T(t)) = lambda

>

Then, re-arranging, we get

> q5 := lhs(X(x)*q3) - rhs(X(x)*q3) = 0;
q6 := lhs(c^2*T(t)*q4) - rhs(c^2*T(t)*q4) = 0;

q5 := diff(X(x),`$`(x,2))-X(x)*lambda = 0

q6 := diff(T(t),`$`(t,2))-c^2*T(t)*lambda = 0

>

In effect, we did all the work. Maple really only played the role of bookkeeper, because it does not have any built-in code for performing manipulations of this type.

The solution of this Sturm-Liouville eigenvalue problem, obtained in Sections16.1, is

X[n](x) = B[n]*sin(n*Pi*x/L)

with eigenvalues

lambda[n] = -n^2*Pi^2/(L^2), n = 1, 2, `...`

Again, Maple presently does not have the tools with which to construct these solutions, so we enter them as

> Xn := B[n]*sin(n*Pi*x/L);

Xn := B[n]*sin(n*Pi*x/L)

>

with eigenvalues given by

> lambda[n] := -(n*Pi/L)^2;

lambda[n] := -n^2*Pi^2/(L^2)

>

for n = 1, 2 , ....

For each value of n , the function T( t ) is the solution of

`T''`(t)+c^2 n^2*Pi^2/(L^2) T(t) = 0

`T'`(0) = 0

so we write

T[n](t) = C[n]*cos(c*n*Pi*t/L)

a solution we obtain in Maple by writing the differential equation as

> q7 := subs(lambda=lambda[n],q6);

q7 := diff(T(t),`$`(t,2))+c^2*T(t)*n^2*Pi^2/(L^2) =...

>

then solving with

> q8 := dsolve({q7,D(T)(0)=0},T(t));

q8 := T(t) = _C2*cos(Pi*n*c*t/L)

>

Emphasizing the dependence on n , we write

> Tn := subs(_C2=C[n],rhs(q8));

Tn := C[n]*cos(Pi*n*c*t/L)

>

( Caution : If Maple uses _C1 instead of _C2 for the constant of integration, please adjust the worksheet accordingly.)

A single eigenfunction, u[n](x,t) is therefore the product

u[n](x,t) = B[n]*sin(n*Pi*x/L)*C[n]*cos(c*n*Pi*t/L)...

that is,

> Un := Xn*Tn;

Un := B[n]*sin(n*Pi*x/L)*C[n]*cos(Pi*n*c*t/L)

>

which contains two constants where only one is needed. Hence, replace the product B[n]*C[n] with the single constant b[n] via

> un := algsubs(B[n]*C[n]=b[n],Un);

un := sin(n*Pi*x/L)*cos(Pi*n*c*t/L)*b[n]

>

The set of eigensolutions {u[n]} can be thought of as the analog of a fundamental set for a linear ODE. The general solution of a linear ODE is a linear combination of all the members of the fundamental set. Similarly, the most general solution of the linear PDE is a linear combination of all the members of its "fundamental set," namely, the set of eigensolutions {u[n](x,t)} .

Since there are an infinite number of eigensolutions, our general solution is the infinite sum

u(x,t) = Sum(u[n](x,t),n = 1 .. infinity) = Sum(b[n]*sin(n*Pi*x/L)*cos(c*n*Pi*t/L),n = 1 .. inf...

that is,

> U := Sum(un,n=1..infinity);

U := Sum(sin(n*Pi*x/L)*cos(Pi*n*c*t/L)*b[n],n = 1 ....

>

The final condition to be applied in this BVP is the initial shape requirement,

u(x,0) = Sum(b[n]*sin(n*Pi*x/L),n = 1 .. infinity) = f(x)

that is,

> simplify(subs(t=0,U)) = f(x);

Sum(sin(n*Pi*x/L)*b[n],n = 1 .. infinity) = f(x)

>

The coefficients b[n] must therefore be the Fourier sine series coefficients for the function f(x) . There is no other choice for these constants if this final condition is to be satisfied. If f(x) is to be equal to a sum of sine terms, then the coefficients in that sum must be the Fourier sine series coefficients. Therefore, the b[n] 's are determined by the Fourier sine series formulas

b[n] = 2/L Int(f(x)*sin(n*Pi*x/L),x = 0 .. L)

and the solution u(x,t) is given by the infinite series

u(x,t) = Sum(b[n]*sin(n*Pi*x/L)*cos(c*n*Pi*t/L),n =...

This infinite sum, along with the defining integrals for the b[n] , constitutes the formal solution to the given BVP for the finite plucked string.

>

Example 24.3

A string of length L = Pi has its ends fixed at x = 0 , and x = Pi on an x -axis. The string is under tension, so that when it is given the initial shape f(x) = x*(Pi-x)/10 , as shown in Figure 24.8 (below), and released, it oscillates. We solve for the motion of the string at any time t*`>`*0 .

The associated BVP that models the motion of this string is

u[tt](x,t) = c^2*u[xx](x,t) , t > 0

u(0,t) = 0

u(pi,t) = 0

u(x,0) = f(x) = x*(Pi-x)/10

u[t](x,0) = 0

The solution, given by

u(x,t) = Sum(b[n]*sin(n*Pi*x/L)*cos(c*n*Pi*t/L),n =...

and

b[n] = 2/L Int(f(x)*sin(n*Pi*x/L),x = 0 .. L)

is implemented in Maple as follows. The initial shape function is

> f := x*(Pi-x)/10;

f := 1/10*x*(Pi-x)

>

and Figure 24.8 (which shows its graph) is

> plot(f,x=0..Pi,color=black, scaling=constrained, xtickmarks=3, ytickmarks=2, labels=[x,u], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

The Fourier coefficients are given by the integral

> q := (2/Pi)*Int(f*sin(n*x),x=0..Pi);

q := 2*Int(1/10*x*(Pi-x)*sin(n*x),x = 0 .. Pi)/Pi

>

whose value is

> b := simplify(value(q));

b := -2/5*((-1)^n-1)/(Pi*n^3)

>

A peek at the first ten coefficients

> seq(subs(n=k,b),k=1..10);

4/5*1/Pi, 0, 4/135*1/Pi, 0, 4/625*1/Pi, 0, 4/1715*1...

>

reveals that the odd-indexed terms "survive," the even-indexed terms are zero. Moreover, the coefficients rapidly converge to zero for this function. In fact, they go to zero as 1/(n^3) , a rapid decrease, as the following conversion to floating point numbers shows.

> seq(evalf(subs(n=k,b)),k=1..10);

.2546479089, 0., .9431404033e-2, 0., .2037183271e-2...

>

Hence, a very few terms will be needed to get a good approximation to u(x,t) . We can test this by examining how many terms it takes to get the Fourier series of f(x) to approximate f(x) well. The first two distinct partial sums in the Fourier series for f(x) are

> p1 := sum(b*sin(n*x),n=1..1);
p3 := sum(b*sin(n*x),n=1..3);

p1 := 4/5*sin(x)/Pi

p3 := 4/5*sin(x)/Pi+4/135*sin(3*x)/Pi

>

with f(x) (thin black) and p[1] (thick red) shown in Figure 24.9, below.

> plot([f,p1],x=0..Pi,color=[black,red], thickness=[1,3], scaling=constrained, xtickmarks=3, ytickmarks=2, labels=[x,u], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

This experiment suggests that two terms of the series for u(x,t) might yield a reasonably good approximation, so write

U = sum(b[n]*sin(n*x)*cos(c*n*t),n = 1 .. 3) = 4/135/Pi ``(27*sin(x)*cos(c*t)+sin(3*x)*cos(3*c*t))

that is,

> U := sum(b*sin(n*x)*cos(c*n*t),n=1..3);

U := 4/5*sin(x)*cos(c*t)/Pi+4/135*sin(3*x)*cos(3*c*...

>

as an approximation to the solution. Set c = 1 , that is,

> U1 := subs(c=1,U);

U1 := 4/5*sin(x)*cos(t)/Pi+4/135*sin(3*x)*cos(3*t)/...

>

to obtain the graph of the solution surface seen in Figure 24.10, below.

> plot3d(U1, x=0..Pi, t=0..4*Pi, axes=frame, labels=[x,`t `,`u `], labelfont=[TIMES,ITALIC,12], style=hidden, color=red, tickmarks=[3,6,3], orientation=[-45,60]);

[Maple Plot]

>

The plane sections t = t[k] are snapshots in time, freezing the physical motion of the string for each value of t[k] . Exhibiting these shapshots in succession forms a movie, or animation, of the physical motion of the string. This animation is given by the following Maple command.

> animate(U1,x=0..Pi,t=0..2*Pi, frames=60, color=black, scaling=constrained, xtickmarks=3, ytickmarks=2, labels=[x,`u `], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

As the string moves in space-time, its history generates a surface, a small part of which we now animate.

>

> F := z -> plot3d(U1, x=0..Pi, t=0..z):
display3d([seq(F(Pi/10*k),k=1..30)],insequence=true, axes=boxed, labels=[x,t,u], labelfont=[TIMES,ITALIC,12], style=hidden, color=red, tickmarks=[3,5,3]);

[Maple Plot]

>