On 2/24/10 11:07 PM, Prof. Dr. Jochen Ziegenbalg wrote:
> 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
>
Well, if you wanted to know that the local (symbolic) variables are the
same, just print them out and compare them. (Or save them somewhere and
compare the results between two different runs.) I think you will find
them to be the same. What you are seeing is roundoff, I think.
The expressions get quite long and they're not arranged in the best way
for computation. So with limited precision, you get quite a bit of
roundoff. When you increase fpprec to 100, the roundoff is reduced
quite a bit and the results are more consistent because you're not
printing out the noisy bits.
Does that make sense?
Ray