Share your repls and programming experiences

← Back to all posts
##### Pi but not... Just read plz

So I was really bored with this whole stay at home stuff and I saw @LizFoster 's pi approximations.

I decided to try to create my own formula infinite series thing.

I started trying to use the unit circle and triangles but I don't know hardly any trig.

I then switched to using points, the distance formula, and the unit circle.

Basically what this program does is generate a lot of points on the unit circle and then calculates the distance between them.

When I tried with 1,000,000 iterations, the result was about 3.1399. It's not that accurate as you can see...

EDIT: I just edited it and tried again with 1,000,000 iterations, and it ended up being 3.1415926533 so it is a lot more accurate now

If I copied some one else's thing, please tell me.

Also, check out this game: https://repl.it/talk/share/Experiment-44-a-text-based-RPG/32658

hotnewtop
LizFoster (648)

Wow! That's cool! It really is very inaccurate, but interesting nonetheless! #^__ ^#

I haven't seen it done this way, but it's a bit funny, honestly!

Good work, really!

LizFoster (648)

### :)

CodingCactus (4192)

@XanderEhlert
That's my favourite way of approximating pi

LizFoster (648)

@CodingCactus It's probably the fastest method out there, why aren't they using this for the world record approximations?!

XanderEhlert (152)

@CodingCactus thank you for spelling favourite right

CodingCactus (4192)

@XanderEhlert Thank you, I try my best
@LizFoster no idea, maybe they just aren't that skilled at python/maths as i am? lol :)

CodingCactus (4192)

I just realised that lol looks like a t.i.e. fighter from star wars. Kinda

CodingCactus (4192)

@XanderEhlert I'm doing
999999999
Iterations, how long will that take?

XanderEhlert (152)

@CodingCactus yeah ummm...
i might have an idea to fix that?

CodingCactus (4192)

@XanderEhlert awww

# :(

XanderEhlert (152)

@CodingCactus basically if you dont enter a number it quits the program

CodingCactus (4192)

@XanderEhlert oh, cool. I didn't know that you could do that

XanderEhlert (152)

@CodingCactus its output was 0.9 something

CodingCactus (4192)

@XanderEhlert hmm..................................................................................................

CodingCactus (4192)

@XanderEhlert I recon some people in the world would say that it is

CodingCactus (4192)

@XanderEhlert please could you put the whole thing in a loop so that I don't have to press run every time? :>

XanderEhlert (152)

@CodingCactus shush i was getting a drink

CodingCactus (4192)

@XanderEhlert sure, but you have to include my approximation :)

XanderEhlert (152)

@CodingCactus bc its not a while loop anymore you can type any number...

DynamicSquid (4634)

@LizFoster Actually it depends on how long you run the code for. If you modify it a little bit and have the code run on a loop, and can actually get pretty close to PI!

LizFoster (648)

@DynamicSquid Well, of course. That is how all π approximations with sigma or PI work..

Codemonkey51 (1048)

This is really cool! I applaud you trying to find your own formula.

cool, unconventional tho. You should try using java bigdecimal library.

Jakman (450)

pi = 22/7
print(pi)

Jakman (450)

@XanderEhlert yeah pi is 22/7 so thats all there is to it

DynamicSquid (4634)

This is actually really cool! I also made a tutorial on this actually if you want to check it out!

xolyon (343)

what is it with all these new Pi thingies I made mien unaware of all these and can you pot image of formula?

xolyon (343)

@XanderEhlert all these new pi posts Poppin up , I made mine aware of the trend lol

AmazingMech2418 (1041)

This is actually a great method for calculating π, of course given that your square roots are accurate! I ended up getting 3.1415926533115135 as a result which is very close to 3.14159265358979323846264338327950288419716939. It seems like what you did was find the length of a 90 degree arc and then multiply by 2 to get π. That means that this is derived from the circumference formula which was, by the way, one of the first ways of approximating π which only later evolved into the modern algorithms and infinite series.

XanderEhlert (152)

@AmazingMech2418 yep thats basically what i tried to do

XanderEhlert (152)

I just realized...

It only does the distance between half the points...

im dumb

lets see if its more accurate after this

XanderEhlert (152)

@XanderEhlert wow its way more accurate now

JiahaoCao (11)

my repl got killed

XanderEhlert (152)

@StudentFires well

its looping however many times you type

if you do more than 10,000,000 it crashes bc repl doesn't want to load for that long for some reason...

xxpertHacker (871)

@XanderEhlert Yeah, ik. Good work nonetheless.