Maxima, symbolic computation and fpprec



If you are doing 
fpprec:32$
bfloat(expression); <-- printf( .. ~h .. ) does this
you cannot expect, that your result is correct in 32 digits, you only
can be sure, that the calculation has been done with a precision of 32,
which is about 100 bits.

Your expression is rather complicated after doing thousands of
iterations. A different precision of the calculation results in
different digits even in the first ten digits.

In contrast, if you are doing 
fpprec:32$
bfloat(%pi);
you can be sure that the result is correct in 32 digits due to the
algorithm that is used in this computation (which is basically a big
integer calculation).

HTH
Volker van Nek

Am Donnerstag, den 25.02.2010, 05:07 +0100 schrieb Prof. Dr. Jochen
Ziegenbalg:
> 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima