Strings and Waves

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

$\frac{\partial^2 u(x,t)}{\partial t^2}=c \frac{\partial^2 u(x,t)}{\partial x^2}$ (1)

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

$u(0,t)=u(1,t)=0$ (2)

because these are the edges of the strings, and

$\frac{\partial u(x,0)}{\partial t}=0$ (3)

because there is no initial velocity.

We assume that the amplitude function is separable, namely

$u(x,t) = F(x) G(t)$ (4)

Then we can rewrite (1) as

$F(x) \frac{\partial^2 G(t)}{\partial t^2} = c \frac{\partial^2 F(x)}{\partial t^2} G(t)$ (5)

Dividing both sides of (5) by (4), we get

$\frac{1}{G(t)} \frac{\partial^2 G(t)}{\partial t^2} = c \frac{1}{F(x)} \frac{\partial^2 F(x)}{\partial t^2} = k$ (6)

where $k$ 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

$\frac{\partial^2 G(t)}{\partial t^2} = k G(t)$ (7)

is

$G(t) = A cos(\sqrt{-k} t) + B sin(\sqrt{-k} t)$ (8)

and the general solution to equation

$\frac{\partial^2 F(x)}{\partial t^2} = \frac{k}{c} F(x)$ (9)

is

$F(x) = C cos(\sqrt{\frac{-k}{c}} x) + D sin(\sqrt{\frac{-k}{c}} x)$ (10)

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 $\sqrt{-k}$ must be equal to $n \pi \sqrt{c}$, where n is an integer. Therefore, we have the following particular solution of equation (1)

$U(x,t) = E sin(x n \pi) cos(t n \pi \sqrt{c})$ (11)

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

$u(x,0)=x, x \in [0,0.5]$ (12)

$u(x,0)=(1-x), x \in (0.5, 1]$ (13)

hence the general solution of equation (1) is

$u(x,t) = \sum_{n=1}^{\infty} E_n sin(x n \pi) cos(t n \pi \sqrt{c})$ (14)

where for $t = 0$ it must be equal to equation (12) and (13). Equation (14) with $t = 0$ has the form of a Fourier series with period 1. The coefficients $E_n$ can be found by exploiting the orthogonality of the sine functions if we multiply by $sin(x m \pi)$ and then integrate. After some calculations we get

$E_n = \frac{4}{\pi^2 n^2} sin(n \frac{\pi}{2})$ (15)

and the complete solution is

$u(x,t) = \sum_{n=1}^{\infty} \frac{4}{\pi^2 n^2} sin(n \frac{\pi}{2}) sin(x n \pi) cos(t n \pi \sqrt{c})$ (16)

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