Why do cosines appear in the whitespace of plots of sines and/or cosines with regularly spaced frequencies?

70 Views Asked by At

If you plot many sines with regularly spaced frequencies over top one another, you will see cosines in the white space of the graph. Please see the image here. The graph is also particularly dark near the lowest frequency sine waves, some having frequencies even lower than that which is plotted. At rational $x/2\pi$ values, the $\sin$ functions can overlap at only a few values. This concentration of $\sin$ functions produces white space at these $x$ values but I have not figured out how to turn this into a useful explanation.

Below is matlab code that can produce such a plot:

x=0:pi/3000:2*pi;
dpi = 150;            % Resolution
sz = 5.*[0 0 2880 1800]; % Image size in pixels
figure(...
  'PaperUnits','inches',...
  'PaperPosition', sz/dpi,...
  'PaperPositionMode','manual')
  
hold on
for it=1:50
    plot(x,sin(x.*it),'b')
end

I find the pattern clearer in matlab, but here is a python version too:

import matplotlib.pyplot as plt
import numpy as np

freqs = np.arange(1,50)
x = np.arange(0,2*np.pi,0.01)
plt.figure(figsize=(20,12))
for f in freqs:
    plt.plot(x,np.sin(f*x),'blue','.',linewidth=0.35)

At first, I thought this had to do with the fact that sines and cosines are orthogonal functions. This idea is appealing because it seems right that they should occupy different parts of a graph in a regular way. This idea is difficult to test with Bessel functions and polynomial series because they do not 'fill' a similar space on the graph the way that sines and cosines do. However when you plot sines and cosines of even frequency, you do not see the sines and cosines of odd frequency. You again see cosines in the white space. Even more strange, you still see cosines in the white space when you just plot cosines!

Has anyone seen something like this before? Is this a Moire pattern in disguise? Why does this happen?