# Hidden patterns in $\sin(a x^2)$

I discovered unexpected patterns in the plot of the function

$$f(x) = \sin(a\ x^2)$$

with $$a = \pi/b$$, $$b=50000$$ and integer arguments $$x$$ ranging from $$0$$ to $$100000$$. It's easy to understand that there is some sort of local symmetry in the plot but the existence of intricate global patterns like these      astonished me.

Is there a somehow simple explanation of these regular patterns that emerge when combining such "incommensurate" functions like $$\text {sine}$$ and squaring? Especially of their specific shapes, their increasing distinctness and the distances between them?

Added: This pattern I found only today somewhere in the middle of the plot: Do you see the "corridors"? They long for explanation.

• Is the elementary-number-theory tag appropriate? – Improve Apr 20 '17 at 16:34
• Obviously not - it has been deleted. But the question has to do with (regularily distributed) natural numbers. – Hans-Peter Stricker Apr 20 '17 at 17:00
• Is there some reason for you being using "unicode" to write superscript in the title and not using simple formatting ? – A---B Apr 20 '17 at 17:01
• No. Thank you for having corrected it. – Hans-Peter Stricker Apr 20 '17 at 17:11
• My answer explains the presence of the pattern in the shape of $\sin (ax^2+\phi)$. And when $x$ gets larger and larger, the points create "accidental" patterns. – Yves Daoust Apr 26 '17 at 14:00

This is the phenomenon known as aliasing, caused to the fact that you are sampling a fast-varying signal with a too low frequency. It tends to create replicas of the original signal, but dilated in time.

When $a$ is close to $2m\pi$, we have at integers

$$\sin an^2=\sin(a-2m\pi)n^2$$

which is a replica of the original function with the smaller coefficient $a'=a-2m\pi$, and this is similar to a time dilation with

$$n'=\sqrt{\frac{a'}a}n$$ so that

$$\sin an^2=\sin an'^2.$$

As you can check on the plot, the blue and green curve coincide at integers ($a=6, a'=6-2\pi$). The other patterns are similarly obtained with a phase shift (such as the values at half-integers, corresponding to $\cos a'n^2$).

• @HansStricker No, they coincide exactly at integers. – Yves Daoust Apr 20 '17 at 13:36
• The point is that the computer graphs the curves by sampling them at regular points, and then it simply connects the dots of the samples. So the curve you see from the samples is going to miss all the extra wiggles between consecutive samples. Effectively it will have the lowest possible aliased frequency of the original. Sufficiently high sampling and sufficiently high screen resolution will counteract this, but with a signal like sin(x^2) whose frequency goes to infinity, there will always be at least some aliasing on a digital display. – Paul Apr 20 '17 at 14:43
• I told the computer to sample only at regular points. That was part of the game. And there was no connecting of dots at all. And it has nothing to do with digital displays. (Open syspedia.de/sin_square.html and zoom-in with Ctrl-PLUS and you will see what I mean.) – Hans-Peter Stricker Apr 20 '17 at 14:50
• The patterns you are seeing are aliased frequencies. It's not necessary to connect dots or have a digital display to see patterns corresponding to aliased frequencies. The discrete points form a shape that your eye is following and you are calling a pattern. That shape/pattern is an aliased frequency. Some of your graphs seem to show more than one aliased frequency. This is also possible, especially since you are controlling the sample rate explicitly and not a digital display. – Paul Apr 25 '17 at 13:32
• This is not an explanation a layman can immediately understand: How can a pattern (something complex) be a frequency (a number)? – Hans-Peter Stricker Apr 25 '17 at 14:42

[To check it all out, you may want to visit this interactive page.]

There are several aspects of the plot of $$f(x) = \sin(a x^2)$$ for integer arguments $$x$$, that need explanation, especially

1. its periodicity

2. the symmetry of the period

3. its recurring patterns

All these can be explained straight forwardly in a similar way:

## Periodicity $$\sin(a x^2) = \sin(a (c + x)^2) = \sin(a (c^2 + 2cx + x^2)) = \sin(ac^2 + 2acx + a x^2) =\sin(a x^2)$$

if $$ac^2 = 2\pi m$$ and $$ac = \pi$$ when $$x$$ is an integer. With $$a = \pi/b$$ this is fulfilled for $$c = b$$, provided $$b$$ is even. Here, $$b=500$$.

## Symmetry of the period $$\sin(a x^2) = \sin(a (b - x)^2) = \sin(a (b^2 - 2bx + x^2)) = \sin(ab^2 - 2abx + a x^2) = \sin(a x^2)$$

## Recurring patterns

The most prominent recurring pattern is the first peak of $$f(x) = \sin(a x^2)$$, e.g. for $$b = 5000$$:

Let's take as an example the third of these patterns which is found exactly in the middle of the period of $$f(x) = \sin(a x^2)$$, i.e. at $$x_0 = b/2$$.

Enlarged, it looks like this: We find:

$$\sin(a (2x)^2) = \sin(a (x_0 + 2x)^2) = \sin(a (x_0^2 + 4x_0x + 4x^2)) =$$

$$\sin(ax_0^2 +4ax_0x + 4ax^2) = \sin(\pi b/4 + 2\pi bx + 4a x^2) = \sin(4a x^2)$$

which holds when $$b$$ is divisible by $$8$$. A similar calculation shows that in this case

$$\sin(a (2x+1)^2) = -\sin(a (x_0 + 2x+1)^2)$$

This is still not the whole story to be told, but a beginning.

I found aliasing in a log table. Just use Excel to plot the error in a four place table with E(x)= Round(Log(x),4)-Log(x) for all 9000 values from 1 to 10. The values of the error will vary from -0.5E-4 ro +0.5E-4. The plot will have white vertical stripes where the slope of the log function is 1/4, 1/5, etc. • Could you please shortly explain why this is so? – Hans-Peter Stricker Apr 26 '17 at 13:51
• When the slope of the log function is just right, several successive values of the error are the same. This prevents the plot from filling the space and creates the white stripes you see at about 8.7, 7.2, 6.2, 5.4, etc. Something similar can happen with almost any differentiable function. – richard1941 Apr 28 '17 at 5:50

You are plotting one part of divisibility. Interesting things happen when the modulo of the factors align.

• Could yo please be more specific. Why and how am I plotting which part of divisibility? I've not been aware of, so can you please tell me. And what are the interesting things that happen when the modulus of which factors align? (Your desmos plots look interesting but I don't understand them immediately - what do I see?) – Hans-Peter Stricker May 11 at 14:58
• Consider $x=sin^2(\pi*y)$ and $y=-sin^2(\pi*x)$ (x and y integers at 0, squared so they don't intermingle later) then project both those graphs onto $p=xy$ (hyperbole). You now have the integers factors of p at the intersections. Substitution changes $x=sin^2(\pi*y)$ into $y=sin^2(\pi*p/x)$. The roots represent integers factors and the arc represents the modulo. Changing x (or b in your case) tests whether one factor is an integer for a fixed y. Larger values of p (or x squared in your case) have more factors (mostly), when the modulo's of those numbers align you get an integer factor. – dataphile May 12 at 6:26