Skip to content
Sign upLog in
← Back to Community

Let's talk about π.

Profile icon
LizFoster

Today I'd like to teach you all about one of my all time favorite constants: π!
Most likely, all of you know that π is the ratio of a circle's circumference to its diameter, and probably only know only 3 to 5 decimal digits of it. However, π is an irrational number, meaning it has no end! Let us go through all of the different formulae of π I have programmed, and explain what they mean! Let's dive in. (These are numbered in the order that they print when the attached code is run)

  1. The Monte Carlo Method

One way you can do this is by drawing a square, with a circle whose edges touch the 4 edges of that square within. Now imagine you were to draw many many dots randomly within the square-circle hybrid. If you take the number of points that fell within the circle, divide it by the total number of points, and multiply it by 4, you get (you guessed it) π!! More info can be found here:
https://ja.wikipedia.org/wiki/モンテカルロ法

  1. The Chudnovsky Algorithm

This is one of the fastest methods out there, being used in the world record, to calculate 50 trillion digits of π! I already explained it in a previous post, but the formula (and more cool information!) is here:
https://ja.wikipedia.org/wiki/モンテカルロ法

  1. The Basel Problem

This problem, posed by a man named Pietro Mengoli, asked for the exact sum of an infinite series, with proof. Mathematician Leonhard Euler answered this, with proof, finding it to equal exactly π^2/6. Further info and interesting facts here:
https://ja.wikipedia.org/wiki/バーゼル問題

  1. The Wallis Product

Unlike the other formulae here, this one uses the Product Operator in its equation. If repeated over an infinite number of times, it will equal π/2. More information here:
https://ja.wikipedia.org/wiki/ウォリス積

  1. The Leibniz Formula

Last but certainly not least, I have here probably one of the slowest π-convergent methods out there. In fact, to get π accurately to 10 decimal places takes about 5 billion iterations, according to the Wikipedia page! This formula alternates between adding and subtracting fractions with odd denominators (meaning this is an example of an alternating series), and converges on π/4. For extra information, go here:
https://ja.wikipedia.org/wiki/ライプニッツの公式

I plan to make more π approximation programs in the future, so stay tuned if these kinds of things interest you as much as they interest me!

Thank you. ^ ^

Voters
Profile icon
ThePinapple
Profile icon
ManuelCruz4
Profile icon
RayhanADev
Profile icon
TheDrone7
Profile icon
CodingCactus
Profile icon
AmazingMech2418
Profile icon
AdriaDonohue
Profile icon
oignons
Profile icon
DJWang
Profile icon
Navinor
Comments
hotnewtop
Profile icon
[deleted]

Great work Liz! Very, very interesting post about a very, very interesting number! I just gave you the conzent creator role, which marks creators who upload high quality content! Congratz

Profile icon
LizFoster

@enigma_dev Oh, thank you! I really appreciate that, that is so awesome of you! Yeah, numbers like π really get me going in terms of conversation, they are just so beautiful!!

Profile icon
Andi_Chin

@enigma_dev Simp!

Profile icon
LizFoster

@Andi_Chin Why are they a Simp? ; - ;

Profile icon
AdriaDonohue

nice job! also,congrats on geting on the leader bord!

Profile icon
LizFoster

@AdriaDonohue
^ ^*

Profile icon
AdriaDonohue

@LizFoster
:) do you watch star wars?>:)

Profile icon
AdriaDonohue

@LizFoster
i have a starwars oc:

Chapter1:An Introduction.

My name is Ariana Bridger.And I am the Most PowerFul Jedi in the universe.That might seem awesome. But it's really not. Because,when you're as Powerful as i am, The Sith find you easily as pie. I’m shocked my crew stayed with me.But they do.That i am glad. Because without my crew I would be dead by now.

When my master made me a full Jedi at 8 years old, everyone was shocked.That was 4 years ago. When I still used my real name. But now, everyone knows me as Adrianna luv.
I was born in an imperial prison to Ephraim and Mira Bridger. When They had to give me to the Sith, they whispered in my ear. They told me to be strong and stand up for what is right. I always remembered that. Their death is the reason for me leaving the empire, and becoming a Jedi instead of a Sith. I never thought i’d see any of my family again, But that was before I joined the Rebellion, and met Ezra Bridger. Now, to tell my story. It started when I got caught stealing a kyber crystal from the empire.
-Ariana Bridger

Profile icon
AphixDev

Sweet! I've been seeing your posts on these pi methods. This is awesome :)

Profile icon
LizFoster

@nt998302
Thank you! I love doing this, it has become quite an enjoyable thing to work on in my free-time (coding and math, that is)

Profile icon
JosiahKnisely

Wait, there are different numbers for π? This is when the confusion sets in...

Profile icon
JosiahKnisely

I'm also very young. I don't get these things.

Profile icon
LizFoster

@JosiahKnisely
Oh, that's alright. I can explain. ^ ^

No, there are not multiple values for π. There is only one, that being '3.14159...' and so on. These are merely methods of calculating π, albeit with varying amounts of accuracy at certain numbers of iterations.

π is quite interesting and cool, in that it can show up within the solutions to various mathematical problems that appear to have absolutely nothing to do with circles (at least at first glance)!

The things that the program displays are not π, in that, based on the accuracy I've asked for, the digits it shows aren't EXACTLY π.

For example, a common value that we use when approximating π is 22/7. This is only accurate to 3 digits (3.14), and even closer is 355/113, which is accurate to 7 digits (3.141592).

While they aren't equal to π, we often use them, since they are close enough to be somewhat useful for our purposes!

We don't know what π equals exactly, since it is infinitely long, but these equations can hep us learn more and more.

Here's a helpful link that non-math people can understand ^ ^

https://simple.wikipedia.org/wiki/Pi

Profile icon
staticvoidliam7

wow you beat me in only like number 5 on hot now lol

Profile icon
LizFoster

@LiamDonohue
Nyahahahaha

Profile icon
staticvoidliam7

tho im confused why is this in Japanese lol

@LizFoster

Profile icon
LizFoster

@LiamDonohue
Uhhhh why?

Profile icon
staticvoidliam7

just curious lol

@LizFoster

Profile icon
LizFoster

@LiamDonohue
Lol

Profile icon
staticvoidliam7

time to whip out google translate lol

@LizFoster

Profile icon
LizFoster

@LiamDonohue
You mean for the Wikipedia links?

You know there are English versions... ^ ^*

Profile icon
staticvoidliam7

no the post program lol

@LizFoster

Profile icon
LizFoster

@LiamDonohue
Oh, they're just the names of the methods, and the iterations the code goes through for each one. Nothing special.

Profile icon
staticvoidliam7

ah ok

@LizFoster

Profile icon
Highwayman

Do you know anything about something called a spigot method/algorithm or something? I heard of them at some point, but I’m not entirely sure where or exactly how either...

Profile icon
LizFoster

@Highwayman
Oh! I completely forgot about those, but yes, I do know about Spigot Algorithms! They can be used to find mathematical constants, like π! This is an article I had bookmarked about that:
http://stanleyrabinowitz.com/bibliography/spigot.pdf

Profile icon
Highwayman

@LizFoster
awesome! Thank you! :P

Profile icon
LizFoster

@Highwayman
Ha ha ha, yeah, it is nothing. (Lol)

I am a bit of a nerd when it comes to math-related subjects (as you can probably tell), so I have many articles like this waiting for use.. wwwwww

Profile icon
Highwayman

@LizFoster
ah yeah that’s kinda me with programming, I have too many books rn XS

Profile icon
LizFoster

@Highwayman
Hehehe, same here, I have many books on math I've been saving for a rainy day..
( . __ . * )

Unfortunately I don't have any books on Python or really programming in general (Lol)

Profile icon
Highwayman

