Fwd: Maxima, symbolic computation and fpprec



Dear Maxima users,

in the mail below, I had overlooked the fact that the very last step
within printf, i.e. converting the (possibly very complex) symbolic
expressions into numeric values, may very well depend on the value of
fpprec.
Sorry for the inconvenience.

Jochen Ziegenbalg


---------- Forwarded message ----------
From: Prof. Dr. Jochen Ziegenbalg <ziegenbalg at ph-karlsruhe.de>
Date: Thu, Feb 25, 2010 at 5:07 AM
Subject: Maxima, symbolic computation and fpprec
To: maxima at math.utexas.edu


Dear Maxima users,

the following program is a simulation of the computation of Pi
according to Archimedes in the form of Christian Wolff.

Pi_Archimedes_Wolff(steps) :=
?block([r:1, se, su, ue, uu, i, n:3],
? ?se : sqrt(3), ?/* initial values ? ? ? ? ? ? */
? ?ue : 3 * se, ? /* for the "triangle"-polygon */
? ?su : 2 * sqrt(3),
? ?uu : 3 * su,
? ?printf(true, "~2d ~10d ~13, 10h ~13, 10h ~43,
? ? ? ? ? 40h ~%", 0, n, ue/2, uu/2, se*se),
? ?for i : 1 step 1 thru steps do
? ? ?(n ?: n * 2,
? ? ? se : r*sqrt(2-2*sqrt(1-(se/(2*r))*(se/(2*r)))),
? ? ? ue : n * se,
? ? ? su : se / sqrt(1 - (se/(2*r)) * (se/(2*r)) ),
? ? ? uu : n * su,
? ? ? printf(true, "~2d ~10d ~13,10h ~13,10h ~43,
? ? ? ? ? ? ?40h ~%", i, n, ue/2, uu/2, se*se) ),
? ?(ue/2+uu/2)/2 );

All the computations are done symbolically - except for what is done
in the "printf" lines. ?But whatever is done there - it should not
influence the value of the (local) variables. ?If this were so, the
printed lines should be the same for different values of fpprec. ?But
they are not. ?For instance, running the program (with steps > 12) the
default value of fpprec results in a printout quite different from
running the program, for instance, with fpprec : 100.
I would be very grateful for an explanation of this phenomenon.

Thank you very much,
Jochen Ziegenbalg