2024-05-04 — 2024-12-13

Explore the fascinating math behind wave behavior on a guitar string, from deriving the wave equation to understanding how tension and mass density influence vibrations, complete with solutions, simulations, and insights into the physics of string instruments.

The Wave Equation

Disclaimer: math-heavy article, on a topic I learnt about by writing: it might contain errors. Please comment if you see anything not making sense!

The other day, I looked at my guitar, and realized that I didn't known how waves behave on a string, mathematically speaking. How do they propagate? The string is fixed between two points. You pluck the string, by displacing it at a certain point, and letting go. What happens then?

Derivation

Imagine a string with tension TT, linear mass density μ\mu. We consider only the vertical displacements of the string, which should stay small (like on a string instrument). We will model our string as a function yy, that gives the vertical displacement given coordinate xx and time tt.

y:[0,L]×R+[ymax,ymax](x,t)y(x,t)\begin{align} y: [0,L] \times \mathbb R^+ &\longrightarrow [-y_\text{max}, y_\text{max}] \\ (x, t) &\longmapsto y(x,t) \end{align}

Let’s forget time for now, and look at static situations. Here’s a piece of string with tension acting on it on both ends.

Not much is happening here: the string is straight, the forces acting on it even out, everything stays in place. But let’s look at what happens when there’s some curvature.

Here, we imagine the net force would make the piece of string go downwards. We can find the mass of the piece easily: mΔx=μΔxm_{\Delta x} = \mu \Delta x. If we can find the net force acting on it, we’ll be able to apply Newton’s second law.

We’ve made the assumption that the movement of the string is only in the yy direction. This means we can consider only the vertical forces acting on the piece, at x0x_0 and x0+Δxx_0 + \Delta x.

From this picture, we can see that the vertical fore acting at x0x_0 is Fx0=Tsin(θ)F_{x_0} = -T \sin(\theta). Knowing that the yy displacements are small, we can make the small angle approximation physicists love, and use the slope instead of sin\sin0, and get:

Fx0=Tddxy(x0)F_{x_0}=-T \frac{d}{dx}y(x_0)

We can find the force from the other end the same way1:

Fx0+Δx=Tddxy(x0+Δx)F_{x_0+\Delta x}=T \frac{d}{dx}y(x_0+\Delta x)

We can sum them and get the net force acting on this small piece of string.

Fnet=T(ddxy(x0+Δx)ddxy(x0))F_\text{net} = T\left( \frac{d}{dx}y(x_0+\Delta x) - \frac{d}{dx}y(x_0) \right)

Great! We have everything we need to apply Newton’s second law. Let’s also put back time into the equation.

T(xy(x0+Δx,t)xy(x0,t))=Fx0,t=mΔxax0,t=μΔx2t2y(x0,t)T\left( \frac{\partial}{\partial x}y(x_0+\Delta x, t) - \frac{\partial}{\partial x}y(x_0, t) \right) = F_{x_0,t} = m_{\Delta x} a_{x_0,t} = \mu \Delta x \frac{\partial^2}{\partial t^2}y(x_0,t)

Reorganizing a bit:

Txy(x0+Δx,t)xy(x0,t)Δx=μ2t2y(x0,t)T\frac{ \frac{\partial}{\partial x}y(x_0+\Delta x, t) - \frac{\partial}{\partial x}y(x_0, t)} {\Delta x} = \mu \frac{\partial^2}{\partial t^2}y(x_0,t)

Supposing our function yy is well-behaved, we have:

xy(x0+Δx,t)xy(x0,t)ΔxΔx02x2y(x0,t)\frac{ \frac{\partial}{\partial x}y(x_0+\Delta x, t) - \frac{\partial}{\partial x}y(x_0, t)} {\Delta x} \xrightarrow[\Delta x \to 0]{} \frac{\partial^2}{\partial x^2}y(x_0, t)

In the end, taking a general xx instead of x0x_0, our equation becomes:

