In Bug 2910437
<https://sourceforge.net/tracker/index.php?func=detail&aid=2910437&group_id=4933&atid=104933>,
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.
Ray