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

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?

• I tried the link and it took way too long to load. Please re-do it so it loads quickly and it is simpler to see what you are referring to, maybe by plotting fewer sines and indicating in another color what you mean by the apparent cosine curves. Commented Jan 18, 2023 at 4:57
• If you want to write the sine function in math mode, use \sin, since with just sin it's formatted as $s$ times $i$ times $n$. Commented Jan 18, 2023 at 5:29
• tl;dr. sounds like you are looking at a Fourier transform . few hundret years old. Commented Jan 18, 2023 at 5:51
• I'm having a hard time producing a smaller plot without compromising the visual. I supplemented it with a description. I am not looking at a Fourier transform, I explain why I think the orthogonal function explanation is lacking in the post.
– Gage
Commented Jan 18, 2023 at 6:02
• You see those cosines as a white space because these are the regions where fewer sines intersect. Obvious so far. Now comes the harder part. Someone needs to do the math. Commented Jan 18, 2023 at 6:59