Sharedmaster / Sine_waves.sagewsOpen in CoCalc

Sine waves

Declare variables

var('t')
t

Sine functions

y=sin(2πt)y = \sin{(2\pi t)}

plot(sin(2*pi*t), (t, -1, 2), ymin = -2, ymax =  2)

y=sin(2πt)+sin(2πt)y = \sin{(2\pi t)} + \sin{(2\pi t)}

show(plot(sin(2*pi*t) + sin(2*pi*t), (t, -1, 2), ymin = -2, ymax =  2) +
     plot(sin(2*pi*t), (t, -1, 2), ymin = -2, ymax =  2,  color = 'red', thickness = 0.5))

y=sin(2πt)+sin(2πt2π(1/2))y = \sin{(2\pi t)} + \sin{(2\pi t - 2\pi(1/2))}

show(plot(sin(2*pi*t) + sin(2*pi*t - 2*pi*(1/2)), (t, -1, 2), ymin = -2, ymax = 2) +
     plot(sin(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2, color = 'red', thickness = 0.5) +
     plot(sin(2*pi*t - 2*pi*(1/2)), (t, -1, 2), ymin = -2, ymax = 2, color = 'green', thickness = 0.5))

y=sin(2πt)+sin(2π(2t))y = \sin{(2\pi t)} + \sin{(2\pi (2t))}

show(plot(sin(2*pi*t) + sin(2*pi*(2*t)), (t, -1, 2), ymin = -2, ymax = 2) +
     plot(sin(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2,  color = 'red', thickness = 0.5) +
     plot(sin(2*pi*(2*t)), (t, -1, 2), ymin = -2, ymax = 2,  color = 'green', thickness = 0.5))

y=sin(2πt)+13sin(2π(3t))+15sin(2π(5t))+17sin(2π(7t))y = \sin{(2\pi t)} + \frac{1}{3}\sin{(2\pi (3t))}+ \frac{1}{5}\sin{(2\pi (5t))} + \frac{1}{7}\sin{(2\pi (7t))}

show(plot(sin(2*pi*t) + (1/3)*sin(2*pi*(3*t)) + (1/5)*sin(2*pi*(5*t)) + (1/7)*sin(2*pi*(7*t)), (t, -1, 2), ymin = -2, ymax = 2) +
     plot(sin(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2, color = 'red', thickness = 0.5) +
     plot((1/3)*sin(2*pi*(3*t)), (t, -1, 2), ymin = -2, ymax = 2, color = 'red', thickness = 0.5) +
     plot((1/5)*sin(2*pi*(5*t)), (t, -1, 2), ymin = -2, ymax = 2, color = 'red', thickness = 0.5) +
     plot((1/7)*sin(2*pi*(7*t)), (t, -1, 2), ymin = -2, ymax = 2, color = 'red', thickness = 0.5))

Beats

y=sin(2π(22t))+sin(2π(20t))y = \sin{(2\pi (22t))} + \sin{(2\pi (20t))}

plot(sin(2*pi*(22*t)) + sin(2*pi*(20*t)), (t, -1, 2), ymin = -2, ymax = 2,  thickness = 0.5)

Beat derivation

Here is a useful trigonometric identity:

sin(a)+sin(b)=2sin(a+b2)cos(ab2).\sin(a) + \sin(b) = 2 \sin{\left( \frac{a + b}{2} \right)} \cos{\left( \frac{a - b}{2} \right)}.

A more convenient formulation is

For example, suppose we have two frequencies that are close together: one at 20 Hz and the other 2 Hz higher (so 22 Hz). According to the above formula, with f=20f = 20 and ϵ=2\epsilon = 2:

Think of this as [sin(2π(21t))][2cos(2πt)].\Big[ \sin{\left( 2\pi (21t) \right)} \Big] \Big[ 2 \cos{\left( 2\pi t \right)} \Big].

The blue graph below is sin(2π(21t))\sin(2\pi (21t)). The red graph is 2cos(2πt)2 \cos(2\pi t). (The dotted curve is just 2cos(2πt)-2 \cos(2\pi t).)

show(plot(sin(2*pi*(21*t)), (t, -1, 2), ymin = -2, ymax = 2, thickness = 0.5) +
     plot(2 * cos(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2,  color = 'red',  thickness = 2) +
     plot(-2 * cos(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2,  color = 'red', thickness = 2, linestyle="--"))
show(plot(sin(2*pi*(22*t)) + sin(2*pi*(20*t)), (t, -1, 2), ymin = -2, ymax = 2, thickness = 0.5) +
     plot(2 * cos(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2,  color = 'red',  thickness = 2) +
     plot(-2 * cos(2*pi*t), (t, -1, 2), ymin = -2, ymax = 2,  color = 'red', thickness = 2, linestyle="--"))

Therefore, in addition to the 21 Hz tone (the average of the two frequencies, 22 Hz and 20 Hz), there will be a perceptible beat every half-second—in other words, a 2 Hz beat.

That last fact needs a little explanation. The function 2cos(2πt)2 \cos(2\pi t) has a frequency of 1 Hz, so why are the beats heard at 2 Hz? If you look at the graph above, you can see that the 21 Hz wave "fills up" both halves of the cosine graph, so it repeats every half-cycle of the cosine graph.

The net effect is that the beats are heard at the freuency ϵ\epsilon, and here, ϵ=2\epsilon = 2.