# Detecting beat frequency using FFT

I wrote Mathematica FFT code that works for non-beat signals, eg. Sin[2*Pi/20*x] and more complicated but I can't obtain beat frequency of Sin[2*Pi*(10)*x] + Sin[2*Pi*(11)*x]. Also, what is general approach for sampling of analytical functions or numerical data in order to extract beat freq, because I think there lies the problem? I understand that Nyquist theorem determines appropriate sampling frequency in order to extract high frequencies.

Code:

test[x_] = Sin[2*Pi/20*x]

xi = 0
xf = 100
h = 1;(*(xf-xi)/n step*)
n = (xf - xi)/h (*# of sampling points*)

N[(1/h)/(n)]  (*sampling frequency*)

xg = N[Range[xi, xf - h, h]];
data = Map[test, xg]

cc = Abs[Fourier[data]]
ccred = Table[If[0 < i < Length[cc]/2, cc[[i]], 0.], {i, Length[cc]}];

Table[Ordering[ccred, -15][[i]], {i, 15}]
Table[ccred[[Ordering[ccred, -15][[i]]]], {i, 15}]

nu = Table[N[((Ordering[ccred, -15][[i]] - 1)*(1/h)/(n))], {i, 15}]
T = Table[N[1/((Ordering[ccred, -15][[i]] - 1)*(1/h)/(n))], {i, 15}]


To get the beat, you have to mix (multiply) the signals, not add them. Try Sin[2*Pi*(10)*x] * Sin[2*Pi*(11)*x.
• The beat frequency is present in the linearly mixed signal, but it will not appear in the FFT. Either introduce non-linear mixing or merely apply the textbook formula for beat frequency: $f_b = |f_1 - f_2|$. – David G. Stork Oct 24 '17 at 1:25