hexagon logo

Another way to get Pi

Maybe it's a question that you can ask only after some beers : why does Pi has an infinity decimal places ?
I don't have the real answer, my approach is to say that it can calculated by summing a lot of little circle chords. (It has been my answer, long time ago, very late on a 31 december... and the drinks weren't beer Slight smile).
In fact, you can calculate a chord, create a segment perp to the chord by the middle, calculate a new chord... and add all the lengthes to calculate Pi.
Whatever the size of the chord, you can cut it to calculate another one smaller... at the infinity.



You can clearly do it with an assignment Slight smile !

This code just gives the difference between PI and the approximation described above.

ASSIGN/WI=0
ASSIGN/REAL_PI=ACOS(-1)
V1=LOOP/START,ID=YES,NUMBER=15,START=1,SKIP=,
OFFSET:XAXIS=0,YAXIS=ZAXIS=,ANGLE=
ASSIGN/AI=SQRT(2-WI)
ASSIGN/WI=SQRT(2+WI)
ASSIGN/PI_I=(2^V1)*AI
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
FORMAT("%1.12f",(REAL_PI-PI_I))
LOOP/END



As usual, it's not very usefull, but it can make your next New Year's Eve fun... Why not ? Wink