Dieter Kaiser wrote:
> Am Dienstag, den 08.12.2009, 09:55 -0500 schrieb Raymond Toy:
>
>> Bug 2910001 lists an issue with slow conversion of bfloat inputs. Yes,
>> for bfloats with 1 million digits, the conversion from the input form to
>> a bfloat is slow.
>>
>> This is caused by how maxima does the conversion. The example in the
>> report is 3.4b5000000. Maxima essentially compute 34/10*10^5000000.
>> This computation is pretty slow. The conversion to bfloat of that
>> rational number is quite fast.
>>
>> I like this method because we get exactly one rounding operation and the
>> result is a close as possible to the actual input.
>>
>> The only other way I can think of is to compute the result as
>> bfloat(34/10)*bfloat(10)^5000000. This is fast, but we get two rounding
>> operations (34/10) and the multiplication, and then whatever rounding we
>> get from computing 10^5000000. Perhaps this is acceptable.
>>
>> Opinions?
>>
>
> On my notebook with CLISP 2.44 I get an overflow for the given example.
>
> (%i10) 3.4b5000000
> Maxima encountered a Lisp error:
>
> overflow during multiplication of large numbers
>
Probably because 10^500000 is some 16 million bits long.
> Automatically continuing.
> To enable the Lisp debugger set *debugger-hook* to nil.
>
>
> But this works:
>
> (%i15) bfloat(34/10)*bfloat(10)^5000000;
> Evaluation took 0.0040 seconds (0.0025 elapsed) using 6.352 KB.
> (%o15) 3.400000000006349b5000000
>
This result is why I don't like computing the input this way. It is
quite a bit off from the original input number. Perhaps we can get more
accurate results if we temporarily increase fpprec, but some care needs
to be taken. And it would be difficult to get all the rounding to work
out so that the same result is given as before.
>
> For the following number it works too:
>
> (%i16) 3.4b600000;
> Evaluation took 0.0000 seconds (0.0002 elapsed) using 88 bytes.
>
I noticed that showtimes doesn't include the time and space for
processing the input. For me, that takes several seconds, but showtimes
says 0 sec.
It's unfortunate these are slow, but I don't really know how to do it in
a way that doesn't have extra roundoff.
Ray