Page 1 of 1

How to find "pi" after armageddon

Posted: Sat Aug 18, 2018 12:39 pm
by Henko
After armageddon, you find yourself in a desert. Your first priority is to re-establish the value of pi (i don't know why, but that's how it is). Find a branch (a piece of wood) and draw a number of equidistant lines in the sand, the distance being precisely the length of the branch.
Then start throwing the branch in the area with the lines.
Jot down the total number of throws and the number of cases in which the branch crosses (hits) one of the lines. After a sufficient number of tries, the following quotient:
2 x total tries / hits will approximate the value of pi.

Code: Select all

option angle degrees
graphics ! graphics clear 1,1,1 
get screen size w,h
cx=w/2 ! cy=100+w/2 ! ww=100*floor(w/100)
xo=(w-ww)/2 ! n=20 ! b=ww/n ! b2=b/2 ! e=ww-b ! e2=e/2
draw size 3 ! draw color 0,0,0
draw rect xo,100 to xo+ww,100+ww
field "result" text "" at 20,20 size ww-20,70 RO ML
field "result" font size 24
draw size 1 ! draw alpha .4 
for i=1 to n-1
  draw line xo,100+i*b to xo+ww,100+i*b
  'draw line xo+i*b,100 to xo+i*b,100+ww
  next i
draw size 1 ! draw alpha 1
for i=1 to 5000
  x=cx+e2-rnd(e) ! y=cy+e2-b-rnd(e) ! ang=rnd(360)
  dx=b2*cos(ang) ! dy=b2*sin(ang)
  y1=y-dy ! y2=y+dy ! draw line x-dx,y1 to x+dx,y2
  r=abs(floor((y1-100)/b)-floor((y2-100)/b))
  tot+=1 ! pi+=r ! div=max(1,pi)
  t$="total= "&tot&", hits= "&pi&chr$(10)&"    pi="&2*tot/div
  field "result" text t$
  pause 2/i
  next i
end
IMG_1547.PNG
IMG_1547.PNG (1.57 MiB) Viewed 3394 times

Re: How to find "pi" after armageddon

Posted: Sun Aug 19, 2018 8:30 am
by Dutchman
:idea: :!: :lol:

Re: How to find "pi" after armageddon

Posted: Sun Aug 19, 2018 4:41 pm
by Mr. Kibernetik
After armageddon PI number will be also damaged...

Re: How to find "pi" after armageddon

Posted: Mon Aug 20, 2018 6:03 am
by Henko
I wonder if the number e can be reconstructed in the desert with an arbitrary piece of wood.
Anybody?

Re: How to find "pi" after armageddon

Posted: Wed Sep 05, 2018 5:02 pm
by rbytes
Pi will never be forgotten as long as I have one of these!
12101BCE-DD26-4A95-A06F-8E1A6A09406E.jpeg
12101BCE-DD26-4A95-A06F-8E1A6A09406E.jpeg (106.97 KiB) Viewed 3325 times