@LizFoster
hmmmmmm I’d suggest one of my books but I’m pretty sure non of them are using python :(

Profile icon
LizFoster

@Highwayman
Awww, that's too bad.. (Lol)

Profile icon
Highwayman

@LizFoster
... I saw you were talking about learning "one of the C languages" earlier? That’s what they are all in. I know it’s not my place or anything at all, but I really strongly suggest you do, it’s so awesome.

I’d suggest maybe checking out cryptography or maybe AI Books, those are pretty math heavy I think :P

Profile icon
LizFoster

@Highwayman
Ooh, you've got me excited now! I certainly will, then! Have you gotten any specific suggestions for books I should buy?

Profile icon
Highwayman

@LizFoster
ehhh No. :( again all my books are c++, but I bet if you just look it up you will find something pretty easily. At least from what I can remember it’s pretty easy to find(it was just too mathy for me, so I never saved it). There are also some things on ai in this learn section too actually, though of course that’ll be more starter stuff than any of the more exciting stuff.

Actually if you learn C++, I found this one a while back on Neural Networks:
http://www.ece.ubc.ca/~msucu/documents/programming/C++%20neural%20networks%20and%20fuzzy%20logic.pdf

I don’t know if it’s actually good I forget I haven’t picked it up in a while(again- too mathy for me I’m bad at math lol)

And then this one is on analyzing stream ciphers(which are really cool by the way)
http://www.cs.ru.nl/~rverdult/Introduction_to_Cryptanalysis-Attacking_Stream_Ciphers.pdf

Again these are kinda introductions and also just things I pulled from my library, so I don’t how good they are but I hope they are helpful. :P

Profile icon
LizFoster

@Highwayman
Oh, nice! These look interesting, I'll start reading these a bit later. Thank you so much! (^ ^ * )

Profile icon
Highwayman

@LizFoster
yw :)

Profile icon
LizFoster

@Highwayman
These actually seem pretty up my alley, ha ha ha

Profile icon
Highwayman

@LizFoster
awesome! Perfect I’m so happy they actually are helping someone lol. I haven’t picked them up in a while

Profile icon
LizFoster

@Highwayman
Yeah! Math is really fun if you can find some thing or things that you find fascinating (for me it was π, Σ, and complex numbers), and from there, you can find that things that seemed really difficult or complex, just needed a bit more context/clarification.

Profile icon
Highwayman

@LizFoster
ehh idk.... I really like cryptography for example but I don’t even know where to start with the math. I just hit a series of strange unintelligible symbols and math jargon and then have no idea what to do.

Profile icon
LizFoster

@Highwayman
Oh, cryptography looks fun. I'd suggest looking on YouTube; half of the stuff I've learned came from Numberphile, 3Blue1Brown, and Mathologer, so I'm sure that there are loads of tutorials and such for cryptography! Here are a few I found if you have the time for it:

https://www.youtube.com/watch?v=cqgtdkURzTE
https://www.youtube.com/channel/UC1usFRN4LCMcfIV7UjHNuQg

and then for fun (probably not as related Lol):

https://www.youtube.com/watch?v=TvsiLV7RLx4

Profile icon
Highwayman

@LizFoster
thank you! I definitely will cryptography is super fun lol :P I’m pretty sure I heard somewhere that @enigma_dev is a cryptography nerd too I think...?

Profile icon
LizFoster

@Highwayman
Oh, it says it in his account biography, so maybe he is! (Lol) Glad I could help ^ ^*

Profile icon
Highwayman

@LizFoster
yeah there we go I knew it lol XD

Profile icon
LizFoster

@Highwayman
Kehehehe.. ^ __ ^

Profile icon
Highwayman

@LizFoster

If P and Q are two points on an elliptic curve such that kP = Q, where k is a scalar and sufficiently large, it is computationally infeasible to obtain k if k is the discrete logarithm of Q to the base P . Note that this is computationally infeasible even if P and Q are known.

XS ohh boy. Here we go again lol.

Profile icon
LizFoster

@Highwayman
Hahahaha don't worry about things that word it like that (I never do). See if you can find a simpler explanation elsewhere

Profile icon
Highwayman

@LizFoster
ok. :) I was actually just going to try and look it up, but that actually sounds like a better idea lol

Profile icon
LizFoster

@Highwayman
Yeah, whenever I don't understand something, I look up an article or video on that topic. It really helps!

Profile icon
Highwayman

@LizFoster
duly noted, lol :P

Profile icon
LizFoster

@Highwayman
(Lol)

Profile icon
[deleted]

I was summoned! Yeah, I’m a big cryptography fan! feel free to pimg me with q‘s!

@LizFoster
@Highwayman

Profile icon
LizFoster

@enigma_dev Nice! QnA galore! ^ ^*

Profile icon
Highwayman

@enigma_dev Oh, yay! Hi! Um, so
I was reading some stuff on the diffie-hellman key exchange, and they started discussing ECC, which I though was basically just another asymmetric encryption algorithm like RSA, but now I’m kinda confused because it started to look like it was just another form of the aforementioned diffie-hellman exchange, so I guess what my question is is what is elliptic curve cryptography?

Profile icon
staticvoidliam7

the only cryptography i know is the Caesar shift wheel lol

@LizFoster

Profile icon
Highwayman

@LiamDonohue
hmmm I thought I just saw you talking about SHA256 a little bit ago..? Or maybe that was someone else? Gah I’m going insane I can’t remember anything anymore :(

Profile icon
staticvoidliam7

no idea what your talking about lol

@Highwayman

Profile icon
Highwayman

@LiamDonohue
:’( oh well.