How to find "pi" after armageddon

Post Reply
Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

How to find "pi" after armageddon

Post 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 3396 times

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: How to find "pi" after armageddon

Post by Dutchman »

:idea: :!: :lol:

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: How to find "pi" after armageddon

Post by Mr. Kibernetik »

After armageddon PI number will be also damaged...

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: How to find "pi" after armageddon

Post by Henko »

I wonder if the number e can be reconstructed in the desert with an arbitrary piece of wood.
Anybody?

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: How to find "pi" after armageddon

Post 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 3327 times
The only thing that gets me down is gravity...

Post Reply