Free Republic
Browse · Search
News/Activism
Topics · Post Article

To: Bill Rice
That's because your computer probably rounded them both to about 4 or 5 places when you "checked" it. I don't think they take it any further.

No, I specifically used Rexx where I can set the numeric digits to any significance I want. I had the Pi program already, and I just fed the answer to the SQRT function that is a part of the PI program. I have compared the output to published lists of Pi digits, and it is accurate. I think that the differences beyond 1000 digits of Pi are too small to show up in the calculation of the square root at that point.

Here is the program:

/* Square root of Pi to digits places/2 */
parse arg places
numeric digits places /* Number of places for PI calculation */
number_pi=PI(places)
sroot=sqrt(number_pi,places/2) /* half the number for the square root */
lineout("sroot.txt",sroot) /* Output to file for cutting and pasting */
exit

PI: procedure
parse arg P
if P = "" then P = 9; P=P+3; numeric digits P
X = SQRT(2, P); Pi = 2 + X; Y = SQRT(X, P); X = Y
do forever
X = 0.5 * (X + 1 / X)
NewPi = Pi * (X + 1) / (Y + 1)
if Pi = NewPi then return trunc(Pi,P-3)
Pi = NewPi
X = SQRT(X, P)
Y = (Y * X + 1 / X) / (Y + 1)
end

SQRT: procedure
parse arg N, P
if P = "" then P = 9; numeric digits P
parse value FORMAT(N,,,,0) with N "E" Exp
if Exp = "" then Exp = 0
if (Exp // 2) <> 0 then
if Exp > 0 then do; N = N * 10; Exp = Exp - 1; end
else do; N = N / 10; Exp = Exp + 1; end
X = 0.5 * (N + 1)
do forever
NewX = 0.5 * (X + N / X)
if X = NewX then return X * 10 ** (Exp % 2)
X = NewX
end

225 posted on 12/08/2001 9:08:04 PM PST by Excuse_Me
[ Post Reply | Private Reply | To 218 | View Replies ]


To: Excuse_Me
Kewl! Back in the late 80's, my guru was called into a company who had just spent 6 figures on an expensive measuring device that was giving them fits. They made bearings or something.

It was supposed to log a bunch of measurements, do Chi-square stuff, and then tell them when it was time to retool.

It was taking and logging the measurements to 6 places, but then they were turning out big batches of rejects - and it wasn't ever popping up any flags to retool.

He determined that while the actual measuring device was accurate and functioning, the cheeseball computer (Probably a 286), that came with it was rounding all those super precise numbers, and then butchering up the math with even more rounding in the statistical analysis process.

He ended up selling them a clone system, and writing them a program that did something like you did to keep the extra places.

236 posted on 12/08/2001 9:34:26 PM PST by Bill Rice
[ Post Reply | Private Reply | To 225 | View Replies ]

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson