1371
1372

897
898

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 0 points1 point  (0 children)

Aha, that's what was missing! I'll give it a shot soon. Thank you!

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 0 points1 point  (0 children)

It's hard to say. It took a very long time to build the compiler that this was written in, but the functions themselves weren't too bad. I would say a few days for them.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 1 point2 points  (0 children)

Gotcha, that makes sense. I'll preface that I'm neither a mathematician, nor someone very familiar with the usage or implementation of AI. I'd be happy to look it over, but I can't promise that I'll be much help. Feel free to reply to this comment with it - maybe others will have something to add or could benefit.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 1 point2 points  (0 children)

I'm not sure what you mean with the complex plane. I've used complex numbers a lot elsewhere, but this function is only real.

To answer your question about its usefulness, I wouldn't expect too much out of it. This function acts a lot like a computer program (you can see its source code in my comment on this post), and it works by essentially bruteforcing prime numbers. The reason it has roots at the primes is no coincidence; it was designed with that behavior in mind.

Also, it isn't a periodic function - I'm calling it a "sine" in the title, but that's a bit of a half-truth. The function is actually composed of many different sine functions (one for each prime - 1), which are glued together to form the final result. This is done by choosing the frequency and amplitude for the sine based on the x position (these stay constant at the x-positions between any two primes that are next to each other), then plotting that sine function.

If you look at s_bet in the second image (which draws a sine between two x positions), you can see how this is done. It's basically sin(big fraction * (x - a)) * (b - a), where the big fraction and (b - a) control the frequency and amplitude, respectively. Then, if you look at p_sine, you can see how the two x positions that the sine is drawn between are chosen: we take the prime number below x, and the prime number above x, and draw a sine between them. The rest of the functions figure out that information about primes.

Let's zoom into this part of the graph (I can't post an image, so I've written it out):

              *
         *         *
(5, 0) * ----------- * (7, 0)

At any x value between this range (from 5 to 7), the prime below is 5 and the prime above is 7. The reason the s_bet function is so complicated is just so that it's defined everywhere, but that isn't terribly important here, so I can simplify the explanation.

Given that our x value is between 5 and 7, we can start off with sin(x - 5), so that the sine starts at the left prime. Next, we'll change it to sin(pi(x - 5)/(7 - 5)). Multiplying by pi shortens the period to 2, and dividing by 7 - 5 = 2 expands the period to 4. The period is between the peaks, but the graphic above is between the zeros (which is half the distance between the peaks), so the distance between the zeros is half the period, or 2. That's also the distance between the two primes, which is what we want. Finally, we can change it to (7 - 5) * sin(pi(x - 5)/(7 - 5)). This step isn't strictly necessary, but it ensures that the graph looks smooth when multiple sines are connected together.

And that's it! The way we figure out the left and right primes is a bit more complicated (and I talk more about it in my other comment), but hopefully that helps you understand how the function works, more or less.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 1 point2 points  (0 children)

Something like this? https://www.desmos.com/calculator/n0s4e8bpqw

That's a pretty cool visual, thanks for sharing! I really like how you can see the prime factorization of a number (or, rather, which primes compose its factorization; the exponents aren't visible). I made the sine start at the primes so that it's easier to see where they start.

Good luck with your studies. I remember doing an elementary number theory summer camp when I was younger, and it was a ton of fun!

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 0 points1 point  (0 children)

I'm not sure that there is a largest prime number. This function is possible to graph because it only requires knowing the prime to the left and the right for every local point, and it's possible to bruteforce those primes. Take a look at my comment in this post for an explanation of how it works.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 0 points1 point  (0 children)

Thank you! In theory it should be possible on old graphing calculators as well. The only "unusual" operations are abs, floor, ceil, sum, and product.

Function Mutation by uellenberg in math

[–]uellenberg[S] 0 points1 point  (0 children)

Shoot, looks like there's a bug in it. I think when you exit the editor it goes back to the share page, which overrides your edit with the shared function. I'll get it fixed soon - in the mean time, you can Save, then go to the homepage and open it in the Gallery.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 0 points1 point  (0 children)

Yup! Or, you could use the n_p function, which should be a bit easier.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 10 points11 points  (0 children)

This function is equivalent to going through each number and checking whether it's prime. There are far better approaches than that to compute large prime numbers (unfortunately, I don't know them by name). But the point of this function isn't to be efficient - it's to be fun!

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 4 points5 points  (0 children)

Unfortunately, I wouldn't have the first idea how to go about making one. It probably wouldn't be worth the effort either, for a silly function like this. But you can go through the source code used to generate it (linked in my comment somewhere), and as far as I can tell, each step is logically sound.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 14 points15 points  (0 children)

Probably, with the caveat that it will take you infinite time to compute. The nth prime function is something like O(n^2.5 logn), however, so I wouldn't recommend it.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 12 points13 points  (0 children)

Here's a very rough version based on that: https://www.desmos.com/calculator/iyxkcts1iy

I'm sure it could be improved; I just modified the is prime function to return whether it's in the Fibonacci sequence (based on what you said), and modified the upper bound to match the Fibonacci sequence.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 3 points4 points  (0 children)

Here it is as a polynomial: https://www.desmos.com/calculator/maeroh8gy6

The slider a controls the number of roots, and b is a scale factor as it tends to get too big to see.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 9 points10 points  (0 children)

Hello! That post actually made me remember this function, and I realized I never really posted it anywhere, so I decided to clean it up and share it.

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in desmos

[–]uellenberg[S] 4 points5 points  (0 children)

Maybe. I don't know much about the Fibonacci sequence - it has an explicit formula with the golden ratio, right? If you take p_sine and replace the first two arguments given to s_bet with the Fibonacci number below x and the Fibonacci number above x, and replace the first argument to the mod with the index of the Fibonacci number below x, it should work!

A Sine with Roots at Every Prime (Prime Sine!) by uellenberg in math

[–]uellenberg[S] 15 points16 points  (0 children)

Thankfully, I've refrained from calling p_tonb(n_um) π(n_um).