Am Dienstag, den 08.12.2009, 07:27 -0500 schrieb Raymond Toy:
> In Bug 2910437, the value of beta_incomplete(1b0,1,z) changes. On
> further inspection, this is caused by the caching in FPE. As
> explained in the bug, what is happening is that fpprec is 56, and the
> cached value of bigfloat %e is used. But one call has fpprec = 57, so
> a new value of %e is computed. This is ok. But the next call to
> beta_incomplete has fpprec = 56, so the 57-bit cached value is rounded
> to a 56 bit value. This rounded value is off by one bit from the
> original value.
>
> I don't think we should do this. I can see three solutions:
>
> 1. Always recompute the value. We probably don't want to do
> this.
> 2. Cache the most recent value. If fpprec changes, recompute %e
> and save that. This should fix the roundoff problem.
> 3. Cache all computed values, and use the cached value when
> possible or compute a new value when needed. This should fix
> the roundoff problem too.
> Option 2 is simple and has (almost) fixed space usage, but potentially
> large speed consequences. Option 3 is relatively simple, but could
> consume a large amount of memory caching the values, but is very fast
> except when a new value is computed. I think I prefer option 3, but I
> don't really have any idea how often new values are computed.
>
> Also, I don't have any examples for %pi or %gamma, but surely there
> are similar roundoff problems. Whatever solution is chosen for %e
> should also be used for %pi and %gamma.
Is it correct, that we have to cache one value of the constants %e, %
gamma, ... for every value of fpprec?
If this is the case I can not imagine that we need to store a lot of
values. We have the standard value fpprec = 56 and some extra values
because of extra digits we use in some calculations. A user who change
the value of fpprec will need the same amount of extra values for his
choice of fpprec.
The only code I knew which might changes the value of fpprec more than
once is the the code for the hypergeometric functions. I think fpprec
can be stepwise doubled up to a value of fpprec=1000. But this is done
in four steps.
Perhaps, it is possible to flush the cache, when a user changes the
value of fpprec very often.
But I might be wrong. I do not know much about the bigfloat algorithm.
Dieter Kaiser