##### EVEN MORE APPROXIMATIONS OF π!!

I'm back at it again, this time with a compilation of different formulae for approximating π, with surprising accuracy in some cases!

Fascinating stuff!

I have a way of approximating pi but i do not now if it is plausible:

in calculs we know that an integral = area under curve

and from geomtry area of circle = pi*(r)^2

the circle furmula is x^2+y^2=r^2 solve for y :

y=((r^2)-(x^2))^(1/2)

(interrating from -r to r = area of half a circle) *2 = area of circle

then solve for pi :

pi = (area of circle)/(r^2)

to calculate the intergration use riymen's sum or simpson's rule

i know how to solve simpson rule only on desmos

is it plausible

@luffy223 Alright, part 2, done!

This uses your typical Riemann Sum formula to calculate the area under the curve. The higher *n* is the better, but it lags too much to be worth it _ _

The difference between the outcome (*a* in this case) and *π* is just about:

0.0000000000032249758419

So yeah, pretty accurate for how low *n* is ^ ^*

@LizFoster And now, the final addition allows *r* to equal any integer value (otherwise it returns undefined _ _)

but could you make a python program to delet the lag from [email protected]

cool will wait for it see ya @LizFoster

as you wish @LizFoster

@luffy223 Alright, so I am a bit confused as to how I would go about saying:

`*f(-r + (a-b/n) x i)*`

or

`*f(l_i)*`

Obviously, I understand how to do the inner workings, but is there something specific I must do to add in the *f()* part?

Also, funnily enough, if you multiply the second part of the Riemann sum by *(τ x 10^3)*, it does the same thing as *f()* does. However, since *τ* is just *2π*, I'd hardly count that that as a win.. (Lol)

mmm to be honst i didn't understand your question (hahaha) mybe def F(): @LizFoster

this is how I undertanded your [email protected]

yeah and there are three types of xi :

ri = a+ idelta(x)

li = a+ (i-1)delta(x)

mi = a + (i-0.5)delta(x)

for simpson rule I used to xi typs :

li

and oi = a+ (2i-1)delta(x)@LizFoster

niiicccceee

@AgastyaSandhuja Thank you!

ok this is unrelated but that response was FAST @LizFoster

@AgastyaSandhuja Lol (^ ^ )

I was active at that second.

BTW did you get the value of φ

from

ΔΔG D-N < 1.7 ?

@LizFoster

@AgastyaSandhuja How interesting. No, I did not use that; I merely calculated it via the formula (√5 + 1) / 2. However, this looks intriguing, and I'll do some reading on that!

Yes it's interesting! It is in equa6 in your code, but whatever you say :p @LizFoster

@AgastyaSandhuja What I meant is, I have not heard it in that context ^ ^*

oh. gotcha. @LizFoster

Lines 5 and 6 are scaring me why do you need to know the amount of days in a week and amount of days in a year?

Edit: oh. Um.

@Highwayman Ha ha ha! For the sixth equation, it uses weeks and year as units (which in my opinion is incredible. Why do units of time produce π?!).

@LizFoster my first(reasonable) thoughts were about how the earth circles the sun, creating such schedules..?

@Highwayman Ooh, that's a good point! I can see it now..

@LizFoster :P that would be so cool if there is an actual correlation.

@Highwayman Yes, it would be!

Actually, a lot of methods of pi do include the earths orbit and time.

@Highwayman @LizFoster

oh wait that's in your program xD

AgastyaSandhuja like yeet

@Highwayman @AgastyaSandhuja Ha ha ha! I am still interested as to why it is used (and why it works..)!

Me too! Again. fast response. (2 seconds) how do you type so fast?

@LizFoster

@AgastyaSandhuja Lol

I'm just active at the moment, and I see the notifications pretty fast.

JS https://repl.it/@StudentFires/pJS,

C++ https://repl.it/@StudentFires/pC

That is the result of a tutorial on memoization, hours of work on converting loops to recursion, converting mathematical summation and product notation to code, then to recursion, and plenty of Desmos graphing and more.

I'll be back on Repl in about 5 hours.

@StudentFires Sorry, had to take care of something ^ ^*

Nice! Looking good

@LizFoster Eh, I wasn't on Repl. Also back when I did this I removed plenty of redundancies from the Riemann Sum formula that you posted earlier.

@StudentFires Oh, huh. I can see what you mean, those would vastly improve the formula aesthetically. Is it any faster?

@LizFoster Never implemented it, but I'm pretty sure `r-(-r)`

is probably slower than `2r`

.

@StudentFires Hm. I'm not fully sure what is going on there, can you write it out on Desmos?

(In response to your other post about a different algorithm)

@LizFoster That algorithm was wrong, I did it in JavaScript a few minutes ago, so I deleted it.

