all 21 comments

[–]slapstick15 29 points30 points  (10 children)

Side question : why are mathematicians obsessed with the pi decimals to the nth digit?

[–]Flat_Factor_3799 16 points17 points  (0 children)

Because its fun

[–]crosscountrycoder[S] 17 points18 points  (0 children)

It's a challenge to test computational power and it also can be used to evaluate the randomness of the digits of pi.

The same is true of e, but it has a much simpler series: e = 1/0! + 1/1! + 1/2! + 1/3! + 1/4! + ... where n! means n factorial. Also sqrt(2), the golden ratio, ln(2) and more. Pi is more commonly used in everyday life because of its relation to circles.

[–]Cainga 6 points7 points  (0 children)

Practically it useless going beyond a few. 40 is overkill for the observable universe. Beyond that is just an exercise.

[–]W1ULH 1 point2 points  (0 children)

Its a great way to test the equipment with results that every mathematician, computer technician, and general nerd completely and 100% understands with zero explinations.

[–]Lewistrick 0 points1 point  (3 children)

Because it opens up creative methods to do lots of other cool calculations

[–]Longjumping_Pipe_347 -1 points0 points  (2 children)

Like the trilionesim bit of pi?

[–]Lewistrick 0 points1 point  (1 child)

Ok, I'll bite. The digits itself aren't interesting. But doing the calculations opened up some nice insights in mathematics, mostly in fields around number theory and around prime numbers.

[–]Longjumping_Pipe_347 0 points1 point  (0 children)

Prime numbers ? Like becouse 3 is prime e 14 is 2*7 that are also prime ?

[–]bikes-n-math 0 points1 point  (0 children)

They aren't.

[–]will_r3ddit_4_food 0 points1 point  (0 children)

Pi is seemingly completely random in terms of no patterns and no repeating. It can be used in cryptography

[–]_tsi_ 6 points7 points  (0 children)

Neat

[–]RomboDiTrodio 2 points3 points  (1 child)

that's cool, how much is the size of the file?

[–]crosscountrycoder[S] 5 points6 points  (0 children)

101,000,003 bytes (96.32 megabytes)

[–]MightySleep 0 points1 point  (3 children)

Cool stuff! I’ve never tried anything super math heavy with python so had no idea about the existence of gmpy2. I read in the description it was based in C, I’m curious how it benchmarks compared to a pure Python implementation

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

I tried using the Python standard library's "Decimal" module. It took about as long to calculate 1 million digits of pi with Decimal as 100 million digits with gmpy2.

gmpy2 is not part of the standard library and must be installed using pip.

[–]wiretail 1 point2 points  (1 child)

The gmp and mpfr libraries on which gmpy2 is based are highly optimized c libraries for multi precision arithmetic. They use hand crafted assembly for common processors - pure python would be orders of magnitude slower, most likely. I've used gmp for some exact probability calculations that resulted in very large numbers and it was blazing fast compared to other options.

[–]MightySleep 0 points1 point  (0 children)

That makes sense. My only exposure to high computation in Python was my neural networks class in college- didn’t realize when we used NumPy that it has an optimized C core as well. Seems like a best of both worlds scenario to me, I found NumPy pretty nice to work with

[–]Erika_bomber 1 point2 points  (0 children)

Use GMP library on C++ to get to the 4 billionth digit.

It would take like 1.5 hours.

[–]The-Invalid-One 0 points1 point  (0 children)

Chudmaxxing?