go home

the ring

prev: snail
next: neon

full directory here


the bug

my music youtube

my tumblr

a third site

nifty trick i figured out for approximating π just a little better

happy π day! i wanted to share a tiny little idea i came up with that lets me approximate π surprisingly well with an infinite series that quite frankly sucks.

you may be aware that π = 4/1 - 4/3 + 4/5 - 4/7 + 4/11 ...
you may also be aware that working this out by hand is not a fast way to calculate π at all - it doesn't even think about starting with 3.14 until term 121.
if you weren't aware of either of these facts, well, congratulations on learning new useless knowledge! i can only imagine that's what you came here for in the first place.

now something i noticed is this series always overestimates π, then underestimated π, then overestimates, then underestimated, over, under, over, under, always alternating, and not getting much closer each time. so, simply, if you take the average of two consecutive iterations, you will get far closer than either of them. in fact, if you average the 9th and 10th iterations, you will get more accurate than the original series gets in 115 terms. now that's pretty amazing.

and you can even take averages of these averages to get a little closer! these averages are always skewed a little towards the earlier term, by virtue of that term being slightly further from π, so the same trick works incredibly well once again! and you can keep iterating averages of averages of averages for as many layers as you have iterations of the original series! that means that if you really want, you can approximate π with less than 0.02% difference without ever worrying about anything divided by 17. if that isn't the absolute dream, i don't know what is.

but let's go back to the first level of averaging, because there's another idea i'm unfortunately not able to properly explore. remember how these averages are usually skewed towards the earlier of the two iterations? something i've been wondering is whether there's some way to take a weighted average of the two, putting slightly more weight on the second of them, to get an even better approximation of π. and i guess more importantly, is there some way to figure out how much to weight it, to get as close as possible to π? (obviously i can't imagine you'd get an exact value here. this number ain't transcendental for nothing)

...if you read all this, and more impressively, understood what the heck i was yapping on about, thanks :]