@StudentFires Ah, okay (Lol)

That would explain why I could not comment on it wwwww

Do you know if this an effective way to calculate π?

I believe I'd need `p(n)/n`

to calculate for π after the function.

`p(z) = ProductNotation(n=1, (2n/(2n-1))^2, z);`

`π = p(∞)/∞`

Update:

@StudentFires Yes, actually! That formula is incredibly similar the Wallis Product (the second part of the product has a '+ 1', not a '- 1')!

@LizFoster Well, since it works, I’ve converted it to a recursive function, thus I can memoize it... That or I’ll do it C++.

Also what has a `+1`

?

@StudentFires

(Also I just remembered, the Wallis Product results in *π*/2, and this results in approximately *π* when multiplied by some large number, m, which is the number of iterations)

Sweet! I can't wait to see it!

@LizFoster That’s why your example divided by `m`

, and I divided by `z`

. Also, 2π is more important that π itself, but I forgot its name. Also, usually `i`

or `k`

are used as the counters in Product Notation and Summation, so I should fix my examples.

@StudentFires Oh, it is called τ (tau)!

@LizFoster Yeah that... “Tau”. That’s far more important that Pi itself.

@StudentFires Yes, it certainly is. However I haven't done much reading on it as I'm quite fond of *π* (as you can tell wwwww)..

@LizFoster I assume you don’t know JavaScript? I'm failing miserably right now.

@StudentFires Ah, alas, I do not. I've been considering learning it though..

If you need help you should try your luck on Stack Overflow, or just post on the Ask forum. ^ ^*

@LizFoster The Ask forum here isn't really active, and yesterday I asked two questions on StackOverflow, no one answered either of them, not even a comment.

@StudentFires Oh, that's weird. Normally you get at least *one* comment... Maybe it was a really active/really inactive moment? Your questions might have drowned in a sea of other questions, but I don't go on there too often, so I wouldn't know.

@LizFoster It was drowned fast, yeah.

@StudentFires Darn, that sucks, I am sorry T~T

@LizFoster Update, actually my code was perfectly formed... but I forgot to put a semicolon. https://repl.it/@StudentFires/PreciousAssuredPi, And what a coincidence, I haven't even renamed the Repl yet.

