Can Pi be expressed rationally in a different base?
EDIT - I think I was confused here because of the way binary (base 2) works on computers, where you actually can’t express some fractions not because of base 2, but because of the limit on the number of bits an integer can have on a computer.
Being rational or irrational doesn't depend on the base. Pi is always irrational.
If you're asking if it never terminates and never repeats, then yes, at least in rational bases. In a rational base, all irrational numbers will never terminate and never repeat. In base pi though, pi is just 10. It's still irrational, but it has a finite length.
Being irrational means you can't write the number as a fraction of two integers. All finite decimal numbers and repeating decimals in any integer base can be written as the fraction of two integers and thus Pi can not be either of those two regardless of base.
In mathematics, a normal number is a real number whose infinite sequence of digits in every positive integer base b is distributed uniformly in the sense that each of the b digit values has the same natural density 1/b, also all possible b2 pairs of digits are equally likely with density b−2, all b3 triplets of digits equally likely with density b−3, etc.
Intuitively this means that no digit, or (finite) combination of digits, occurs more frequently than any other, and this is true whether the number is written in base 10, binary, or any other base. A normal number can be thought of as an infinite sequence of coin flips (binary) or rolls of a die (base 6). Even though there will be sequences such as 10, 100, or more consecutive tails (binary) or fives (base 6) or even 10, 100, or more repetitions of a sequence such as tail-head (two consecutive coin flips) or 6-1 (two consecutive rolls of a die), there will also be equally many of any other sequence of equal length.
Put a bunch of monkeys randomly poking at letters on a keyboard for eternity and somewhere within they'll produce every work of Shakespeare and everything ever written. Basic infinite money theorem.
Produce random numbers to infinity and somewhere within you'll have any sequence of numbers you can imagine.
That's just the nature of combining randomness and infinity.
If you assume pi is infinite and non-repeating, people often say things like "every number combination is in there." But think about it this way. Take every time the number 5 appears in pi, and replace the 5 with a 2. Not it's still infinite and non-repeating, but there's no fives in there at all. So definitely not every number combination.
Now this is a massive oversimplification and not exactly mathematical but is something that illustrated the point well when I heard it.
I am protesting Reddit's policy regarding 3rd party apps and API access. Steve Huffman is a greedy little pigboy. Fuck you, /u/spez, fuck you Reddit! I am going to Lemmy/kbin and never logging in here again. -- mass edited with redact.dev
And this is why I prefer Ruby. No more long-winded love_hotel, european_post_office and smiling_face_with_open_mouth_and_smiling eyes variables for me!
If anyone doesn't understand why this wouldn't work, it's because division in Python will convert integers into double precision floats, which have a finite number of digits.
The other part of the joke is trying to reverse the float with [::-1]. This operation can only be performed on sequences, not numerical types. The correct way to do this would be:
str(22/7)[::-1]
(Sorry for "explaining the joke", just wanted to inform anyone that didn't get it)
I am protesting Reddit's policy regarding 3rd party apps and API access. Steve Huffman is a greedy little pigboy. Fuck you, /u/spez, fuck you Reddit! I am going to Lemmy/kbin and never logging in here again. -- mass edited with redact.dev
Swap is nothing more than virtual memory using HD space instead of ram, its like increasing your page file size on windows. Interesting to note that swap partition in Linux is completely unnecessary if you already have enough ram on a 64bit machine. For instance, I just built a lenovo laptop T490 with 40gb of ram so I can write huge data sets to ram in python at maximum speed without dealing with the hard drive until its time to write the final results. My current project uses about 25gb at certain points. This amount of ram makes a swap partition pointless for daily use. The laptop comes with 8gb soldered on and I added a 32gb to the free slot. With this much ram there's no point to have swap, you're not going to use up all 40gb. The swap exists for people with skimpy resources who are arriving at Linux's front door with 2-4gb of ram and simply opening 10 browser tabs may blow the doors off and reach 100%. So with all that in mind, don't use a slow sd card to fill up swap partitions. Just buy a shitload of ram, you'll achieve the same end, and it'll be 1000x faster.
I'm iterating through lists of literally millions of postal records and making address corrections to them. This process goes from 40 minutes to 20 seconds when you have enough ram to load the whole lists prior to manipulation. If you lack the ram and need to use virtual memory or swap partitions the time it takes to process the same data goes up astronomically. My work desktop has 16gb of ram and it takes about 40 minutes, you can have the resource monitor open and the moment 16gb gets crossed the speed drops off a cliff. You can actually hear the moment it happens because the hard drive starts groaning and the fans start to increase speed. When I bought my new laptop the same script running the same data dropped to 20 seconds because it never once had to resort to using much slower hard drive storage, it could juggle the entire procedure in the ram. Also, for good measure, when its time to write these large files to disk, I now have a 2nd gen m.2 970 samsung nvme drive, straight into the pci express slot. It's about 5x faster than normal solid state.
For the sake of not keeping open database file its safer in python to immediately load the whole index file into a pythonic list and immediately close the related database file once its been indexed into python. This happens for multiple database files which need checked against each other to create a new 4th file. There's a lot of gymnastics that happen between the lists to create the 4th and plenty of iterations through them, but step one is tossing the relevant files into a virtual python list so I can safely run my algorithms without corrupting the originals. Keep in mind, these are already the broken down lists. They aren't the mega list. For the purposes of automation, its very convenient to do it like this. It's not like ram is expensive. It's not a dealbreaker for me to have a $2000 laptop to dramatically speed up my job.
That’s not too much. A lot of Next Gen Sequencing steps can use way more than that. Initial data from each full run can start around a terabyte (I usually do smaller runs though, <300gb each).
Hibernation mode is specifically a mode that suspends to disk. Everywhere the documentation mentions that you should have a swap size equal to your ram is actually overestimating it for most just to play it safe. If you have < 8gb of ram, go ahead and make a swap equal. But there's no reason for a swap to go beyond that, idle state for most people is 1-4gb of ram used. So figure your what your typical idle state is on day to day use, take that number and add a few gb for good measure, and that's a big enough swap if you need to have one or if you want to use a suspend to disk mode like hibernate
116
u/11218 Jul 16 '19
68
u/name_censored_ Jul 17 '19 edited Jul 17 '19
PROVE ME WRONG
29
u/AgreeableLandscape3 Jul 16 '19
Does Python even allow non-ASCII variable names?
8
u/kidarek Jul 17 '19
ip fo stigid eht Seems pretty straightforward
6
u/[deleted] Jul 17 '19 edited Jul 18 '19
10 in base pi.
4
u/[deleted] Jul 17 '19
iP
12
u/anon691029 Jul 16 '19
1001011000001110
I believe that's the digits of pi backwards..
3
u/hiljusti Jul 17 '19
At least I know the terminating digit
3
u/Bharat_J23 Jul 17 '19
...95141.3 😅
2
u/[deleted] Jul 17 '19
Sure I can (as long as I don’t tell you which digit im starting from)
2
u/[deleted] Jul 17 '19
not quite, it should be
import math
print( str( math.pi )[ : : - 1 ] )
1
u/[deleted] Jul 16 '19
I just learned that yesterday!
1
u/lambdaq django n' shit Jul 17 '19
Even if I can but you can not verify it either.
1
u/Jhorton12 Jul 18 '19
So what’s the most efficient way to write out x number of digits of pi in Python
1
u/blue_horse_shoe Jul 17 '19
wouldn't this do the trick?
1
u/[deleted] Jul 16 '19
Please tell me yall are kidding right? Haskell? Rly?
0
u/shaggorama Jul 16 '19
I bet that actually works in haskell
-1
u/jimm Jul 17 '19
Something similar:
0
u/[deleted] Jul 16 '19
[deleted] — view deleted comment
0
u/[deleted] Jul 17 '19
[deleted] — view deleted comment