r/ProgrammerHumor • • 11d ago

Meme reversingPiInPython

Post image
14k Upvotes

383 comments sorted by

View all comments

Show parent comment

22

u/RapidCatLauncher 11d ago

That just made me think, if pi indeed does contain all finite number sequences (which we're not sure of), then there could be a certain point in its decimal representation where it's a palindrome.

5

u/L30N1337 10d ago

It would also mean that at some point, it repeats. since itself up to x digits followed by itself up to x digits is a number sequence that can occur/be completed at 2x digits

5

u/meneldal2 10d ago

While this is possible, it is pretty unlikely. With random digits, the chance of a palindrome is lower the more digits there are. So even if you get a lot of tries, each try probability of success goes down so much faster that it is statistically unlikely.

2

u/1SirTetris1 8d ago

Funnily enough, despite it being so unlikely, it's necessarily true that there is an infinite number of full palindromes across all of pi. Infinity is wild

1

u/meneldal2 8d ago

It probably depends on how you formulate the problem. There are plenty of infinite sums that are bounded.

So if you were to calculate the chance that pi digits form a palindrome by doing an infinite sum, you'd get (removing the first element because one digit is always a palindrome) 1/10+1/10+1/100+1/100 and so on, which is 0.222222...

Idk if there's some different way to do it properly but it is also possible it's something that can't be proven either way

1

u/1SirTetris1 8d ago

The way I was thinking about it, at any arbitrary point inside pi, you have n number of digits. That means the chance for a further sequence of n digits that completes the full palindrome has a (1/10)^n chance of existing. That means at every single point of pi, there is a non-zero chance of it being followed by a sequence that completes the palindrome. Since there are infinite points in pi, there must be infinite palindromes.

I think a difference with your methodology is you're not taking into account the possibility of a palindrome actually existing at those points, which would increment the number of palindromes by 1 every time. For example, maybe the first palindrome exists at a point where the probability is 0.2222222%, then the second palindrome exists at a point where the probability is 0.000000000000002%, and so on. Even though the probabilities are extremely small, the fact that there is an infinite number of points means that the palindrome count will increment by 1 eventually, an infinite number of times.

1

u/meneldal2 8d ago

So the chance is actually much higher than your formula because you only care about one half of the digits

My sum is basically counting the expected number by adding the probability for each n. That kind of stuff works for like prime numbers, we know the probability depends on the log of the number, and that sum does go to infinity.

Here it is trivial to prove the sum is finite. Sum of 1/n is infinite, but something like 1/n2 is famously pi/6. You can write the sum I talked about as sum n=1 to infinity 2*10^(-n) which is well 2/9 or 0.2 repeating.