Imagine you have 2 audio waves of equal amplitude, offset by a phase difference $\phi$. The two wave functions are: $$\begin{align} S_1(x,t) &= A\cos(kx-\omega t)\nonumber\\ S_2(x,t) &= A\cos(kx-\omega t + \phi)\nonumber \end{align}\nonumber $$

Let's say we want to fix the position of the listener, who is sitting at position $x_1$ relative to the center of wave 1 and $x_2$ relative to the center of wave 2. The wave function is now only a function of the time $t$: $$\begin{align} S_1(t) &= A\cos(kx_1-\omega t)\nonumber\\ &= A\cos(-\omega t + kx_1)\nonumber\\ &= A\cos(\omega t - kx_1)\nonumber\\ S_2(t) &= A\cos(kx_2-\omega t + \phi)\nonumber\\ &= A\cos(-\omega t + (kx_2 + \phi))\nonumber\\ &= A\cos(\omega t - (kx_2 + \phi))\nonumber \end{align}\nonumber $$

where we have used the property $\cos(-\theta)=\cos(\theta)$.

Next, we want to see what happens when we add the two together. From the Principle of Superposition, $S\equiv S_1 + S_2$.

Here's the trick we will use: if we were to offset each wave by the same phase $\alpha$, then if we add the two waves together, there will be no change in the sum $S$. This is easy to see in the figure below. The red line is $S_1$ and the blue is $S_2$. Offsetting both by the same phase $\theta$ is equivalent to moving them both to the left and right by the same angle, hence $S=S_1+S_2$ will also move by the same angle and there will be no change in $S$.

So let's add a phase $\alpha = kx_1$ to both waves. This gives us: $$\begin{align} S_1(t) &= A\cos(\omega t)\label{wave1}\\ S_2(t) &= A\cos(\omega t - (kx_2 - kx_1 + \phi))\label{wave2} \end{align}\nonumber $$ Now, we can define $\theta = kx_2 - kx_1 + \phi$, which gives us $$\begin{align} S_1(t) &= A\cos(\omega t)\nonumber\\ S_2(t) &= A\cos(\omega t - \theta)\nonumber \end{align}\nonumber $$ which gives $$\begin{align} S &= S_1 + S_2\nonumber\\ &= A\cos(\omega t) + A\cos(\omega t - \theta)\nonumber\\ \end{align}\nonumber $$ Now, let's pull the same trick and add $\theta/2$ to both waves. This should also have no effect on the sum $S$: $$S = A\cos(\omega t + \theta/2) + A\cos(\omega t - \theta/2)\label{eqtheta}$$ We can simplify by using the trig identity $\cos(a\pm b)=\cos(a)\cos(b)\mp\sin(a)\sin(b)$: $$\begin{align} S &= S_1 + S_2\nonumber\\ &= A\cos(\omega t+\theta/2) + A\cos(\omega t - \theta/2)\nonumber\\ &= A\big [\cos(\omega t)\cos(\theta/2) - \sin(\omega t)\sin(\theta/2) + \cos(\omega t)\cos(\theta/2) + \sin(\omega t)\sin(\theta/2)\big]\nonumber\\ &= 2A\cos(\theta/2)\cos(\omega t) \end{align}\nonumber $$ This looks right. When $\theta = 0$, the waves are in phase and $S=2A\cos(\omega t)$ as expected.

