# [Maxima] bfloat hangs computer

Edwin Woollett woollett at charter.net
Wed Mar 18 18:01:27 CDT 2009

```On Wed, Mar 18, 2009  Robert Dodier wrote:
--------------------------------------------------
> 1b<foo> attempts to call (EXPT 10 <foo>) so when <foo>
> is a large integer (positive or negative), it is trying to compute
>  a very large integer or 1/(very large integer). I'm guessing that
>  when Maxima appears to hang, it is actually running EXPT and
>  just taking a very long time.
-----------------------------------
In fact Maxima has no problem returning exp(-10^n) for n equal
to 8 or larger. The problem is when Maxima is asked to
add (or subtract)  the number 1 to that tiny number
using bfloat( 1 + e) where e has been defined as exp(-bfloat(10^j) )
for j = 8 or larger.

default floats have no problem
----------------
(%i1) g1(j) := block([z,e],
z : float(10^(j)),
e : exp(-z),
print(j,z,e),
float( 1 +  e ) )\$
(%i2) for j:7 thru 9 do print(g1(j ))\$
7 10000000.0 0.0
1.0
8 1.0E+8 0.0
1.0
9 1.0E+9 0.0
1.0

But the same thing with bigfloats hangs with j = 8

(%i3) g2(j ) := block([fpprec,z,e],
fpprec:60,
z : bfloat(10^(j)),
e : exp(-z),
print(j,z,e ),
bfloat(1 + e) )\$
(%i4) for j:7 thru 9 do print(g2(j ));
7 1.0b7
1.51693678089873435758946378226101624640108558149085643695901b-4342945
1.0b0
8 1.0b8
6.45170969282176600884365482713563323969794742528138149981955b-43429449
(hangs...)

Clearly, we have printed out, so Maxima has computed, the tiny number
exp(-z),  so Maxima is taking a very long time (?) to do bigfloat addition.

-------------------------------------------
> At this point I think the stuff about the exp function or arithmetic
> is beside the point. I think if you just enter 1b<foo> for various
> values of <foo> sooner or later you'll find one that causes an error.
--------------------------------------------------------------
It looks like this is a trap I will have to keep in mind when using
bfloat with exponentials.

Thanks for the feedback.

Ted Woollett

```