T2x2y(x,t)=μ2t2y(x,t)T \frac{\partial^2}{\partial x^2}y(x, t) = \mu \frac{\partial^2}{\partial t^2}y(x, t)

Or, as it is more often presented:

2t2y(x,t)=Tμ2x2y(x,t)\frac{\partial^2}{\partial t^2}y(x, t) = \frac T \mu \frac{\partial^2}{\partial x^2}y(x, t)

This reflects well our early intuition that the more curved the string is at some point, the faster it would move. The higher the tension, the faster, the higher the mass density, the slower. Sanity check: pass.

We can do two things from here, now that we have this partial differential equation: we can stop here, and go simulate it on a computer, or we can try to find explicit solutions.

Solutions

Of course, this equation is ideal, in that it doesn’t reflect all of reality. For example, there’s no damping, and a movement will continue forever. But it’s still useful to understand how waves propagate in this environment, especially if we can find the general form of the solutions.

Separation of variables

Let’s try to simplify the problem by “trying out” the assumption that yy can be written as the product of two simpler functions, each depending on only one parameter:

y(x,t)=X(x)T(t)y(x,t) = X(x) T(t)

This severely simplifies the problem and limits the number of forms that yy can take. Let’s substitute yy for this product in the wave equation:

2t2y(x,t)=Tμ2x2y(x,t)2t2[X(x)T(t)]=Tμ2x2[X(x)T(t)]X(x)T(t)=TμX(x)T(t)\begin{align} \frac{\partial^2}{\partial t^2}y(x, t) &= \frac T \mu \frac{\partial^2}{\partial x^2}y(x, t) \\ \frac{\partial^2}{\partial t^2}[X(x)T(t)] &= \frac T \mu \frac{\partial^2}{\partial x^2}[X(x)T(t)] \\ X(x)T''(t) &= \frac T \mu X''(x)T(t) \end{align}

When X(x)0X(x) \neq 0 and T(t)0T(t) \neq 0, we can rearrange a bit2

T(t)T(t)=TμX(x)X(x)\frac{T''(t)}{T(t)} =\frac T \mu \frac {X''(x)}{X(x)}

Each side depends only on one variable, which means they are both equal to the same constant!

Solving each side

Let’s take the left-hand side first

T(t)T(t)=α RT(t)=αT(t)\begin{align} \frac{T''(t)}{T(t)} &= \alpha\ \in \mathbb R \\ T''(t) &= \alpha T(t) \end{align}

If we’re looking for a function whose derivative is almost the same, we’re looking at the exponential. Let’s set T(t)=eatT(t) = e^{at}. We get that:

a2eat=αeat    a2=αa^2 e^{at} = \alpha e^{at} \iff a^2 = \alpha

If α>0\alpha > 0, we have T(t)=eαtT(t) = e^{\sqrt{\alpha} t}, but we’re probably not looking for an exponential function, as it won’t satisfy our boundary conditions. On the other hand, if α<0\alpha < 0, we have T(t)=e±itαT(t) = e^{\pm it\sqrt{-\alpha}}, which looks a lot more like the waves we’ve been talking about.

It makes sens intuitively: if T(t)/T(t)>0T''(t)/T(t) > 0, the function has a positive curvature when it’s already positive, making it grow even more. In the other case, it has a negative curvature, which is more reminiscent of the restoring force we found in the first part.

For simplicity, let’s set α=k2\alpha = -k^2, so that we have:

T(t)=e±iktT(t) = e^{\pm ikt}

We can follow the exact same procedure for XX, which is the same equation with a additional multiplicative constant.

X(x)=k2μTX(x)X''(x) = -k^2 \frac \mu T X(x)

and try X(x)=ebxX(x) = e^{b x}

b2ebx=k2μTebx    b2=k2μTb^2 e^{b x} = -k^2 \frac \mu T e^{b x} \iff b^2 = -k^2 \frac \mu T

So that b=±ikμTb = \pm ik \sqrt{\frac \mu T} . Let’s define λ=kμT\lambda = k \sqrt \frac \mu T for simplicity.

