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!
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 :
(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:
So yeah, pretty accurate for how low n is ^ ^*
@luffy223 Alright, so I am a bit confused as to how I would go about saying:
*f(-r + (a-b/n) x 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)
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.
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 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!
@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)!
Oh wow. It took 10 minutes to calculate the numbers.
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.
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)
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.
Those Unicode character variable names are astonishing.
@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.)
They can be more accurate. Also, more a more precise value of "year," use 365.25, or find a more accurate decimal.