Download Vibrating String Investigations

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Probability amplitude wikipedia , lookup

Wave function wikipedia , lookup

Renormalization group wikipedia , lookup

Wave packet wikipedia , lookup

Transcript
Project 9.6
Vibrating String Investigations
The d'Alembert solution
y( x , t ) =
1
2
[ F ( x + at ) + F ( x − at )]
(1)
of the vibrating string problem (with fixed endpoints and zero initial velocity on the
interval [0, L]) is readily implemented using a computer algebra system such as Maple,
Mathematica, or MATLAB. Recall that F(x) in (1) denotes the odd period 2L
extension of the string's initial position function f (x). A plot of y = y(x,t) for
0 ≤ x ≤ L with t fixed shows a snapshot of the string's position at time t.
y
t=0
2
t = pi 4
1
x
0.5
-1
-2
1
1.5
2
2.5
3
t = 3pi 4
t = pi
In the paragraphs that follow we illustrate the use of Maple, Mathematica, and
MATLAB to plot such snapshots for the vibrating string with initial position function
f ( x ) = 2 sin 2 x ,
0 ≤ x ≤ π.
(2)
We can illustrate the motion of this vibrating string by plotting a sequence of snapshots ,
either separately (as in Fig. 9.6.4 of the text) or on a single figure — as in the preceding
Project 9.6
261
figure. The apparent "flat spots" in the t = π/4 and t = 3π/4 snapshots are discussed in
Problem 23 of Section 9.6 in the text.
You can test your implementation of d'Alembert's method by attempting to
generate Figures 9.6.6 (for a string with triangular initial position) and 9.6.7 (for a string
with trapezoidal initial position) in the text. The initial position "bump function"
f ( x ) = sin 200 x ,
0 ≤ x ≤ π.
(3)
generates travelling waves traveling (initially) in opposite directions, as indicated in Fig.
9.6.3 in the text. The initial position function defined by
f ( x) =
sin
0
200
( x + 1.5) for 0 < x < π / 2,
for π / 2 < x < π .
(4)
generates a single wave that starts at x = 0 and (initially) travels to the right. (Think of a
jump rope tied to a tree, whose free end is initially "snapped".)
After exploring some of the possibilities indicated above, try some initial position
functions of you own choice. Any continuous function f such that f (0) = f(L) = 0
is fair game. The more exotic the resulting vibration of the string, the better.
Using Maple
To plot the snapshots shown simultaneously in the preceding figure, we start with the
string's initial position function f (x) defined by
f := x -> 2*sin(x)^2:
To define the odd period 2π extension F(x) of f (x), we need the following
function s(x) that shifts the point x by a multiple of π into the interval [–π, π].
s := proc(x)
local k;
k := floor(evalf(x/Pi)):
if type(k, even)
then evalf(x - k*Pi):
else evalf(x - k*Pi - Pi) fi
end:
Then the desired odd extension is defined by
F := proc(x)
if s(x) > 0 then f(s(x)) else -f(s(-x)) fi
end:
262
Chapter 9
Finally, the d'Alembert solution in (1) is defined by
G := (x,t) -> ( F(x+t) + F(x-t) )/2:
The command
plot('G(x,Pi/4)', x = 0..Pi);
now gives the t = π/4 snapshot exhibiting the apparent flat spot previously mentioned.
(The quotes are used to prevent premature evaluation during plotting.)
In order to plot the simultaneously the graphs for
t = 0, π / 12, π / 6, π / 4, π / 4, 5π / 12,
,π ,
we first define the snapshot showing the string's position at time t = nπ / 12 by means of
the function
fig := n -> plot('G(x,n*Pi/12)', x = 0..Pi):
Then the preceding figure, exhibiting simultaneously the successive positions of the
string in a single composite figure, is generated by the command
with(plots):
display([seq(fig(n), n = 0..12)]);
If we "restart" with the initial position function
f := proc(x)
if x < Pi/2 then x else Pi - x fi
end:
corresponding to the triangular wave function of Project 9.2, then we get in this way the
composite picture shown in Fig 9.6.6 of the text.
Similarly, the trapezoidal wave function
f := proc(x)
if x <= Pi/3 then x
elif x > Pi/3 and x < 2*Pi/3
then Pi/3
else Pi - x fi
end:
of Project 9.2 produces the picture shown in Fig. 9.6.7.
Project 9.6
263
Using Mathematica
To plot the snapshots shown simultaneously in the preceding figure, we start with the
string's initial position function f (x) defined by
f[x_] := 2 Sin[x]^2
To define the odd period 2π extension F(x) of f (x), we need the following
function s(x) that shifts the point x by a multiple of π into the interval [–π, π].
s[x_] := Block[{k}, k = Floor[N[x/Pi]];
If[EvenQ[k], (* k is even *)
(* then *)
N[x - k*Pi],
(* else *)
N[x - k*Pi - Pi]] ]
Then the desired odd extension of the initial position function is defined by
F[x_] := If[s[x] > 0, (* then *)
(* else *)
f[ s[x]],
-f[-s[x]] ]
Finally, the d'Alembert solution in (1) is
G[x_,t_] := (F[x+t] + F[x—t])/2
A snapshot of the position of the string at time t is plotted by
stringAt[t_] :=
Plot[G[x,t], {x,0,Pi}, PlotRange -> {-2,2}];
For example, the command
stringAt[Pi/4];
plots the t = π/4 snapshot exhibiting the apparent flat spot previously mentioned.
We can plot the simultaneously the graphs for
t = 0, π / 12, π / 6, π / 4, π / 4, 5π / 12,
,π ,
by defining a whole sequence of snapshots at once:
snapshots = Table[stringAt[t], {t,0,Pi,Pi/12}];
264
Chapter 9
These snapshots can be animated to show the vibrating string in motion, or we can
exhibit simultaneously the successive positions of the string in a single composite figure
(as shown previously) with the command
Show[snapshots];
The initial position function
f[x_] := If[ x < Pi/2, (* then *) x,
(* else *) Pi — x ] // N
corresponding to the triangular wave function of Project 9.2 generates in this way the
composite picture shown in Fig 9.6.6 of the text.
Similarly, the trapezoidal wave function
f[x_] := Which[
0 <= x < Pi/3,
x,
Pi/3 <= x < 2*Pi/3, Pi/3,
2*Pi/3 <= x <= Pi,
Pi — x ] // N
of Project 9.2 produces the picture shown in Fig. 9.6.7.
Using MATLAB
To plot the snapshots shown simultaneously in the preceding figure, we start with the
string's initial position function f (x) defined by
function y = f(x)
y = 2*sin(x).^2;
saved as the file f.m.
To define the odd period 2π extension F(x) of f (x), we need first to shift the
point x by a multiple of 2π to a point s in the interval [–π, π]. We then define F(x)
to be f (s) if s > 0, − f ( − s) if x < 0. This is accomplished by the function
function y = foddext(x)
% Odd period 2Pi extension of the function f
k = floor(x/pi);
q = ( 2*floor(k/2) ~= k ); % q = 0 if k even
s = x - (k+q)*pi;
% q = 1 if k odd
m = sign(s);
% if s>0 then y = f(s) else y = -f(-s)
y = m.*f(m.*s);
saved in the file oddext.m.
Project 9.6
265
The d'Alembert solution in (1) is now defined by
function y = G(x,t)
y = (foddext(x+t) + foddext(x-t))/2;
Then the commands
x = 0 : pi/300 : pi;
plot(x, G(x,pi/4))
plot the t = π/4 snapshot exhibiting the apparent flat spot previously mentioned. The
simple loop
for n = 0 : 12
plot(x, G(x, n*pi/12))
axis([0 pi -2 2]); hold on
end
finally generates the preceding composite figure that exhibits simultaneously the
successive positions of the vibrating string from t = 0 to t = π by steps of π/12.
The initial position function
function
y = f(x)
y = x.*(x < pi/2) + (pi-x).*(x >= pi/2);
corresponding to the triangular wave function of Project 9.2 generates in this way the
composite picture shown in Fig 9.6.6 of the text.
Similarly, the trapezoidal wave function
function y = f(x)
y = x.*(x <= pi/3) ...
+ (pi/3)*(x > pi/3 & x < 2*pi/3)...
+ (pi - x).*(x >= 2*pi/3);
of Project 9.2 produces the picture shown in Fig. 9.6.7.
266
Chapter 9