SF [2159499] Full bigfloat precision for Gamma after the second call



Am 14 Oct 2008 um 18:18 hat Raymond Toy geschrieben:


> *** At this point maxima wants 438 bits of pi.  But fprt18231_ sees
>     $fpprec = 64 and therefore only computes 64 digits or about 215
>     bits.  We really want 438 bits.  I think it was a misunderstanding
>     about fpprec and $fpprec.  fpprec changes throughout the code and
>     is dynamically changed to produce the desired precision.  I think
>     sin is especially likely to increase fpprec so that it can do
>     range reduction accurately.

Ray, 

I think you are right here. When I wrote the code I wasn't aware of possible interferences 
with other functions concerning fpprec. More or less I only thought of a standalone 
computation of pi. Sorry for this stupidness! (Just for the record: The standalone 
computation I checked for at least 200000 digits.) 

If you need pi for e.g. $fpprec=64, then (fprt18231_) must be of the same precision. The 
loop starts with a precision of ten digits and will be finished when the precision is > $fpprec. 
But if you need a precision of fpprec=438, a use of $fpprec=64 is definitely wrong. 

I believe the problem is fixed when $fpprec is replaced by something like fpprec/3.3
So I propose the following fix. Please check it.

(defun fprt18231_ nil  
  (let ((a 1823176476672000)
        (n 42698670666) 
        (d 1000)     
        (p (ceiling fpprec 3.3)))    
     (do ((prec 10 (* 2 prec)))
         ((> prec p))
       (setq h n)
       (setq n (+ (* n n) (* a d d)))
       (setq d (* 2 h d)) )
     (fpquotient (intofp n) (intofp d)) ))

Volker