CORRELATION WITH SINE AND COSINE
ACCOUNTING FOR PHASE

In the previous section we noticed that our “sine detector” was flawed. The detector would fail to register the presence of certain sinusoidal components if the input signal was phase-shifted by exactly 90 degrees. Under these circumstances, sine waves could slip past the detector unnoticed.

We can fix our detector by computing two dot products instead of one. In addition to computing the dot product of our input with a sine wave, we will also compute the dot product with a cosine wave. Since a cosine is simply a sine with a shift of 90 degrees, this ensures that we’ll always register a non-zero reading on our detector no matter what the phase of the incoming signal might be. With this change, no sinusoidal components will be able to “slip through” the detector.


Figure 1a.  Dot Product With Cosine Figure 1b.  Dot Product With Sine






Something quite interesting happens when we interpret the two dot products as coordinates on the complex plane. Using the cosine dot product as the real component, and the the sine dot product as the imaginary component we end up describing a complex number whose magnitude is constant no matter what the phase shift of the incoming signal might be. Notice that the final output of the detector looks remarkably similar to a phasor when plotted on the complex plane, especially as you begin to fiddle with the phase slider. I recommend spending some time with this visualization since it visualizes what’s going on at the heart of the DFT. If you understand this, everything else is (sortof) minutiae.

In the next section, we’ll step through an example computation of the DFT and see exactly how the detector that we’ve developed over the last two sections is used in the DFT.