Our two resulting “elemental” solutions (actually four, counting the signs) are:

T(t)=e±iktX(x)=e±iλx\begin{align} T(t) &= e^{\pm ikt} \\ X(x) &= e^{\pm i \lambda x} \end{align}

But the equation is linear, meaning that any linear composition of these is still a solution. That means our general form is:

y(x,t)=X(x)T(t)=(A1eiλx+B1eiλx)(A2eikt+B2eikt)y(x,t) = X(x)T(t) = (A_1 e^{i \lambda x} + B_1e^{-i \lambda x}) (A_2 e^{ikt} + B_2e^{-ikt})

Where A1,A2,B1,B2CA_1, A_2, B_1, B_2 \in \mathbb C

Applying the boundary conditions

Spatial

We are ready to apply some boundary conditions. First, the string is fixed in place at x=0x=0 and x=Lx=L, which means that t\forall t we have y(0,t)=y(L,t)=0y(0,t) = y(L,t) = 0. The first one translates to:

y(0,t)=X(0)T(t)=(A1+B1)(A2eikt+B2eikt)=0y(0,t) = X(0)T(t) = (A_1+B_1)(A_2 e^{ikt} + B_2 e^{-ikt}) = 0

So at least one of the member is null. For the right side to be null would mean that A2=B2=0A_2 = B_2 = 0 which leads to a non-moving string. Other wise, we have B1=A1B_1 = -A_1, and

X(x)=A1(eiλxeiλx)=2iA1sin(λx)=Csin(λx)\begin{align} X(x) &= A_1 (e^{i \lambda x} -e^{-i\lambda x}) = 2i A_1 \sin(\lambda x) \\ &= C \sin(\lambda x) \end{align}

Applying the condition from the other end of the string, we get:

X(L)=Csin(λL)=0    λL=nπ    λ=nπLX(L) = C \sin(\lambda L) = 0 \iff \lambda L=n\pi \iff \lambda=\frac{n\pi}{L}

Which is valid for any nNn \in \mathbb N^*, meaning XX can be a superposition of those:

X(x)=nNCnsinnπLxX(x) = \sum_{n\in\mathbb N^*} C_n \sin\frac{n\pi}{L} x

Temporal

If we consider the movement of a guitar string, at the initial pluck, the velocity of the string is 00 everywhere (before the player lets the string go). Which means that T(0)=0T'(0) = 0:

T(t)=ikA2eiktikB2eiktT(0)=ikA2ikB2=0    A2=B2\begin{align} T'(t) &= ikA_2 e^{ikt} - ikB_2 e^{-ikt} \\ T'(0) &= ikA_2 - ikB_2 = 0 \iff A_2 =B_2 \end{align}

We can now simplify the writing of TT:

T(t)=A2(eikteikt)=2A2cos(kt)=Dcos(kt)\begin{align} T(t) &= A_2(e^{ikt}-e^{-ikt}) = 2A_2 \cos(kt) \\ &=D \cos(kt) \end{align}

We also know that k=λTμ=nπLTμk=\lambda \sqrt \frac T \mu = \frac{n\pi} L \sqrt \frac T \mu, which means we also have a superposition here:

T(t)=nNDncosTμnπLtT(t) = \sum_{n \in \mathbb N^*} D_n \cos\sqrt \frac T \mu \frac{n\pi} L t

Final solution

By combining these terms, with new an=Cn+Dna_n=C_n+D_n, we have4

y(x,t)=nNansin(nπxL)cos(TμnπtL)y(x,t) = \sum_{n\in\mathbb N^*} a_n \sin \left( \frac{n\pi x} L \right) \cos \left( \sqrt \frac T \mu \frac{n\pi t} L\right)

And by applying sin(x)cos(y)=12(sin(x+y)+sin(xy))\sin(x)\cos(y) = \frac 1 2 (\sin(x+y) + \sin(x-y)) we get