Now, let's add 2 waves that have a different frequency, which means they also have a different wavelength, but without the phase difference ($\phi = 0$). Equations $\ref{wave1}$ and $\ref{wave2}$ are modified to be: $$\begin{align} S_1(t) &= A\cos(k_1x-\omega_1 t)\nonumber\\ S_2(t) &= A\cos(k_2x-\omega_2 t)\nonumber\\ \end{align}\nonumber $$ If we write the angular frequency difference $\delta\omega = \omega_1-\omega_2$ and the average $\bar\omega = (\omega_1+\omega_2)/2$, then it's easy to show that $$\begin{align} \omega_1 &= \bar\omega + \delta\omega/2\nonumber\\ \omega_2 &= \bar\omega - \delta\omega/2\nonumber\\ \end{align}\nonumber $$ Similarly, we can define the wave number difference $\delta k = k_1-k_2$ and the average $\bar{k} = (k_1+k_2)/2$ and get $$\begin{align} k_1 &= \bar k + \delta k/2\nonumber\\ k_2 &= \bar{k} - \delta k/2\nonumber\\ \end{align}\nonumber $$ Substuting into $S_1$ and $S_2$ gives $$\begin{align} S_1(t) &= A\cos((\bar k+\delta k/2)x-(\bar\omega+\delta\omega/2) t)\nonumber\\ S_2(t) &= A\cos((\bar k-\delta k/2)x-(\bar\omega-\delta\omega/2) t)\nonumber\\ \end{align}\nonumber $$ Next we fix $x$ to be at some point a distance $x_1$ from the source of wave 1 and $x_2$ from wave 2, and add up the two waves to and write it in this form: $$S = S_1+S_2 = A\big [ \cos(-\bar\omega t - \delta\omega\cdot t/2 - (\bar k+\delta k/2)x_1) + \cos(-\bar\omega t + \delta\omega\cdot t/2 + (\bar k-\delta k/2)x_2) \big]\nonumber $$ This is a mess! Let's define $\phi_1 = (\bar k+\delta k/2)x_1$ and $\phi_2 = (\bar k-\delta k/2)x_2$, and rewrite $S$ as $$S = A\big [ \cos(-\bar\omega t - \delta\omega\cdot t/2 - \phi_1) + \cos(-\bar\omega t + \delta\omega\cdot t/2 + \phi_2) \big]\nonumber $$ and use $\cos(-\theta)=\cos(\theta)$ to get $$S = A\big [ \cos(\bar\omega t + \delta\omega\cdot t/2 + \phi_1) + \cos(\bar\omega t - \delta\omega\cdot t/2 - \phi_2) \big]\nonumber $$ Since we are still summing the two waves, we can add a common phase to both, so let's add $\phi_1$ to both waves, which gives us: $$S = A\big [ \cos(\bar\omega t + \delta\omega\cdot t/2) + \cos(\bar\omega t - \delta\omega\cdot t/2 - \delta\phi) \big]\nonumber $$ where $\delta\phi = \phi_2-\phi_1 = \delta k\cdot (x_1-x_2)/2$.

Let's choose a point that is equidistant from the 2 waves (remember, we are in 2 dimensions). In that case, $x_1=x_2$ and $\delta\phi=0$. This gives us the following for $S$: $$S = A\big [ \cos(\bar\omega t + \delta\omega\cdot t/2) + \cos(\bar\omega t - \delta\omega\cdot t/2) \big]\nonumber $$ This looks just like equation $\ref{eqtheta}$, so we can write $S$ as $$S = 2A\cos(\delta\omega\cdot t/2)\cos(\bar\omega t)\label{final2}$$

Now, imagine that the 2 frequences $f_1$ and $f_2$ are such that the difference $\delta f$ is much smaller than the average. For instance, $f_1=400$Hz and $f_2 = 402$Hz. This gives $\bar f=401$Hz and $\delta f = 2$Hz. This looks like a wave with a slow varying amplitude $2A\cos(2\pi\cdot 1Hz)$ and frequency $\bar f=401$Hz. What you will here is a tone that has the average frequency $401$Hz, with an amplitude that "modulates" such that you will hear a peak at 1 cycle per second.

Below, you will see 2 text windows with frequencies for 2 sounds. Push the start button for each wave and you will hear the wave at that frequency. Change the frequency and you will hear the average modulated by the beat frequency $\delta f/2$.

Amplitude: 1
Frequency 1 Hz
Frequency 2 Hz