[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOGO-L> Total Turtle Trip




Boy, have we bitten this dead horse or what.

Here is another take on the same subject.  It's an old trick, and I'd like
to apologize to the many readers of the group who have seen it before, or
perhaps even written about it in their books.

This time, the goal is not only to draw the circle's periphery, but also to
fill it.  And not only that, but we also want to measure the area of the
circle.  And not only that, but we want to compute the value of PI.  And
all that in a program with about a third of the number of lines that is
takes to explain it.

Sound like a lot?  Actually, it's rather easy using the KPBG (Alan Kay /
Piaget / Brian / George) formula below.  Consider a 200 x 200 square with
center at (0,0).  Now pick a random point in the square.  KPBG will tell
you whether the point is in the bounded circle (radius=100).  If it is,
draw a dot.  Otherwise, don't.  As you repeat this, keep a tally of the
points in and out the circle.   Knowing the area of the square, it's easy
to use the tallies to compute the approximate area of the circle.  And
knowing the circle's radius and the formula for a circle's area, it's easy
to compute PI.  If you have never seen this before, you'd be surprised at
the accuracy of PI that you can get.

To demonstrate the concept of convergence, you could print the computed
value of PI every so many iterations, while continuing the iterations.
Advanced students would at that point enjoy learning about how random
numbers are generated on computers and why the above method is limited and
cannot yield an arbitrary precision of PI.

Chuck Shavit

George Mills wrote:
> 
> > Brian Harvey wrote:
> >
> > And the 15-year-old has been taught x^2 + y^2 = r^2 and can't draw
> > a circle at all.  :-)
> 
> You can get pretty damn close using that very formula and a little
> bit of algebra. It's basically what they are told to do when they
> are asked to plot this curve on paper (i.e. plug in a few numbers
> and sketch it).
> 
> to circle :radius
> pu
> for [x -:radius :radius 1] ~
>   [
>   make "y sqrt ((:radius * :radius) - (:x * :x))
>   setxy :x  :y pd fd 1 bk 1 pu
>   setxy :x -:y pd fd 1 bk 1 pu
>   ]
> end

---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home