Is there a way to make a sine wave equal to $0$ everywhere but around its peak? (Sieve of Eratosthenes in wave form)

365 Views Asked by At

[Editor's comment] The sieve part of the title is from me. The comments from the asker revealed that this what they are hoping to build. JL. [/Editor's comment]

So, basically what I need is something like this:

The function is 500^(cos(2pi*x/2))/500

You can see fairly regular peaks and the function seems to be 0 elsewhere, but it's not. It's just quite small.

What I need is a function that:

  • Is greater than 0 where its peak is (even a bit around it is ok)
  • Is 0 where its neighbour numbers are
    (In the picture shown, I want it to be 0 where 3, 5, 7, 9 etc... are. It can be a bit greater than 0 where 2.95 or 3.05 is, I don't care. It just needs to be 0 where 3 is, and the other numbers are).

**Other example** (This is 500^(cos(2pi*x/3))/500)

Here you can see peake where 3, 6, 9 etc... are, but I need the function to be exactly 0 where 1, 2, 4, 5, 7, 8, etc... are. I don't care how it behaves in between the numbers, as long as it's 0 where those numbers are and greater than 0 (preferably =1) elsewhere.

One more thing:

  • It needs to be a single equation and not a split one.

Is it possible?

EDIT: My goal is to construct an equation that finds prime numbers by looking at the zeroes in this function.

stacked wave

This has been obtained by 'stacking' the cosine wave functions for multiples of 2, 3, 5 and 7. You can see quite easily that 11 and 13 are marked as 0, but since the function is not exactly 0, but a bit above it when the numbers are possible primes, the error builds up and the function is not reliable anymore after we stack too many of them.

The one in the last picture was this:

999999999999^(cos(2pix/2))/999999999999+999999999999^(cos(2pix/3))/999999999999+999999999999^(cos(2pix/5))/999999999999+999999999999^(cos(2pix/7))/999999999999

It is just a sloppy approximation, but shows the concept quite well I guess.

2

There are 2 best solutions below

1
On

How about $\cos(\pi x/2)^{2n} $ for $n \in \{1,2,3,...\}$? One for even numbers, zero for odd numbers.

0
On

Sieve of Erathostenes in wave form

Since this is your actual aim, then I am recasting my answer in a different way.

Product form

Take a function $u(x)$, having in every $x=n \in \mathbb N$ a zero of order $q$.
Then the products $$ P_{\,1,\,n} \left( {u(x)} \right) = \prod\limits_{k\, = \,1}^n {\,u\,(x/k)} \quad P_{\,2,\,n} \left( {u(x)} \right) = \prod\limits_{k\, = \,2}^n {\,u\,(x/k)} = {{P_{\,1,\,n} \left( {u(x)} \right)} \over {u(x)}} $$ will have in $x=m \; | m\le n \in \mathbb N$ , respectively, a zero of order $q \sigma_0(m)$ and $(q-1) \sigma_0(m)$.
If we take another function $v(x)$ (even the same $u(x)$), also with zeros of order $q$ for $x$ being a natural integer, and divide $P_1$ by the square of it, then the resulting function will have no zero when $x= \text{prime}$, and instead will be null only for composite integral $x$.
So, it has a complementary behaviour vs. the one you are looking for.

For instance $$ \eqalign{ & Q_{\,n} \left( {\sin ,\sin } \right) = {1 \over {\sin ^{\,2} \,(\pi x)}}\prod\limits_{k\, = \,1}^n {\,\sin \,(\pi x/k)} = {1 \over {\sin \,(\pi x)}}\prod\limits_{k\, = \,2}^n {\,\sin \,(\pi x/k)} \cr & Q_{\,n} \left( {\sin ,{\rm fall}} \right) = {1 \over {\left( {\left( {x - 1} \right)^{\,\underline {\,n\,} } } \right)^{\,2} }}\prod\limits_{k\, = \,1}^n {\,\sin \,(\pi x/k)} = \prod\limits_{k\, = \,1}^n {{{\,\sin \,(\pi x/k)} \over {\left( {x - k} \right)^{\,2} }}} \cr} $$ etc.
Then, it is always possible to multiply by an entire function to change the "envelopping" of the function.

Sum form

It is known (see e.g. this Wolfram site page) that the number of divisors of $n$ can be written as $$ \sigma _{\,0} (n) = \sum\limits_{\matrix{ {1\, \le \,j\, \le \,k} \cr {1\, \le \,k\, \le \,n} \cr } } {{1 \over k}\cos \left( {{{2\,\pi j\,n} \over k}} \right)} $$ but given the nature of this formula, we also can write $$ \sigma _{\,0} (m)\quad \left| {\;2 \le m \le n} \right. = \sum\limits_{\matrix{ {1\, \le \,j\, \le \,k} \cr {1\, \le \,k\, \le \,n} \cr } } {{1 \over k}\cos \left( {{{2\,\pi j\,m} \over k}} \right)} $$

Then $$ \eqalign{ & s_{\,0} (x,n)\quad \left| {\;2 \le x \le n} \right. = \sum\limits_{\matrix{ {1\, \le \,j\, \le \,k} \cr {1\, \le \,k\, \le \,n} \cr } } {{1 \over k}\cos \left( {{{2\,\pi j\,x} \over k}} \right)} \cr & = \sum\limits_{1\, \le \,k\, \le \,n} {{{\cos \left( {{{k + 1} \over k}\,\pi \,x} \right)\;\sin \left( {\pi \,x} \right)} \over {k\sin \left( {{{\,\pi \,x} \over k}} \right)}}} = \cr & = \sin \left( {\pi \,x} \right)\sum\limits_{0\, \le \,k\, \le \,n - 1} {{{\cos \left( {{{k + 2} \over {k + 1}}\,\pi \,x} \right)\;} \over {\left( {k + 1} \right)\sin \left( {{{\,\pi \,x} \over {k + 1}}} \right)}}} = \cr & = \sum\limits_{0\, \le \,k\, \le \,n - 1} {\cos \left( {{{k + 2} \over {k + 1}}\,\pi \,x} \right)\;{{\sin \left( {\pi \,x} \right)/\left( {\pi \,x} \right)} \over {\sin \left( {{{\,\pi \,x} \over {k + 1}}} \right)/\left( {{{\,\pi \,x} \over {k + 1}}} \right)}}} \cr} $$

and $s_0(x,n)-2$ is null for all $x$ prime $\le n$, and not for composite integers. However it is null also for non-integral values of $x$.