Here’s the problem: A straight string of length 1 is being displaced from its middle point to an amplitude 0.5 (see picture above). If the string is to be set free, what is the amplitude of every point as a function of time?
The string will satisfy the wave equation (for the proof see “D. J. Griffiths, Introduction to Electrodynamics, 3rd edition, Chapter 9”) or in equation form
where c is a constant that depends on the physical properties of the string. This amplitude function represents the amplitude of a point at particular time. The initial conditions are
because these are the edges of the strings, and
because there is no initial velocity.
We assume that the amplitude function is separable, namely
Then we can rewrite (1) as
Dividing both sides of (5) by (4), we get
where is a constant. The reason for that is that we have two functions in (5) which are always equal, yet they do not depend on the same variable. The only way for this to be possible is if they are both constant.
The general solution to equation
and the general solution to equation
Applying the boundary condition of equation (3) leads to the constant B of equation (8) to be zero. In addition, because of the boundary conditions of equation (2), the constant C of equation (10) must be zero and the constant must be equal to , where n is an integer. Therefore, we have the following particular solution of equation (1)
Due to the linearity of the differential operator, every equation of this form satisfies equation (1). So, we can construct a function of arbitrary form by adding enough functions of this type until they represent the one in the picture, whose equation is
hence the general solution of equation (1) is
where for it must be equal to equation (12) and (13). Equation (14) with has the form of a Fourier series with period 1. The coefficients can be found by exploiting the orthogonality of the sine functions if we multiply by and then integrate. After some calculations we get
and the complete solution is
A MATLAB function was written to visually depict the motion of the string. It takes as inputs the amplitude of the string displacement, string constant, length of string (1 in our analysis) and duration of motion (in seconds). The output is a matrix with the frames of the movement. The code can be seen below.
function [A] = string_wave(amplitude, speed, length, seconds) a=amplitude; c=speed; l=length; t=seconds; lac=0.005; for t=0:0.01:t sum=zeros(1,1+l/lac); d=zeros(1,1+l/lac); for x=0:lac:l d(int64(1+x/lac))=x; for n=1:1:50 sum(int64(1+x/lac))=sum(int64(1+x/lac))+(8*a/(pi*pi*n*n))*sin(n*pi/2)*sin(n*pi*x/l)*cos(n*pi*sqrt(c)*t/l); end end plot(d,sum) axis([0 l -amplitude amplitude]) F=getframe; if t==0 A=F.cdata; else A=cat(4,A,F.cdata); end end
A video was created using this code by typing the following commands
A=string_wave(0.5,1,1,2); B=immovie(A); movie2avi(B, 'name_of_video')
and can be seen below