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

  * dependencies:  => #11130, #11321
  * milestone:  sage-4.7.2 => sage-pending


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).
>
> 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(50);
> sage: pari('Euler')   # Precision changes
> 0.57721566490153286060651209008240243104215933593992
> sage: pari.euler()    # Precision does NOT change
> 0.5772156649015328607
> }}}
>
> 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).
>
> Depends on #11130.

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(50);
 sage: pari('Euler')   # Precision changes
 0.57721566490153286060651209008240243104215933593992
 sage: pari.euler()    # Precision does NOT change
 0.5772156649015328607
 }}}

 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).

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9937#comment:10>
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