## Saturday, 24 August 2013

### Bending with Dojo part 1: Maths rock

One of the distinctive sounds of the guitar is bending notes, pushing or pulling the string sideways across the fretboard to raise its pitch. Santana's Samba Pa Ti and Pink Floyd's Shine On You Crazy Diamond have classic examples, but whether you're listening to BB King or Noel Gallagher it'll show up from time to time.
But guitar strings are steel, they can't stretch that much can they? Some people have trouble believing this and think there must be 'give' somewhere else, but a guitar string is thin and long and really can stretch, so I thought I'd put together a string bend calculator to show how. Using it should be self explanatory, this series of posts is about what's happening under the hood.

The following is roughly divided up into a chunk of maths, some web programming (part 2), complications and fun and games with equations (part 3).

### Shakin'

Guitar strings make a note by vibrating at a particular frequency, they do this because they're under tension. When you pluck a string the tension tries to pull it straight again, but because the string is quite free to move it overshoots, it keeps overshooting and getting pulled back, gradually losing energy (and getting quieter). The more tension the faster the cycle goes (higher pitch), the heavier the strings are the slower it goes.
You can write this down as an equation for the speed of a wave travelling down a string under tension:
Speed of vibration along string $$c = \sqrt {\frac{T}{\rho}}$$, you can probably guess $$T$$ is tension, $$\rho$$ is the "linear density" e.g how much a metre of string weighs (or how massive it is for the pedants out there). The different types of density get important a bit later.
The observant reader will be saying waves don't travel down a guitar string (where would they go?), it vibrates side to side. This is true, one way of looking at it is they get reflected at each end, called a standing wave. However we can still use the same relations for speed (c), frequency (f) and wavelength (w). (If you're following along with a physics textbook you might have $$\nu$$ for frequency and $$\lambda$$ for wavelength, but let's try and keep it simple here. Also I'm saving l for later.).
Quite simply, $$\mbox{speed}=\mbox{frequency}\ times\ \mbox{wavelength}$$, or $$c=fw$$.
Since we don't care about the speed along the string (or maybe you do, I don't right now), we get rid of it:
$fw= \sqrt{\left( \frac{T}{\rho} \right)}$

### How long is a piece of string?

The wavelength (w) above is the distance between the start and stop of the "S" that makes up a wave, but the standing wave on a guitar string doesn't look like this. It's one half of it (the second harmonic does look like an S, but we're interested in the string notes here). So if the length of the string (l), between the bridge and the nut (the "scale length") is half the wavelength, then $$w=2l$$.

### Getting tense

Since we want to know about string stretching and that will depend on tension, we want to rewrite things with the tension dependent on the other factors:
$(2fl) = \sqrt{\frac{T}{\rho}} \\ (2fl)^2 = \frac{T}{\rho} \\ 4f^{2}l^{2}\rho = T$

### Row your boat

(For the non-Greek speakers out there, $$\rho$$ is pronounced  "row"...) We've said that's the density as mass-per-length of the string, but if you look up the density of steel you'll find the mass-per-volume (call it $$d$$), kilogrammes per cubic meter ($$kg\ m^{-3}$$ or the Imperial equivalent, grains per cubic chain or whatever). This is because strings come in different thicknesses. To get from $$d$$ to $$\rho$$ we multiply by the cross sectional area of the string, which is a circle.
$\rho=d\pi r^2 = d \pi \left(\frac{g}{2}\right)^2 = \frac{dg^2\pi}{4}$
$$\pi r^2$$ is the usual way to write the area of the circle, but the radius $$r$$ is just half the width of the diameter or gauge $$g$$.
$T=(flg)^{2}\pi d$

### Stretch it

If you remember school physics lessons then you probably remember Hooke's Law. This says the displacement (stretch) of a spring is proportional to the force stretching it. A similar rule works for some solid materials like steel, where the stress ($$\sigma$$ tension over an area) is proportional to the strain ($$\epsilon$$ stretch relative to original length). The relation is given by the Young's Modulus, $$E$$.
$\sigma = \epsilon E \\ \frac{T}{A}=\frac{T}{\frac{1}{4}\pi g^2}=E\frac{s}{L}$
$$s$$ is the distance the string stretches by, $$L$$ is the full length of the string. We already used small $$l$$ for the scale length, but on most guitars the part of the string between the headstock and the tuners is also under tension.

### Getting toned

Musicians don't deal in frequencies, they use notes. We need to be able to convert from notes to frequencies. It's fairly well known that for every octave you go up the frequency of the note doubles. If you know a bit more about equal temperament tunings then you'll know that for each semitone the frequency multiplies by $$2^{1/12}$$. So if we know what frequency one note is then we can work out any other note by knowing how many octaves and semitones up or down it is.
The standard most often used is "A440", where the A above middle C is at 440Hz. So what frequency is the low E guitar string? We need to know the octave. Something called scientific pitch notation is useful here, this gives each octave a number, middle C is the 4th octave, or C4. A bit confusingly each octave starts at C, so the 440Hz A is A4. So in the 4th octave we need to count semitones down from A4 to C4 and up from A4 to B4.
$f=2^{(\mbox{oct}-4)+\mbox{st}/12} * 440Hz$
Where "oct" is the octave and "st" is semitones above or below (negative) A. The low E string is E2 or about 82Hz.

### The final stretch

So how much does a string stretch with a bend of $$n$$ semitones? To get the bend you pull the string, raising the tension by enough to get the pitch. Call this higher tension $$T_2$$, the new note $$f_2$$.
$T_{2}=(f_{2}lg)^{2}\pi d \\ \frac{T_2}{T} = \frac{(f_{2}lg)^{2}\pi d}{(flg)^{2}\pi d} = \left(\frac{f_2}{f}\right)^2$
And we can write the ratio of $$f_2$$ and $$f$$ in terms of $$n$$ semitones
$T_2=T(2^{n/12})^2=2^{n/6}*T \\ T_2 - T = (2^{n/6}-1)T$
Why $$T_2 - T$$? The string is already under tension, what we want to know is how much more tension is needed. The extra stretch is then found by using that in the Young's modulus equation:
$s=\frac{L}{E}\frac{(2^{n/6}-1)T}{\frac{1}{4}\pi g^2}$
We could start substituting more things in here, but it's useful later to be able to do things with the tension, so we'll stop there.

Mathematical symbols in this post handled by MathJax http://www.mathjax.org/  using as in this post.