y(x,t)=12nNan(sinnπL(x+tTμ)+sinnπL(xtTμ))y(x,t) = \frac 1 2 \sum_{n \in \mathbb N^*} a_n \left( \sin \frac{n\pi}{L}\left(x+ t\sqrt \frac T \mu \right) + \sin \frac{n\pi}{L}\left(x- t\sqrt \frac T \mu \right) \right)

Which is a more interpretable form of the solutions: for each frequency, there’s a wave going to the right, and another going to the left. In this form, we can also see that c=Tμc = \sqrt \frac T \mu is the speed at which the wave propagates. Let’s re-write it with that simplification in mind:

y(x,t)=12nNan(sinnπL(x+ct)+sinnπL(xct))y(x,t) = \frac 1 2 \sum_{n \in \mathbb N^*} a_n \left( \sin \frac{n\pi}{L}\left(x+ ct \right) + \sin \frac{n\pi}{L}\left(x- ct \right) \right)

Actually, we still have an unknown, or rather an infinity of them, namely all the ana_ns. But these can be determined with the initial state of the string y(x,0)y(x, 0). If we plug that in, we obtain:

y(x,0)=nNansin(nπxL)y(x, 0) = \sum_{n\in\mathbb N^*} a_n \sin \left( \frac{n\pi x} L \right)

Which is just the Fourrier decomposition of the initial state.

(TODO add explanation about Fourrier series)

an=2L0Ly(x,0)sinnπxLdxa_n = \frac 2 L \int_0^L y(x,0) \sin \frac {n\pi x} L dx

Read more here

Simulation

Now a bit of fun. By making the domain (both temporally and spatially) discrete, we can model the string at time tt by an array y~tRn\tilde{y}_t \in \mathbb R^n, where n=LΔxn = \frac L {\Delta x} and Δx\Delta x is the spatial definition. We can keep track of the vertical speed of the string at any point with another array v~tRn\tilde{v}_t \in \mathbb R^n.

This way, we can keep track of the system at time tt, and update it based on the previous equation. This is done using a finite-difference approximation of the second spatial derivative (which is just the approximation you get by considering the definition of a derivative)

2x2y(x,t)y(xΔx,t)2y(x,t)+y(x+Δx,t)Δx2\frac {\partial^2}{\partial x^2} y(x,t) \approx \frac {y(x-\Delta x, t) - 2y(x, t) + y(x+ \Delta x, t)} {\Delta x^2}

From this, using the wave equation, we get an approximation a~(x,t)\tilde{a}(x,t) of acceleration. Integrating once is easily approximated:

tt+Δta~(x,t)dta~(x,t)Δt=:Δv~t\int_t^{t+\Delta t} \tilde{a}(x, t) dt \approx \tilde{a}(x, t) \Delta t =: \Delta \tilde{v}_t

This gives us the change of speed, with which we can update our v~t+Δtv~t+Δv~\tilde{v}_{t+\Delta t} \leftarrow \tilde{v}_t + \Delta \tilde{v} and by “integrating” again…

tt+Δtv~(x,t)dtv~tΔt=:Δy~t\int_t^{t+\Delta t} \tilde{v}(x, t) dt \approx \tilde{v}_t \Delta t =: \Delta \tilde{y}_t

…we get an update to our yy by doing y~t+1y~t+Δy~t\tilde{y}_{t+1} \leftarrow \tilde{y}_t + \Delta \tilde{y}_t and the cycle starts again, approximating the new position and speed at each time step. Of course, all that is of no use if we don’t get to see it in action!

100
4
1

Comparison with a real string


  1. Indeed ddxy(x)=tanθ=sinθcosθsinθ\frac d {dx} y(x) = \tan \theta = \frac {\sin\theta}{\cos\theta} \approx \sin\theta because cosθ1\cos \theta \approx 1 when θ\theta is close to 00.
  2. The sign difference comes from the two different directions for tension.
  3. Otherwise, both sides of the equation are equal to zero anyway.
  4. There’s only one sum because kk and λ\lambda are linearly dependent.