🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #678

Re: Buffon's Needles

#678
From: Dr John Stockton
Date: Thu, 24 Jun 1999 00:00
35 lines
2662 bytes
JRS:  In article <7ks8ls$mgk$1@bgtnsc03.worldnet.att.net> of Wed, 23 Jun
1999 22:24:59 in news:comp.lang.pascal.delphi.misc, Earl F. Glynn
<EarlGlynn@att.net> wrote:
>An updated "Lab Report" about estimating the value of pi
>by "throwing" needles on a set of parallel lines can be found at:
>
>http://www.efg2.com/lab/Mathematics/Buffon.htm
>
>The example includes complete Delphi source code and a
>complete description of the mathematics and the various
>methods of randomly "throwing" the needles.

The following will do it, in BP7 and D3 DCC32 -cc modes :

  var U, V, W : longint ;
  begin V := 0 ; W := 10000000 ; Randomize ;
  for U := 1 to W do if cos(Random*Pi*0.5)>Random then Inc(V) ;
  Write(2.0/(V/W):0:6) ; Readln ;
  end.

This represents a needle of length 2 thrown on planks spaced by 2, and
tests whether the projected half-length of the needle exceeds the
distance between the centre and the nearest line.

It will be interesting to see whether you've managed to avoid using a
value for Pi, implicitly or explicitly, in the work.

A quick test shows that the result obtained from the above code depends
on, but is not proportional to, the value used for Pi.
 
-- 
 � John Stockton, Surrey, UK.  jrs@merlyn.demon.co.uk   Turnpike v4.00   MIME. �
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.
Technical Details
Message-ID: <Im0c0MABmjc3Ew2K@merlyn.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7ks8ls$mgk$1@bgtnsc03.worldnet.att.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 109585,d24982a2aa52a35f
X-Google-Attributes: gid109585,public
X-Google-Thread: 10a7f1,d24982a2aa52a35f
X-Google-Attributes: gid10a7f1,public
X-Google-Thread: 10a726,d24982a2aa52a35f
X-Google-Attributes: gid10a726,public
X-Google-Thread: 10baee,d24982a2aa52a35f
X-Google-Attributes: gid10baee,public
X-Google-Thread: 105ac8,d24982a2aa52a35f
X-Google-Attributes: gid105ac8,public
From: Dr John Stockton <jrs@merlyn.demon.co.uk>
Subject: Re: Buffon's Needles
Date: 1999/06/24
Message-ID: <Im0c0MABmjc3Ew2K@merlyn.demon.co.uk>
X-Deja-AN: 493468441
Content-Transfer-Encoding: 8bit
X-NNTP-Posting-Host: merlyn.demon.co.uk:158.152.233.145
References: <7ks8ls$mgk$1@bgtnsc03.worldnet.att.net>
Content-Type: text/plain;charset=iso-8859-1
X-Complaints-To: abuse@demon.net
X-Trace: news.demon.co.uk 930249524 nnrp-10:15504 NO-IDENT merlyn.demon.co.uk:158.152.233.145
Organization: Home, Surrey, UK
MIME-Version: 1.0
Newsgroups: comp.lang.pascal.delphi.misc,alt.comp.borland-delphi,de.comp.lang.pascal.delphi,fr.comp.lang.pascal,es.comp.lenguajes.delphi