# [Maxima] roundoff errors

Raymond Toy toy.raymond at gmail.com
Fri Mar 13 08:51:38 CDT 2009

Volker van Nek wrote:
> Ray, in your example just take fpprec 26, which I believe is correct,
> because you want 26 valid digits.
>
> (%i1) fpprec:26\$
> (%i2) 1b0+1b-25;
> (%o2)                    1.0000000000000000000000001b0
>
Heh.  Ok.  Change the example to x : 1b0+10b0^(-fpprec).  For the few
cases I tried, maxima prints 1b0, but x-1b0 is non-zero.

>
> Remembering the PI computations I did some time ago I found that time that
> fpprec is very precise. E.g. the following shows that a correct rounding was
> made at the 30. valid digit.
>
> (%i4) fpprec:30\$
> (%i5) bfloat(%pi);
> (%o5)                  3.14159265358979323846264338328b0
> (%i6) slength(string(%));
> (%o6)                                 33
> (%i7) fpprec:32\$
> (%i8) bfloat(%pi);
> (%o8)                 3.1415926535897932384626433832795b0
Isn't this because bfloat(%pi) calls fppi1 which calls comppi with 12
extra bits of precision and then rounds the result to the desired precision?

Ray