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

To: Excuse_Me
"When I recalculated it taking the square root of Pi to 2000 places and calculating the answer to 1000 places it was exactly the same."

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.

218 posted on 12/08/2001 8:47:10 PM PST by Bill Rice
[ Post Reply | Private Reply | To 213 | View Replies ]


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 ]

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