#9937: PARI real precision is broken in many ways
--------------------------+-------------------------------------------------
   Reporter:  jdemeyer    |       Owner:  was                                   
   
       Type:  defect      |      Status:  new                                   
   
   Priority:  major       |   Milestone:  sage-4.6                              
   
  Component:  interfaces  |    Keywords:  pari gp real precision 
set_real_precision
     Author:              |    Upstream:  N/A                                   
   
   Reviewer:              |      Merged:                                        
   
Work_issues:              |  
--------------------------+-------------------------------------------------
Changes (by jdemeyer):

  * keywords:  pari gp real precision => pari gp real precision
               set_real_precision


Old description:

> The following do not work as they should (try these examples with a
> freshly started copy of Sage, such that everything is default).
>
> {{{
> # Default: 2 significant words (while we really should get only 1)
> sage: pari('Pi').debug()
> [&=0000000004fc9620] REAL(lg=4):0400000000000004
> (+,expo=1):6000000000000001 c90fdaa22168c234 c4c6628b80dc1cd1
>
> # Change precision and then change it back: we get 1 word
> sage: n = pari.get_real_precision(); pari.set_real_precision(100);
> pari.set_real_precision(n);
> sage: pari('Pi').debug()
> [&=00000000012bf200] REAL(lg=3):0400000000000003
> (+,expo=1):6000000000000001 c90fdaa22168c235
> }}}
>
> {{{
> # set_real_precision() doesn't do anything for library functions:
> sage: pari.set_real_precision(1000);
> sage: pari.euler().debug()
> [&=0000000004f75e20] REAL(lg=3):0400000000000003
> (+,expo=-1):5fffffffffffffff 93c467e37db0c7a5
> }}}
>
> Dependencies: #9898, #9893

New description:

 The following do not work as they should (try these examples with a
 freshly started copy of Sage, such that everything is default).

 This is definately a bug with the initialization of the precision:
 {{{
 # Default: 2 significant words (while we really should get only 1)
 sage: pari('Pi').debug()
 [&=0000000004fc9620] REAL(lg=4):0400000000000004
 (+,expo=1):6000000000000001 c90fdaa22168c234 c4c6628b80dc1cd1

 # Change precision and then change it back: we get 1 word
 sage: n = pari.get_real_precision(); pari.set_real_precision(100);
 pari.set_real_precision(n);
 sage: pari('Pi').debug()
 [&=00000000012bf200] REAL(lg=3):0400000000000003
 (+,expo=1):6000000000000001 c90fdaa22168c235
 }}}

 {{{set_real_precision()}}} seems to affect essentially only the precision
 for evaluating strings in PARI and not much else:
 {{{
 sage: pari.set_real_precision(1000);
 sage: pari.euler().debug()
 [&=0000000004f75e20] REAL(lg=3):0400000000000003
 (+,expo=-1):5fffffffffffffff 93c467e37db0c7a5
 }}}

 This last behaviour is actually documented in
 {{{sage/libs/pari/gen.pyx}}}:
 > Unless otherwise indicated in the docstring, most Pari functions
 > that return inexact objects use the precision of their arguments to
 > decide the precision of the computation. However, if some of these
 > arguments happen to be exact numbers (integers, rationals, etc.),
 > an optional parameter indicates the precision (in bits) to which
 > these arguments should be converted before the computation. If this
 > precision parameter is missing, the '''default precision of 53 bits'''
 is
 > used.

 In other words, the default precision is an unchangable 53 bits. I would
 expect {{{set_real_precision()}}} to change this.  This is also trivial to
 implement since the global variable {{{prec}}} is already there (and
 initialized once and for all to 53).

 Dependencies: #9898, #9893

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9937#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to