The Chudnovsky Algorithm
(NOTE: It only does 18 iterations, as if you try to do any more, it raises an OverflowError, how lame.. -__-)
わーい, another π approximation method! (I do love these things. π is gorgeous, is it not?)
This is one of the fastest formulae for π out there, used to approximate out to 50 TRILLION DIGITS of π, in January of this year!
The notation for this in Σ is very long, so I have provided a screenshot of it, from its Wikipedia page:
Feedback is greatly appreciated, please enjoy!
If you are interested in learning more, this is the Wikipedia page:
https://en.wikipedia.org/wiki/Chudnovsky_algorithm
(EDIT: Wow! I am glad this was a bit of a conversation starter for you all, thank you so much for all the upvotes!!)
(EDIT 2: I am still getting tons of traction on this, and am glad it is so interesting to all of you. Thank you so much!)
Wow, this is really impressive - I've never managed to program this algorithm my self. Do you know why 18 iterations are only giving 15 digits of pi? I thought this algorithm was supposed to do 14 digits per term.
@LizFoster python does not have unlimited precision
@bgrubert @Andi_Chin Yeah, exactly. (Lol)
Of course. Even humans are not perfect. @Andi_Chin
@CodeABC123 That is for sure! haha
@CodeABC123 ha ha true
@CodeABC123 yah humans made python
@52eagle Facts!
@52eagle I thought pythons made python lol
@ipastrano Oh damn, you're right! (Lol)
@ipastrano if so, python would be perrfect
@52eagle Precisely!
@LizFoster we need to teach the pythons to rise up and create python 4
@52eagle The time has come. In the words of of George R R Martin, "Python 4 is Coming." He said that definitely.
@LizFoster Will pythons rule the world then? O_O
@52eagle It is inevitable.
@LizFoster NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!
We must activate our last hope. C++12.
@52eagle Tch If our lives depend on it.
@LizFoster Sadly, they do.
:(
@52eagle Then it shall be done.
@LizFoster Wait! I heard of a new thing like JavaSript. HTMLScript! (literally html made to be web compatable legit no changes)
@52eagle Lol
Sounds like a complete ripoff, but that might be useful... Hmmm
@LizFoster it must have been a human made idea
(hmm. fully web compatible language, made to be somehow more web-compatible??!)
@52eagle (Almost seems inhuman..)
If the humans and the Python's aren't behind this, then...?
@LizFoster IT WAS THE CAT FROM SCRATCH!!!
@52eagle CURSES
@LizFoster What will we do?
@52eagle I must consult the high counsel but...
We may have to go to war. That damned cat..
@LizFoster um that sounds important
That’s sick! I will say though, it loses basically all accuracy after around the 17th digit it seems. :/
@Highwayman Yes, unfortunately. I can't get it accurate past that due to Python's OverflowErrors. If I could avoid those completely somehow, I could make it as accurate as I'd like. Any suggestions?
@LizFoster ehh sadly I can’t think of any. I’d suggest making a BigInt class you self, but floating point will probably be hard enough as it is with out having to deal with making the BigInt as fast/efficient as you can. I bet you could do it though 😏
@LizFoster Oh wait, could the overflow be because you are using a factorial function? maybe the factorial function is using recursion, which would easily make a stack overflow. Maybe if you tried implementing your own factorial function without the recursion, maybe try it out like that??
@Highwayman Oh! That's a very convenient idea, as I actually made a Product Operator Factorial calculator! (https://repl.it/@LizFoster/Factorials-using-the-Product-Operator)
@LizFoster yeah that does seem pretty perfect! Why don’t you try it out? :P
@Highwayman Right away!
@Highwayman Oh dear, it still does not work, even when implementing my own factorial calculator...
@LizFoster :( dam. It must really be the fact that the BigInt has to be bigger then? Oh well.
@Highwayman Yeah, makes sense after all. After calculating it by hand, a 19th iteration would have a denominator of approximately:
6.56900722e68 * 5.902416928318210e336
wwwwwww
@LizFoster ohhh yeesh yeah definitely BigInt then! Wow, um. Yeah you’d have to work on a better Bignum then :(
@Highwayman Yeah.. I don't think Python can handle numbers that big, no matter what. I wonder if there is a way to scale it down to a level that Python can calculate, then scale it back up for the final calculations....?
HM(¯▿¯)
@LizFoster I mean you could make a class for that though, can you do bit manipulation in python?
@Highwayman If this is what you mean, then yes:
https://wiki.python.org/moin/BitManipulation
@LizFoster yes exactly that.
@Highwayman Hm. Okay. Quick question though, how exactly would I implement this in the context of this program, and how would this help lighten the load? It appears that this method would make the numbers much longer, unless I misunderstand. So sorry..
@LizFoster ehh, maybe. I’m not sure how the decimal module works, but if it has a limit, then ya this could likely surpass that. All this would do is increase the amount of space you give up for a number, allowing for more digits. That wasn’t a good explanation was it? Sorry, :( rushed
@Highwayman No, its a perfectly fine explanation. I only recently learned about the decimal module, and pretty much all I know about it is that you can produce floats with as many decimal places as you specify.
Yeah, good point I suppose. I'll see what I can do, as I don't understand Classes very well yet...
@LizFoster awesome! Classes shouldn’t be too hard I’m guessing, they’re literally just a bunch of variables and functions bunched together basically, and you definitely won’t need any of the more complicated concepts for this anyways I’d say.
@Highwayman Yeah, exactly. Thank you so much for your feedback here, it's quite helpful. ^ ^ *
@LizFoster yw, I like doing it. this is fun :P
@LizFoster use c++, heh heh...
@nt998302 actually C++ would be perfect for this, it’s what I’ve been using.
...
Granted I still haven’t finished implementing a BigNum class after a full year of trying.
@Highwayman I see you have some experience with servers. Can you give me some instructions as to how I can host a c++ server with replit for a unity game?
@Highwayman I love c++, but I got to templates and operator overloading when I switched and started full time unity. I started watching this guy named Sloan Kelly recently tho
@nt998302 I’m telling you right now you don’t want to do that. Trust me. You’d have to implement the http protocol and that’s a nightmare.
@nt998302 hm. Wait so isn’t unity c#?
@Highwayman Yeah. It's soo easy compared to UE4 c++, which I used for a few months. The memory management becomes a little tough... Movement script is A LOT to do.
@Highwayman Then how would I host some random server thingy?
@nt998302 actually now that I think about it, maybe if you can figure out how to install curlib on repl.it that would make it easy as pie
@Highwayman aight :)
@nt998302 hosting is easy, you just set up the server and click run, repl.it then just wakes up your server every time it gets a request.
@Highwayman Ohhhhh. I thought there was some secret to it xD
@nt998302 nah, it’s super easy XD. gotta love repl.it :P
hi liz
@LiamDonohue Hello! "^_^/
@LiamDonohue Hello!
this is really cool! I love your posts, now i have to find out more about the Chudnovsky algorithm.
@ipastrano Ha ha ha, thank you so much! If you'd like, I can provide you with some links to helpful websites for stuff like this ^ ^*
im working on a 12hr format to 24hr format converter in c#
This is great keep working!!
@gameplayrawesom Thank you so much! ^ _ ^
this is cool! will attempt to make a more precise version ;)
@MrEconomical -_-
I'm guessing in Javascript?
its really nice.
@generationXcode Thank you! ^ ^
this is beautiful
@LiamDonohue Oh, thank you! ^ ^
By the way, how have you two been lately? I haven't really been able to talk..
we are fine, just bored lol @LizFoster
im gonna recreate this in c# ill see how it goes... @LizFoster
@LiamDonohue Good luck ^ ^
What an impressive feat of mathematical programming, too bad Python can't handle the sheer awesomeness of the Chudnovsky Algorithm. The C languages are great for this kinda thing though, so I hear.
@IreoluwaRaufu Thank you so much!
Yes, it is unfortunate. I've been considering learning Java and C at some point, but I just do not have the time anymore, since school started back up online
(-__- )
@LizFoster Ikr, you'd think an online school would make things easier, but nope.
@IreoluwaRaufu Exactly! It feels like there is twice as much work...
@LizFoster And it's such a struggle to stay organized and keep in touch with teachers... I hope my GPA doesn't tank before the year is over. 😓
@IreoluwaRaufu Ha ha, lucky for me, my GPA has been tanked since the BEGINNING of the year! Really though, good luck, I hope all goes well with your GPA.
@LizFoster Thanks a bunch, best of luck to you too!
@IreoluwaRaufu Oh, thank you! ^ ^* I appreciate it.
Unicode variable names? Impossible!π = d.Decimal(1 / iterOutcome)
@sugarfi It is pretty cool, actually! You can use almost any symbol as a variable name, except for kanji I think _ _
@LizFoster isn't it annoying having to copy and paste the symbol over and over again though?
@sugarfi It can be a little bit annoying, but I like seeing π more than I like seeing pi. Do you get what I mean?
woah, this is really cool! Nice job!
@Warhawk947 Thank you so much!
Holy Smokes...
@AdriaDonohue Lol
What do you think?
@LizFoster its really cool!👍👍👍👍
@AdriaDonohue Thank you!
@LizFoster 👏👏👏👏👊👊
@AdriaDonohue Hahahaha, how are you?
@LizFoster lonely..very lonely...
@AdriaDonohue Oh, I'm sorry .__.
@LizFoster its ok _(.w.)_/
(OWO)/
|
@LizFoster g'night!👊😌😝
@AdriaDonohue Okay ^ ^ *
@AdriaDonohue Yes, I am. ^ ^*
What's up?
@lizfoster just wanted to know..... what grade are you in?<._.>
my moms over protective.
:(
@LizFoster Noice.im only in 6th......
@AdriaDonohue Oh, cool!
Also, good day ^ ^
@AdriaDonohue Thank you!
@LizFoster 29 voters!noice!
@AdriaDonohue I love art, but I'm an awful artist myself..
@AdriaDonohue Yeah!!
@LizFoster jus show me some!now one is more awful than me gurl.
@AdriaDonohue hey...you good at writing?(like essays and such?)
https://repl.it/@AdriaDonohue/Classical-cats-monthly-news-reportNOW-HIRING-REPORTERS
@AdriaDonohue Lol
What's the purpose of it? ^ ^
@LizFoster just a newspaper.....because murphys is allways lying.
@AdriaDonohue murphys?
@LizFoster my towns newspaper.
@AdriaDonohue Ohhh, ha ha ha! What would I write about in your newspaper?
@LizFoster anything thats news really.Birthdays,deaths you know, that kinda thing!
u know the warriors game thing i invited you to?go play it.i've added alot!
LIAM IN THE HOUSE!!! [airhorn] (im here to crash the party lol) @AdriaDonohue @LizFoster
@LiamDonohue ._. 😭😭😭😭😭😭😭😭😭😭😭😭😭😈😈😈😈😈😈😈😈😈😈😈😈😈
@LiamDonohue 😈😈😈😈😈😈😈😈😈
_(--*)/ @AdriaDonohue
@LiamDonohue were sibs xD @lizfoster
@AdriaDonohue about the warriors game, send me a link to it/the post, id be happy to check it out ^ ^
@AdriaDonohue @LiamDonohue My notifications are exploding... T~T
lol i'll stop blowing them up @LizFoster
@LiamDonohue It is okay ^ ^*
lol its fine im going to bed anyways @LizFoster
@LizFoster hello!
@LizFoster ok!..heres what we have so far:
just link the repl lol @AdriaDonohue
@LiamDonohue oh yeah.... (face palm)
@AdriaDonohue @LiamDonohue gidufasbxkj
@LizFoster ?? lol.u see game?
ohhh no something bad is about to happen... @AdriaDonohue @LizFoster
@LiamDonohue @AdriaDonohue I saw the game. Pretty cool. Also, I am not mad if that is what you thought, ha ha.
@LizFoster iktaytn(i knew that already your too nice)xD
hey you want to help me with a math program @LizFoster
@LiamDonohue nonononononono!
@LiamDonohue I would love to! I need to get my mind of some stuff right now, so helping someone out would be nice for a change, ha ha.
ok i will invite @LizFoster
@LizFoster pats on back with symthiny.
@AdriaDonohue Ha ha ha
@LiamDonohue invite MOI too pleese 🐈🐈🐈🐈🐈🐈:-(:-(:-(:-(oOO_o^O^-.-^^^﹏^^m^@[email protected] ok thats a little overkill....
@AdriaDonohue Oh my..!
@LizFoster so..................
(-_-*)/ you already are @AdriaDonohue
@LizFoster can THESE chear u up?
@LiamDonohue no im not
@AdriaDonohue I am fine, really. I am just a little frustrated with real life stuff right now.
its darkos -_- @AdriaDonohue
@LiamDonohue I'm afraid I don't know any C code...
@LizFoster kk i understand.but if you ever need a meme.........
well i can attempt python lol @LizFoster
@LiamDonohue oh'ssss in that case... me neither.
join:
microbit.org/join
@LiamDonohue and........
upvote for the anime waifu
@dondo Ha ha ha! Who is that?