# If we listen to the sound, why does $\sin(x^2)$ shrink and grow in intervals?

$\sin(x^2)$ gives (it seems) an ever shrinking sine wave: Its frequency gets higher, and the pitch of the sound wave should too, right? But if we pass the $\sin$ through the Play function (with a reasonable coefficient like 1500) we get It goes up, and then down, on certain intervals. This is the pitch, i.e. the frequency, which I expected to look more like $a^x$ instead of like the screenshot above.
The sound pitch lowers and so should the sine function do? But it looks like it doesn't (according to the first screenshot)?

Where am I wrong? Is the sine frequency really getting wider at some points (I think it should not) or what else?

• This is known as aliasing. See Bill S's explanation here, which is basically the same as your question except that he's doing it on purpose. – Rahul Jan 25 '17 at 23:59

What (I think) happens is that you use a constant rate of $8000\,\text{Hz}$ on a steady increasing frequency. This leads to interesting effects when the frequency of the function gets bigger than you rate-frequency.

This fact can be explored by just using a $\sin$-Function and use a interval which is slightly larger than $\pi$ at example:

Show[Plot[Sin[x], {x, 0, 30 Pi}],
ListLinePlot[Table[{x, Sin[x]}, {x, 0, 30 Pi, Pi + 0.1}],
PlotStyle -> Black, Mesh -> All]] While you used a normal $\sin$-function, you got a multiplication of two wave-functions with different frequencies just by using a too small rate-frequency.

You can visualize this. Use your function $\sin(x^2)$ but a constant interval to get the plot below:

p = Table[Sin[x^2], {x, 0, 100, 0.05}];
ListLinePlot[p, AspectRatio -> 1/10, PlotRange -> All,
ImageSize -> 1500] We can also analyze the frequency of this (in a little bit of cheating) by partitioning the list in equal parts and doing an FFT:

p = Table[Sin[x^2], {x, 0, 200, 0.005}];
g1 = ListLinePlot[p, AspectRatio -> 1/10, PlotRange -> All,
ImageSize -> 1500];
pp = Partition[p, Floor[Length[p]/500]];
fp = Flatten@Table[Abs[Fourier[pp[[i]]]]^2, {i, 1, Length[pp]}];
g2 = ListLinePlot[fp, AspectRatio -> 1/10, PlotRange -> All,
ImageSize -> 1500];
g3 = GraphicsGrid[{{g1}, {g2}}] Which looks like your diagram there.

EDIT: To answer your comment: (First notice, that the first diagram of the output of Play is a diagram which shows the frequency over time) It's like whats shown in the first picture but whats actually happens is displayed in the second picture. Your function frequency gets so high, that you Sample-Rate-Frequency goes into a kind of interference with it. So that you get an alternating frequency drift. A way to prevent this is to increase the sample rate. An example:

Play[Sin[(20*t*2 Pi)^2], {t, 0, 25}, SampleRate -> 8000] This is what you've got essentially. If we now increase our sample rate, we can go into higher frequencies of your function without getting this interference.

Play[Sin[(20*t*2 Pi)^2], {t, 0, 25}, SampleRate -> 80000] Notice how this sound can play much longer before our frequency begins to drift away.

• Seems logical, although not quite intuitive :). So are you saying that when the audio is generated, it (the process) gets such points from the $\sin$ function that the effect is like on your first picture? I tried changing the sample rate and noted that the bigger the sample rate, the bigger the grow/shrink intervals of the sine. They're certainly related but I'm not quite sure how it really works. It seems that from such a small difference in the beginning the result is radically changed. – Al.G. Jan 25 '17 at 23:36
• I updated my anwser to anwser this. – Julien Kluge Jan 25 '17 at 23:59
• Thanks, I understood it - while trying to explain it to someone else. Again it turns out to be the best way to learn something :) – Al.G. Jan 26 '17 at 16:43