@StudentFires Ha ha ha! Happens to the best of us (I say from experience, I've gotten hung up on things, only to find that it was failing from a basic syntactical error)..

Looks good! Can you allow it to take a user input for the iterations? It is fairly inaccurate in its current state.

Really fast either way!

@LizFoster Yeah, I updated it to be interactive a minute after I told you.

@StudentFires Sorry for the late response, had to eat breakfast ^ ^*

Ah, nice! It actually takes about as long to calculate

1 000 000 000 as Desmos does, so it's REALLY fast. Wow.

@LizFoster Don't worry, I wasn't even on Repl.it for a few hours, so I'm sorry for the late response. I updated it to C++ and never finished it, it has plenty of room to be faster and more precise, I'm getting on it right now!

Wait... breakfast, what continent are on?

@StudentFires Ah, all good. I'm excited to see how fast it is once you finish it (#w#)

Oh, nowhere wwwwww

@LizFoster I'm all the way in the ~~redacted~~. Is the virus bad where you are?

@StudentFires Not too bad (well, as 'not bad' as it can get with COVID-19) luckily. Is it bad where you are?

@LizFoster Hasn't even touched my city... yet. But it will, unfortunately, as it's very close.

But back to that formula I'm using, I thought about it and `2x/(2x-1)`

can be simplified to `x/(x-.5)`

, dunno why he didn't do this himself.

@StudentFires Wouldn't that just give half the result though?

@StudentFires Oh, shoot, nevermind. I am dumb _ _

You're right, that would work as well.

@LizFoster You aren’t *dumb*, now if you didn’t catch your own err, maybe.

But I’m pretty sure you’ve been taught a higher level of Mathematics than I’ve been taught, since I’ not even in pre-Calculus yet.

@StudentFires I re-consolidated the equation, so it looks a lot more clean now.

@LizFoster Bit late, I already have that. In to code too.

@StudentFires I suppose you're right.. ^ ^*

Trust me, calculus is a lot of fun; it is just that, most calculus teachers are really boring. You should watch 3Blue1Brown's "Essence Of Calculus" series if you are interested in that stuff. He explains it in an easy to understand way, and it's entertaining too (which cannot be said of most calculus teachers)!

@StudentFires Aaaaaa darn it! I felt cool for a second there T~T

@LizFoster Go look at the very top of this message chain. Carefully look at the first images I posted. I had the squared version in the very beginning.

*Always 1 step ahead*

@StudentFires T~T Rest in peace

Nice! You could also use sin and cos!

@codeitfast Thank you so much!

Yes, I could, but apparently they are based on *π* themselves.. I don't want to use things derived from *π* to **find** *π*

@LizFoster true. However, if you know calculus, you can also use it to find the area and then, when you have the area, since you have the radius, find pi.

@codeitfast Ooh, good point. As luck would have it, I *do* know calculus! (Lol)

@codeitfast Now, how exactly would I use *sin* for that? It has something to do with internal angles (at least, I would assume so), but otherwise I am in the dark..

@LizFoster you actually could just change x by something like .00000001 until you get 180, then use the Pythagorean theorem during each interval to find the circumference, and you could get pi.

@codeitfast Good point, though could you explain that a bit more? what is x an argument to? tan(x)?

Oh wow. It took 10 minutes to calculate the numbers.

@CodeABC123 What do you mean? It takes less than 3 seconds..?

Not for me. @LizFoster

Maybe you have a fast computer. @LizFoster

@CodeABC123 Oh, how weird. That's surprising, as I am on a fairly low-end chromebook (Lol)

I’m on an iPad. @LizFoster

@CodeABC123 Ah, I see, that probably explains it ^ ^*

Sorry it takes so long..

Im not a great programmer, but maybe you could use the leibniz formula? Where you start with an approximation of pi at 1, and then subtract 1/3, add 1/5, subtract 1/7. add 1/9, etc. That times four is pi. I have a repl for this on my profile if you're interested.

@cs906941 Funnily enough, I have that as well! You can find it here: https://repl.it/@LizFoster/140

One of the first approximations I made, actually, ha ha ha!

for equation 7 you are using sine, which is based on pi itself. You should look into some infinite sums, there are some really simple ones, like 1 + 1/4 + 1/9 + 1/16 + 1/25 + 1/36 (reciprocals of square numbers) and that infinite sum tends to ((pi)^2)/6

@finlay44111 Oh, I see, I did not remember that *sin* was based on π.

Is that series (the reciprocals of square numbers) by chance related to ζ(2)? I am not sure if they are related, but here is the equation I refer to (from the Wikipedia on ζ):

If not, what is that infinite sum called? It looks to be the same as the Basel Problem, which I think I have done.. (might be wrong though, Lol)

@LizFoster yeah that is exactly the series it is, it is riemann zeta function, you can actually get pi from any even value you pass into the riemann zeta function, eg, riemann-zeta(4) == (pi^4)/90

@LizFoster also the Basel problem is the same as the riemann-zeta(2)

@finlay44111 How interesting, I never thought about that!

@finlay44111 Okay, I thought so, but wasn't fully sure (Lol)

@LizFoster

I remembered someone who loved big numbers, so I thought you might like to see this: https://repl.it/talk/share/Using-Memoization-to-Speed-Up-Code/31937.

@StudentFires Oh wow, that's awesome! I'll try to puzzle my way through the code (^ ^**) (Lol)

@LizFoster The only problem is, I'm not sure if Python can return functions, so this might not be possible in Python, but I might be able to find a way to calculate π quickly.

@StudentFires Wait, do you mean printing functions that return a value? Python can do that if so.

@LizFoster Well then, perfect! The idea can be implemented in Python. *Sorry, I don't know Python... yet.*

@StudentFires That's perfectly fine, don't worry about it!

Ha ha ha.

I'll see what I can do about getting one written for python... Right after I finish writing a code for finding all Pythagorean Triples with side c being 50 or less

I am going to have a long night.... T~T

@LizFoster Unless you're trying to challenge yourself on purpose, I suggest leveraging the internet to reduce your workload. Just maybe your night won't be as long.

@StudentFires Yeah, you're right... (￣ヘ￣); It would make things a lot easier, ha ha ha

I do not even have to do this tonight, I just hate having to take more than a day to finish stuff like this. (Lol)

~~1004 decimal places get on my level~~

Those Unicode character variable names are astonishing.

@IreoluwaRaufu Really? (Lol)

@LizFoster Yeah, they inspired me to experiment with variable identifiers, and there's actually a wide range of characters you can use to name a variable, list, or other data structure in Python3. (The more ya know.)

@IreoluwaRaufu Yeah! Although, I still need to check if Japanese symbols are valid. Probably not ^ ^*

They can be more accurate. Also, more a more precise value of "year," use 365.25, or find a more accurate decimal.

how did i know this would happen lol

@LiamDonohue Expect more to come (*^*)

yup next thing i know u will be doing quantum physics lol @LizFoster

@LiamDonohue Don't even get me started... (Lol)

Amazing, I've never seen this many pi approximations in one program in my life!

Great and interesting as always!

@CodingCactus Thank you! I try my best (Lol) ^ ^*