Maple in Mathematics Education II: Fourier Series & Wave Equation, 1-D Wave Equation Solutions
by David Canright, Math. Dept., Code MA/Ca, Naval Postgraduate School, Monterey, CA, dcanright@nps.navy.mil, 2000 David Canright.
Note: This worksheet allows exploration & plotting of Fourier Series solutions to the (one-dimensional) Wave Equation (using partial sums ).
:
, 0 < x < L
Introduction: Setting up the Worksheet
> restart;
> with(plots): need "plots" package for animation below
Section I: General Definitions for Wave Equation
Note: do this section only once (before L, a0, etc. are ever defined)
term: one term (#n) in series SN: partial sum (up to N) of series
Wave Equation: general definitions first define terms and partial sum of series solution in terms of Xn & Tn
> unassign('X0','T0','Xn','Tn','n','N');
> u0 := X0 * T0;
> un := Xn * Tn;
> u := u0 + 'sum( un, n=1..N )';
> vel := X0 * 'diff(T0,t)' + 'sum( Xn * diff(Tn,t), n=1..N )';
>
Section II: Define Eigenfunctions from Boundary Conditions
come back and redo this section for each different pair of Boundary Conditions
You have four choices; execute only one :
Section IIa: Either fixed-fixed: X(0) = X(L) = 0
> unassign('A0','B0','t','x','n','L','An','Bn','c','kn');
> X0 := 0;
> Xn := sin(kn*x);
> Tn := An*cos(kn*c*t) + Bn*sin(kn*c*t);
> kn := n*Pi/L;
define period of oscillation
> per := 2*L/c;
Now jump down to define particular Fourier Series
Section IIb: Or, free-free: X'(0) = X'(L) = 0
> X0 := 1/2;
> T0 := A0 + B0*t;
> Xn := cos(kn*x);
Section IIc: Or, fixed-free: X(0) = X'(L) = 0
> kn := (n-1/2)*Pi/L;
> per := 4*L/c;
Section IId: Or, free-fixed: X'(0) = X(L) = 0
Section III: Define Particular Fourier Series from Initial Conditions
come back and redo this section for each different Fourier Series
You have two choices :
If you know the functions f and g , use the first subsection
If you know the coefficients , use the second subsection
If you know f and g, and the coeffiecients, use either subsection
but do not do both !
Section IIIa: Either Calculate Coefficients by Integrals
If you know the function f and choose L, c
you can calculate the coefficients:
using the integral formulas
define particular function f (default example is from text) modify this definition for other series
> f := piecewise(x<1,x,2-x);
> g := 0;
choose L
> L := 2; c := 1;
Now evaluate the integrals to find the coefficients
Note: these steps must be done in order
> 2 / L * Int( f, x=0..L );
> value(%);
> A0 := %;
> 2 / L * Int( f * Xn, x=0..L );
> simplify(%,trig,assume=integer);
> An := %;
> 2 / L * Int( g, x=0..L ) ;
> B0 := %;
> 2 / (kn*c*L) * Int( g * Xn, x=0..L );
> Bn := %;
At this point, have defined the series, so skip down to the plots
Section IIIb: Or, Specify Coefficients: & L
You must first know the formula for each coefficient
define particular series coefficients and L, c modify these definitions to plot other series
> A0 := 0;
> An := 8*sin(n*Pi/2)/(n*Pi)^2;
> B0 := 0;
> Bn := 0;
define particular functions f and g (sum of series) modify this definition for other series
Note: if do not know f or g, set to 0;
> f := piecewise(x<1,x,2-x); g := 0;
At this point, have defined the series, so go on to the plots
Section IV: Plot Partial Sum and/or Terms of Series
try changing the parameters on any or all of these
choose N, check initial displacement:
> unassign('x'); t := 0; N := 10; plot( {u,f}, x=0 .. L);
choose N, check initial velocity:
> unassign('x','t'); N := 10; plot( subs(t=0,{vel,g}), x=0 .. L);
choose N, t to plot the partial sum u at some particular time (can use multiples of the period)
> unassign('x'); N := 10; t := per/3; plot( u, x=0 .. L);
choose N, t to plot the partial sum for velocity at some particular time
> unassign('x','t'); N := 10; plot( subs(t=per/3,vel), x=0 .. L);
choose N, t to plot the partial sum u over time at some position
> unassign('t'); N := 10; x := L/3; plot( u, t=0 .. per);
choose N, x to plot the partial sum for velocity over time at some position
> unassign('t'); N := 10; x := L/3; plot( vel, t=0 .. per);
Section V: Animate the Vibrating String
choose N, nf (# frames) to animate the partial sum u
> unassign('x','t'); N := 10; nf := 12; # choose number of frames per period
> animate( u, x=0..L, t=0..(1-1/nf)*per, frames=nf );
choose N, nf (# frames) to animate the partial sum for velocity
> animate( vel, x=0..L, t=0..(1-1/nf)*per, frames=nf );
choose N, nf (# frames) to animate the partial sum u and the terms
> unassign('x','t'); N := 3; nf := 24; # choose number of frames per period
> animate( {u, u0, seq(un,n=1..N)}, x=0..L, t=0..(1-1/nf)*per, frames=nf, axes=boxed ); unassign('n'):
Conclusion: This worksheet clearly demonstrates Maple's ability to be used as an Educational tool for advanced mathematical concepts.
Disclaimer: 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.