\begindata{text,538290320}
\textdsversion{12}
\template{help}
\define{global
}
\chapter{Circle pi:  an ATK inset for estimating pi

}
\section{What circlepi is

}\leftindent{
Circle pi is an ATK inset which graphically displays the recursive progress of 
an algorithm for estimating the value of pi.  It runs in color on color 
displays.

}
\section{Starting circlepi

}\leftindent{
You can start a Circle pi by inserting into an ATK document, like any other 
inset.  Specifically, in a text document, type \bold{<Esc> <Tab>}, and answer 
the prompt at the bottom of the screen for the name of the inset with 
"\typewriter{circlepi}".  A Circle pi inset will appear at the insertion point 
of your document, and estimate the value of pi.

}
\section{Warnings

}\leftindent{
You can set the recursion level of Circle pi through the Depth Limit menu. 
 Since ATK is not multi-threaded, asking Circle pi to deeply recurse means 
that you will tie up the process which holds Circle pi until it Circle pi 
finishes redrawing itself.  Each level requires three times the computation of 
the previous level, so jumping four levels takes 81 times as long to compute!

}
\section{Pop-up menu meanings

}\leftindent{
The Depth Limit menu allows you to choose how deep Circle pi will recurse in 
its computation.  Levels > 7 can take a long time to compute, but will yield 
more accurate results.

}
\section{How circlepi works

}\leftindent{
Circle pi attempts to measure the area inside and outside of a circle 
recursively.  It starts with the center point of a unit square, and tests that 
point:

\center{\
\begindata{eq,538268296}
{ lpile d_eqstyle { root { x sup { 2 } + y sup { 2 } } < r sup { 2 } , thick r = 1 } } \enddata{eq,538268296}
\view{eqview,538268296,115,170,0}
}to determine whether it lies within or outside of the perimeter of the 
circle.  If it is inside, the northwest quadrant's area is added to the inside 
sum, and the algorithm recurses on the southeast quadrant.  If it is outside, 
the southeast quadrant's area is added to the outside sum, and the algorithm 
recurses on the northwest quadrant.  Recursion on the northeast and 
southwestern quadrants are also performed.


Since we now have two estimates of the area of the circle (one from the 
inside, and one from the outside), we can estimate pi as follows:

\center{\
\begindata{eq,538268488}
{ lpile d_eqstyle { pi = 4 * { cpile { A } over { r sup { 2 } } } , } } \enddata{eq,538268488}
\view{eqview,538268488,116,102,0}
}where \italic{A} is the inside or outside area we've measured, and \italic{r} 
is the radius of the circle (or one in our case).  We multiply by four since 
we're only measuring a quarter circle.


What this algorithm also gives us is a measurement of how much we don't know, 
and this value can be used to determine the error in our estimate.

}
\section{Program Author}

\leftindent{
}\leftindent{Michael McInerny,

Information Technology Center

}
\section{Related tools}  


Select (highlight) one of the italicized names and choose "Show Help on 
Selected Word" from the pop-up menu to see the help file for:


\leftindent{\helptopic{insets}

\helptopic{eq}}


\begindata{bp,537558784}
\enddata{bp,537558784}
\view{bpv,537558784,118,0,0}
Copyright 1992 Carnegie Mellon University and IBM.  All rights reserved.

\smaller{\smaller{$Disclaimer: 

Permission to use, copy, modify, and distribute this software and its 

documentation for any purpose is hereby granted without fee, 

provided that the above copyright notice appear in all copies and that 

both that copyright notice, this permission notice, and the following 

disclaimer appear in supporting documentation, and that the names of 

IBM, Carnegie Mellon University, and other copyright holders, not be 

used in advertising or publicity pertaining to distribution of the software 

without specific, written prior permission.



IBM, CARNEGIE MELLON UNIVERSITY, AND THE OTHER COPYRIGHT HOLDERS 

DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 

ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT 

SHALL IBM, CARNEGIE MELLON UNIVERSITY, OR ANY OTHER COPYRIGHT HOLDER 

BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 

DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 

WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 

ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 

OF THIS SOFTWARE.

 $

}}\enddata{text,538290320}
