Maple A3
Maple A3
Maple A3
n p x An sin L n=1
approximates g(x). Consequently, An is the Fourier sine series coefficient for f (x) and sine series coefficient for g(x).
c n p Bn L
is the Fourier
The following entries define the functions f and g, calculate An and Bn, then create various solution curves. We assume that L = 1, c = 1 and the string is initially stretched "tent like" over the f(x) = piecewise(x < 0.5, 0.2 x, 0.2 (1 - x)) x axis with the shape
Set it into motion with a finger flick at a point one quarter of the way from the left endpoint g(t) = 0.1 d(t - 0.25) You may, of course, change these to fit any situation that you would like to explore. > L := 1: c := 1: f := x -> piecewise(x<L/2,2/5*x,2/5*(L-x)): g := x -> 1/10*Dirac(x - L/4):
1
An := 2/L*int(f(x)*sin(n*Pi*x/L), x=0..L): Bn := L/(c*n*Pi)*2/L*int(g(x)*sin(n*Pi*x/L), x=0..L): The following entry simplifies the formulas for An and Bn, then displays them. > C := [An,Bn] assuming n::integer: 'An'=C[1],'Bn'=C[2]; 1 1 2 -2 sin n p + cos n p n p 2 2 5n p
2 2
An = -
1 1 2 cos n p n p + 2 sin n p 2 2 5n p
2 2
, Bn =
1 sin n p 4 5np
This it the definition of U as a function of N, x, and t. > U := (N,x,t) -> sum((An*cos(c*n*Pi*t/L)+Bn*sin(c*n*Pi*t/L))*sin(n*Pi*x/L), n=1..N); N c n p t c n p t n p x An cos + Bn sin U := (N, x, t) sin L L L n=1
The first plot checks that the coefficients are correct for the velocily function function f is made when we plot U at t =0 below).
0.2
0.4 x
0.6
0.8
This curve is a typical approximation to a Dirac delta. The area under the curve is approximately 1/10. The plot of U(20,x,0) shows that the An coefficients are also correct. > plot( U(20,x,0), x=0..L, 0..0.25, ytickmarks=3, title="Initial Waveform");
Initial Waveform 0.2 0.1 0 0 0.2 0.4 0.6 0.8 1
Five snapshots, one every 0.2 seconds: > plot( [U(50,x,0.2*t)$t=0..5], x=0..L, color=red);
0.2 0.1 0 0 -0.1 -0.2 0.2 0.4 x 0.6 0.8 1
A movie (see the Help page for plots[animate]): > plots[animate]( plot, [ U(50,x,t), x=0..L ], t=0..2, frames=40);
t = .87179 0.2 0.1 0 -0.1 0 -0.2 0.2 0.4 x 0.6 0.8 1
The waveform surface > plot3d( U(50,x,t), x=0..L, t=0..2, axes=boxed, orientation=[-60,70], lightmodel=light2 );
0.8