# # How To Simulate Guitar Sounds?

## # Derivation of 1D wave equation

Hi, my friend! Have you ever seen how a guitar string viberate? I mean have you ever look closely after you plunking a string? I want to simulate the motion of a guitar string on my computer. I will show you how to do this from scratch using Python. The first thing first we need to do is to analysis a small piece on the string. Let look at this figure.

## # Wave function

The motion of an ideal string can be discribed by a 1D wave equation(In this case the fraction between the string and the air is not considered),

$\frac{\partial^{2} u}{\partial t^{2}}=\frac{T}{\mu} \frac{\partial^{2} u}{\partial x^{2}}$

Where, $u=u(t,x)$ is the displacement of the the string at position $x$, at the time, $t$; $T$ is the tensile force; $\mu$ is the linear density (mass per length). [1]

## # String tension

String tension is a function of three aspects: string gauge, scale length, and pitch. String gauge refers to the thickness of the strings. Scale length is a measurement of the distance of a vibrating string on a given instrument—usually this means it’s measured from the nut to where the string contacts the bridge or tailpiece. Pitch refers to the note/sound the string is tuned to (or intended to be tuned to). [3]

For a guitar string, the string tension in newton is given by

$T = 4mLf^2 = \mu (2Lf)^2$

where $m$ is its mass in kilogram, $L$ is the length in meter, and $f$ the lowest vibration frequency of the string in hertz which determines the pitch. [5]

## # Solve PDE

I am going to simulate the third string, which has the frequency of 196 Hz. The tension 5.39 Kg given by the the manufacturer is converter to 52.85785 newtons by multiplying the gravititional acceleration $g$.

$T = 5.39 \text{kg} \times 9.80665 \text{m}/\text{s}^2 = 52.8578435 \text{kg}\cdot \text{m}/\text{s}^2 = 52.85784 \text{N}$

The unit weight (UW) of the third string J4503/EXP given is 0.00004679 pounds per linear inch (lb/in). Hence, the linear density $\mu$ can be obtained.

$\mu = 0.00004679 \frac{\text{lb}}{\text{in}} = 0.00004679 \frac{0.45359237 \text{kg}}{0.0254 \text{m}} = 0.00083557 \text{kg/m}$

To slove the partial differential equation, we need to give the initial conditions.

The initio state of the string can be described as these equations.

$u(0, x) = - \frac{1}{18} x, x \in [0, 0.18] ,$

$u(0, x) = \frac{1}{47} x - 0.01383, x \in (0.18, 0.65],$

$\left. \frac{\partial u}{\partial t} \right|{t=0} = 0 ,$

and

$\frac{\partial^{2} u}{\partial t^{2}}=\frac{T}{\mu} \frac{\partial^{2} u}{\partial x^{2}}$

I use Euler's method to solve the equation numerically. First choose stepsizes $\Delta t$ and $\Delta x$, and set $t=0$ and $x=0$.

What is the stable condition of this equation?

What is the constraint ?