# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1281966207 -7200
# Node ID 8a361e1b884e29f85cceac579afa670d2c4261db
# Parent  f77808909c540fff2ad614693a7825695860ab74
#9343: Upgrade Pari to Version 2.4.3 (development svn-12577)

diff -r f77808909c54 -r 8a361e1b884e c_lib/include/gmp_globals.h
--- a/c_lib/include/gmp_globals.h	Sat Aug 14 18:53:26 2010 -0700
+++ b/c_lib/include/gmp_globals.h	Mon Aug 16 15:43:27 2010 +0200
@@ -11,7 +11,7 @@
 EXTERN mpz_t u, v, q, u0, u1, u2, v0, v1, v2, t0, t1, t2, x, y, ssqr, m2;
 EXTERN mpq_t tmp;
 
-EXTERN mpz_t a1, a2, mod1, mod2, g, s, t, xx;
+EXTERN mpz_t a1, a2, mod1, sage_mod2, g, s, t, xx;
 
 EXTERN mpz_t crtrr_a, crtrr_mod;
 
diff -r f77808909c54 -r 8a361e1b884e doc/en/constructions/algebraic_geometry.rst
--- a/doc/en/constructions/algebraic_geometry.rst	Sat Aug 14 18:53:26 2010 -0700
+++ b/doc/en/constructions/algebraic_geometry.rst	Mon Aug 16 15:43:27 2010 +0200
@@ -10,18 +10,15 @@
 How do you count points on an elliptic curve over a finite field in
 Sage?
 
-Over prime finite fields, includes both the the baby step giant
-step method, as implemented in PARI's ``ellap``, and the SEA
-(Schoof-Elkies-Atkin) algorithm as implemented in PARI by
-Christophe Doche and Sylvain Duquesne. An example taken form the
+Over prime finite fields, includes both the the baby step giant step
+method and the SEA (Schoof-Elkies-Atkin) algorithm (implemented in PARI
+by Christophe Doche and Sylvain Duquesne). An example taken form the
 Reference manual:
 
 ::
 
     sage: E = EllipticCurve(GF(10007),[1,2,3,4,5])
-    sage: E.cardinality(algorithm='sea')
-    10076
-    sage: E.cardinality(algorithm='bsgs')
+    sage: E.cardinality()
     10076
 
 The command ``E.points()`` will return the actual list of rational
diff -r f77808909c54 -r 8a361e1b884e sage/algebras/quatalg/quaternion_algebra.py
--- a/sage/algebras/quatalg/quaternion_algebra.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/algebras/quatalg/quaternion_algebra.py	Mon Aug 16 15:43:27 2010 +0200
@@ -2315,8 +2315,8 @@
         sage: v = [a,b,c]
         sage: from sage.algebras.quatalg.quaternion_algebra import intersection_of_row_modules_over_ZZ
         sage: M = intersection_of_row_modules_over_ZZ(v); M
-        [   2    0   -1   -1]
-        [   4   -1   -1    3]
+        [  -2    0    1    1]
+        [  -4    1    1   -3]
         [  -3 19/2   -1   -4]
         [   2   -3   -8    4]
         sage: M2 = a.row_module(ZZ).intersection(b.row_module(ZZ)).intersection(c.row_module(ZZ))
diff -r f77808909c54 -r 8a361e1b884e sage/calculus/calculus.py
--- a/sage/calculus/calculus.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/calculus/calculus.py	Mon Aug 16 15:43:27 2010 +0200
@@ -658,7 +658,7 @@
         sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))')
         '2.5657285005610514829173563961304785900147709554020 E-127'
         sage: gp.set_real_precision(old_prec)
-        57
+        50
 
     Note that the input function above is a string in PARI syntax.
     """
diff -r f77808909c54 -r 8a361e1b884e sage/ext/gmp.pxi
--- a/sage/ext/gmp.pxi	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/ext/gmp.pxi	Mon Aug 16 15:43:27 2010 +0200
@@ -15,7 +15,7 @@
     # changed sqr to ssqr due to a collision with ntl
     cdef mpq_t tmp
 
-    cdef mpz_t a1, a2, mod1, mod2, g, s, t, xx
+    cdef mpz_t a1, a2, mod1, sage_mod2, g, s, t, xx
 
     cdef mpz_t crtrr_a, crtrr_mod
 
@@ -187,8 +187,8 @@
     mpz_set_ui(mod1, m[0]) 
     for i from 1 <= i < n:
         mpz_set_ui(a2, v[i])
-        mpz_set_ui(mod2, m[i])
-        mpz_gcdext(g, s, t, mod1, mod2)
+        mpz_set_ui(sage_mod2, m[i])
+        mpz_gcdext(g, s, t, mod1, sage_mod2)
         if mpz_cmp_si(g,1) != 0:
             raise ArithmeticError, "Moduli must be coprime (gcd=%s)."%mpz_to_str(g)
         # Set a1 = a1 + (a2-a1) * s * mod1
@@ -196,8 +196,8 @@
         mpz_mul(xx, xx, s)
         mpz_mul(xx, xx, mod1)
         mpz_add(a1, a1, xx)
-        # Set mod1 = mod1*mod2
-        mpz_mul(mod1, mod1, mod2)
+        # Set mod1 = mod1*sage_mod2
+        mpz_mul(mod1, mod1, sage_mod2)
 
     # Now a1 is the CRT for the whole list v and mod1 is the modulus
     mpz_set(answer[0], a1)
diff -r f77808909c54 -r 8a361e1b884e sage/interfaces/expect.py
--- a/sage/interfaces/expect.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/interfaces/expect.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1532,7 +1532,7 @@
             return 1
 
         # everything is supposed to be comparable in Python, so we define
-        # the comparison thus when no comparable in interfaced system.
+        # the comparison thus when no comparison is available in interfaced system.
         if (hash(self) < hash(other)):
             return -1
         else:
diff -r f77808909c54 -r 8a361e1b884e sage/interfaces/gp.py
--- a/sage/interfaces/gp.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/interfaces/gp.py	Mon Aug 16 15:43:27 2010 +0200
@@ -4,7 +4,7 @@
 Type ``gp.[tab]`` for a list of all the functions
 available from your Gp install. Type ``gp.[tab]?`` for
 Gp's help about a given function. Type ``gp(...)`` to
-create a new Gp object, and ``gp.eval(...)`` to run a
+create a new Gp object, and ``gp.eval(...)`` to evaluate a
 string using Gp (and get the result back as a string).
 
 EXAMPLES: We illustrate objects that wrap GP objects (gp is the
@@ -60,7 +60,7 @@
 
     sage: print gp.eval("plot(x=0,6,sin(x))")
     <BLANKLINE>
-    0.9988963 |''''''''''''_x"...x_''''''''''''''''''''''''''''''''''''''''''|
+    0.9988963 |''''''''''''_x...x_''''''''''''''''''''''''''''''''''''''''''|
               |          x"        "x                                        |
               |        _"            "_                                      |
               |       x                x                                     |
@@ -70,8 +70,8 @@
               |  _                          _                                |
               | _                            _                               |
               |_                              _                              |
-              _,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-              |                                "                             |
+              _                                                              |
+              `````````````````````````````````"``````````````````````````````
               |                                 "                            |
               |                                  "                           |
               |                                   "                          "
@@ -137,8 +137,24 @@
     Type ``gp.[tab]`` for a list of all the functions
     available from your Gp install. Type ``gp.[tab]?`` for
     Gp's help about a given function. Type ``gp(...)`` to
-    create a new Gp object, and ``gp.eval(...)`` to run a
+    create a new Gp object, and ``gp.eval(...)`` to evaluate a
     string using Gp (and get the result back as a string).
+
+        INPUT:
+
+        - ``stacksize`` (int, default 10000000) -- the initial PARI
+          stacksize in bytes (default 10MB)
+        - ``maxread`` (int, default 100000) -- ??
+        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_ROOT/data/extcode/pari from which to read scripts
+        - ``logfile`` (string, default None) -- log file for the pexpect interface
+        - ``server`` -- name of remote server
+        - ``server_tmpdir`` -- name of temporary directory on remote server
+        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.
+
+        EXAMPLES::
+        
+            sage: Gp()
+            GP/PARI interpreter
     """
     def __init__(self, stacksize=10000000,   # 10MB
                  maxread=100000, script_subdirectory=None,
@@ -147,6 +163,19 @@
                  server_tmpdir=None,
                  init_list_length=1024):
         """
+        Initialization of this PARI gp interpreter.
+
+        INPUT:
+
+        - ``stacksize`` (int, default 10000000) -- the initial PARI
+          stacksize in bytes (default 10MB)
+        - ``maxread`` (int, default 100000) -- ??
+        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_ROOT/data/extcode/pari from which to read scripts
+        - ``logfile`` (string, default None) -- log file for the pexpect interface
+        - ``server`` -- name of remote server
+        - ``server_tmpdir`` -- name of temporary directory on remote server
+        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.
+
         EXAMPLES::
         
             sage: gp == loads(dumps(gp))
@@ -167,12 +196,27 @@
         self.__seq = 0
         self.__var_store_len = 0
         self.__init_list_length = init_list_length
+        # gp starts up with this set to 1, which makes pexpect hang:
+        self.set_default('breakloop',0)
+
+    def _start(self, alt_message=None, block_during_init=True):
+        r"""
+        Restart the underlying process.
+
+        .. note:: This is handled by the Expect class, except that we
+           need to reset the breakloop configuration parameter.
+        """
+        Expect._start(self, alt_message=alt_message, block_during_init=block_during_init)
+        self.set_default('breakloop',0)
+        
 
     def _repr_(self):
         """
+        String representation of this PARI gp interpreter.
+
         EXAMPLES::
         
-            sage: gp
+            sage: gp # indirect doctest
             GP/PARI interpreter
         """
         return 'GP/PARI interpreter'
@@ -271,35 +315,59 @@
             28              # 32-bit
             38              # 64-bit
         """
-        a = self.eval('\\p')
-        i = a.find('=')
-        j = a.find('significant')
-        return int(a[i+1:j])
+        return self.get_default('realprecision')
 
     get_real_precision = get_precision
     
     def set_precision(self, prec=None):
         """
-        Sets the current PARI precision (in decimal digits) for real number
-        computations, and returns the old one.
+        Sets the PARI precision (in decimal digits) for real computations, and returns the old value.
         
         EXAMPLES::
         
-            sage: old_prec = gp.set_precision(53)
+            sage: old_prec = gp.set_precision(53); old_prec
+            28              # 32-bit
+            38              # 64-bit
             sage: gp.get_precision()
-            57
+            53
             sage: gp.set_precision(old_prec)
-            57
+            53
             sage: gp.get_precision()
             28              # 32-bit
             38              # 64-bit
         """
-        old = self.get_precision()
-        self.eval('\\p %s'%int(prec))
-        return old
+        return self.set_default('realprecision', prec)
 
     set_real_precision = set_precision
         
+    def get_series_precision(self):
+        """
+        Return the current PARI power series precision.
+        
+        EXAMPLES::
+        
+            sage: gp.get_series_precision()
+            16
+        """
+        return self.get_default('seriesprecision')
+
+    def set_series_precision(self, prec=None):
+        """
+        Sets the PARI power series precision, and returns the old precision.
+        
+        EXAMPLES::
+        
+            sage: old_prec = gp.set_series_precision(50); old_prec
+            16
+            sage: gp.get_series_precision()
+            50
+            sage: gp.set_series_precision(old_prec)
+            50
+            sage: gp.get_series_precision()
+            16
+        """
+        return self.set_default('seriesprecision', prec)
+
     def _eval_line(self, line, allow_use_file=True, wait_for_prompt=True):
         """
         EXAMPLES::
@@ -357,9 +425,68 @@
             return m - t
         return m 
 
+    def set_default(self, var=None, value=None):
+        """
+        Set a PARI gp configuration variable, and return the old value.
+
+        INPUT:
+        
+        - ``var`` (string, default None) -- the name of a PARI gp
+          configuration variable.  (See ``gp.default()`` for a list.)
+        - ``value`` -- the value to set the variable to.
+        
+        EXAMPLES::
+        
+            sage: old_prec = gp.set_default('realprecision',100); old_prec
+            28              # 32-bit
+            38              # 64-bit
+            sage: gp.get_default('realprecision')
+            100
+            sage: gp.set_default('realprecision',old_prec)
+            100
+            sage: gp.get_default('realprecision')
+            28              # 32-bit
+            38              # 64-bit
+        """
+        old = self.get_default(var)
+        self._eval_line('default(%s,%s)'%(var,value))
+        return old
+
+    def get_default(self, var=None):
+        """
+        Return the current value of a PARI gp configuration variable.
+
+        INPUT:
+
+        - ``var`` (string, default None) -- the name of a PARI gp
+          configuration variable.  (See ``gp.default()`` for a list.)
+
+        OUTPUT:
+
+        (string) the value of the variable.
+        
+        EXAMPLES::
+        
+            sage: gp.get_default('log')
+            0
+            sage: gp.get_default('logfile')
+            'pari.log'
+            sage: gp.get_default('seriesprecision')
+            16
+            sage: gp.get_default('realprecision')
+            28              # 32-bit
+            38              # 64-bit
+        """
+        return eval(self._eval_line('default(%s)'%var))
+
     def set(self, var, value):
         """
-        Set the variable var to the given value.
+        Set the GP variable var to the given value.
+
+        INPUT:
+
+        - ``var`` (string) -- a valid GP variable identifier
+        - ``value`` -- a value for the variable
         
         EXAMPLES::
         
@@ -375,8 +502,12 @@
 
     def get(self, var):
         """
-        Get the value of the variable var.
+        Get the value of the GP variable var.
         
+        INPUT:
+
+        - ``var`` (string) -- a valid GP variable identifier
+
         EXAMPLES::
         
             sage: gp.set('x', '2')
@@ -387,6 +518,12 @@
 
     def kill(self, var):
         """
+        Kill the value of the GP variable var.
+        
+        INPUT:
+
+        - ``var`` (string) -- a valid GP variable identifier
+
         EXAMPLES::
         
             sage: gp.set('xx', '22')
@@ -413,6 +550,8 @@
     
     def _next_var_name(self):
         """
+        Return the name of the next unused interface variable name.
+
         EXAMPLES::
         
             sage: g = Gp()
@@ -436,6 +575,8 @@
 
     def quit(self, verbose=False, timeout=0.25):
         """
+        Terminate the GP process.
+
         EXAMPLES::
         
             sage: a = gp('10'); a
@@ -458,12 +599,11 @@
         
         EXAMPLES::
         
-            sage: gp.console() #not tested
-            GP/PARI CALCULATOR Version 2.3.3 (released)
+            sage: gp.console()  # not tested
+            GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)
             amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version
-            compiled: Feb 22 2008, gcc-4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
-            (readline v5.2 enabled, extended help available)
-            ...
+            compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC)
+            (readline v6.0 enabled, extended help enabled)
         """
         gp_console()
 
@@ -473,8 +613,8 @@
         
         EXAMPLES::
         
-            sage: gp.version()
-            ((2, 3, 5), 'GP/PARI CALCULATOR Version 2.3.5 (released)')
+            sage: gp.version()  # not tested
+            ((2, 4, 3), 'GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)')
         """
         return gp_version()
 
@@ -602,16 +742,18 @@
             sage: new_prec = pi_150.precision(); new_prec
             48                                             # 32-bit
             57                                             # 64-bit
-            sage: old_prec = gp.get_precision()
-            sage: gp.set_precision(new_prec)
+            sage: old_prec = gp.set_precision(new_prec); old_prec
             28                                             # 32-bit
             38                                             # 64-bit
             sage: pi_150
-            3.14159265358979323846264338327950288419716939937  # 32-bit
+            3.14159265358979323846264338327950288419716939938  # 32-bit
             3.14159265358979323846264338327950288419716939937510582098  # 64-bit
             sage: gp.set_precision(old_prec)
             48                                             # 32-bit
             57                                             # 64-bit
+            sage: gp.get_precision()
+            28                                             # 32-bit
+            38                                             # 64-bit
         """
         if precision:
             old_prec = self.get_real_precision()
@@ -640,19 +782,45 @@
     view of PARI::
     
         sage: E = gp('ellinit([1,2,3,4,5])')
-        sage: loads(E.dumps()) == E
+        sage: loads(dumps(E)) == E
         False
         sage: loads(E.dumps())
-        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, -1.390370006883364885531598814 + 1.068749776356193066159263547*I, -1.554824121162190164275074561 + 3.415713103000000000000000000 E-29*I, 0.7774120605810950821375372806 - 1.727349756386839866714149879*I, 2.971915267817909670771647951] # 32-bit
-        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169750, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, -1.3903700068833648855315988135906792497 + 1.0687497763561930661592635474375038788*I, -1.5548241211621901642750745610982915039 + 7.9528267991764473360000000000000000000 E-39*I, 0.77741206058109508213753728054914575197 - 1.7273497563868398667141498789110695181*I, 2.9719152678179096707716479509361896060]  # 64-bit
+        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, 1.390370006883364885531598814 - 1.068749776356193066159263548*I, 3.109648242324380328550149122 + 1.009741959000000000000000000 E-28*I, 1.554824121162190164275074561 + 1.064374745210273756943885994*I, 2.971915267817909670771647951] # 32-bit
+        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169751, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, 1.3903700068833648855315988135906792497 - 1.0687497763561930661592635474375038788*I, 3.1096482423243803285501491221965830079 + 2.3509887016445750160000000000000000000 E-38*I, 1.5548241211621901642750745610982915040 + 1.0643747452102737569438859937299427442*I, 2.9719152678179096707716479509361896060] # 64-bit
         sage: E
-        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, -1.390370006883364885531598814 + 1.068749776356193066159263547*I, -1.554824121162190164275074561 + 3.415713103 E-29*I, 0.7774120605810950821375372806 - 1.727349756386839866714149879*I, 2.971915267817909670771647951]   # 32-bit
-        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169750, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, -1.3903700068833648855315988135906792497 + 1.0687497763561930661592635474375038788*I, -1.5548241211621901642750745610982915039 + 7.952826799176447336 E-39*I, 0.77741206058109508213753728054914575197 - 1.7273497563868398667141498789110695181*I, 2.9719152678179096707716479509361896060]  # 64-bit
+        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, 1.390370006883364885531598814 - 1.068749776356193066159263548*I, 3.109648242324380328550149122 + 1.009741959 E-28*I, 1.554824121162190164275074561 + 1.064374745210273756943885994*I, 2.971915267817909670771647951] # 32-bit
+        [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169751, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, 1.3903700068833648855315988135906792497 - 1.0687497763561930661592635474375038788*I, 3.1096482423243803285501491221965830079 + 2.350988701644575016 E-38*I, 1.5548241211621901642750745610982915040 + 1.0643747452102737569438859937299427442*I, 2.9719152678179096707716479509361896060]  # 64-bit
     
     The two elliptic curves look the same, but internally the floating
     point numbers are slightly different.
     """
-    
+
+    def _sage_(self):
+        """
+        Convert this GpElement into a Sage object, if possible.
+        
+        EXAMPLES::
+        
+            sage: gp(I).sage()
+            i
+            sage: gp(I).sage().parent()
+            Maximal Order in Number Field in i with defining polynomial x^2 + 1
+
+        ::
+
+            sage: M = Matrix(ZZ,2,2,[1,2,3,4]); M
+            [1 2]
+            [3 4]
+            sage: gp(M)
+            [1, 2; 3, 4]
+            sage: gp(M).sage()
+            [1 2]
+            [3 4]
+            sage: gp(M).sage() == M
+            True
+        """
+        return pari(str(self)).python()
+
     def __long__(self):
         """
         Return Python long.
@@ -691,22 +859,30 @@
 
     def _complex_mpfr_field_(self, CC):
         """
-        EXAMPLES::
-        
-            sage: CC(gp(1+15*I))
-             1.00000000000000 + 15.0000000000000*I
+        Return ComplexField element of self.
+
+        INPUT:
+
+        - ``CC`` -- a Complex or Real Field.
+
+        EXAMPLES::     
+    
+            sage: z = gp(1+15*I); z
+            1 + 15*I
+            sage: z._complex_mpfr_field_(CC)
+            1.00000000000000 + 15.0000000000000*I
+            sage: CC(z) # CC(gp(1+15*I))
+            1.00000000000000 + 15.0000000000000*I
             sage: CC(gp(11243.9812+15*I))
-             11243.9812000000 + 15.0000000000000*I
+            11243.9812000000 + 15.0000000000000*I
             sage: ComplexField(10)(gp(11243.9812+15*I))
-             11000. + 15.*I
+            11000. + 15.*I
         """
-        GP = self.parent()
-        orig = GP.get_real_precision()
-        GP.set_real_precision(int(CC.prec()*3.33)+1)
-        real = str(self.real()).replace(' E','e')
-        imag = str(self.imag()).replace(' E','e')
-        GP.set_real_precision(orig)
-        return sage.rings.complex_number.ComplexNumber(CC, real, imag )
+        # Multiplying by CC(1) is necessary here since
+        # sage: pari(gp(1+I)).sage().parent()
+        # Maximal Order in Number Field in i with defining polynomial x^2 + 1
+
+        return CC((CC(1)*pari(self))._sage_())
 
     def _complex_double_(self, CDF):
         """
@@ -791,7 +967,9 @@
     return isinstance(x, GpElement)
 
 # An instance
-gp = Gp()
+#gp = Gp()
+from sage.misc.all import DOT_SAGE
+gp = Gp(logfile=DOT_SAGE+'/gp-expect.log') # useful for debugging!
 
 def reduce_load_GP():
     """
@@ -812,12 +990,11 @@
     
     EXAMPLES::
     
-        sage: gp.console() #not tested
-        GP/PARI CALCULATOR Version 2.3.3 (released)
+        sage: gp.console()  # not tested
+        GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)
         amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version
-        compiled: Feb 22 2008, gcc-4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
-        (readline v5.2 enabled, extended help available)
-        ...
+        compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC)
+        (readline v6.0 enabled, extended help enabled)
     """
     os.system('gp')
 
@@ -826,8 +1003,8 @@
     """
     EXAMPLES::
     
-        sage: gp.version()      # random output
-        ((2, 3, 1), 'GP/PARI CALCULATOR Version 2.3.1 (0)')
+        sage: gp.version()  # not tested
+        ((2, 4, 3), 'GP/PARI CALCULATOR Version 2.4.3 (development svn-12577)')
     """
     v = gp.eval(r'\v')
     i = v.find("Version ")
diff -r f77808909c54 -r 8a361e1b884e sage/interfaces/maxima.py
--- a/sage/interfaces/maxima.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/interfaces/maxima.py	Mon Aug 16 15:43:27 2010 +0200
@@ -2054,7 +2054,7 @@
         
             sage: gp('intnum(x=0,1,exp(-sqrt(x)))')            
             0.5284822353142307136179049194             # 32-bit
-            0.52848223531423071361790491935415653021   # 64-bit
+            0.52848223531423071361790491935415653022   # 64-bit
             sage: _ = gp.set_precision(80)
             sage: gp('intnum(x=0,1,exp(-sqrt(x)))')
             0.52848223531423071361790491935415653021675547587292866196865279321015401702040079
diff -r f77808909c54 -r 8a361e1b884e sage/lfunctions/dokchitser.py
--- a/sage/lfunctions/dokchitser.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/lfunctions/dokchitser.py	Mon Aug 16 15:43:27 2010 +0200
@@ -79,7 +79,7 @@
         sage: L(1)
         Traceback (most recent call last):
         ...
-        ArithmeticError:   ###   user error: L*(s) has a pole at s=1.000000000000000000
+        ArithmeticError
         sage: L(2)
         1.64493406684823
         sage: L(2, 1.1)
@@ -90,7 +90,7 @@
         sage: (zeta(2+h) - zeta(2.))/h
         -0.937028232783632
         sage: L.taylor_series(2, k=5)
-        1.64493406684823 - 0.937548254315844*z + 0.994640117149451*z^2 - 1.00002430047384*z^3 + 1.00006193307235*z^4 + O(z^5)
+        1.64493406684823 - 0.937548254315844*z + 0.994640117149451*z^2 - 1.00002430047384*z^3 + 1.00006193307...*z^4 + O(z^5)
     
     RANK 1 ELLIPTIC CURVE:
     
@@ -130,8 +130,8 @@
         sage: L.derivative(1,E.rank())
         1.51863300057685
         sage: L.taylor_series(1,4)
-        -1.28158145691931e-23 + (7.26268290635587e-24)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)      # 32-bit
-        -2.69129566562797e-23 + (1.52514901968783e-23)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)      # 64-bit
+        2.90759778535572e-20 + (-1.64772676916085e-20)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)      # 32-bit
+        -3.11623283109075e-21 + (1.76595961125962e-21)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)      # 64-bit
     
     RAMANUJAN DELTA L-FUNCTION:
     
@@ -373,9 +373,11 @@
             pass
         z = self.gp().eval('L(%s)'%s)
         if 'pole' in z:
-            raise ArithmeticError, z
+            print z
+            raise ArithmeticError
         elif '***' in z:
-            raise RuntimeError, z
+            print z
+            raise RuntimeError
         elif 'Warning' in z:
             i = z.rfind('\n')
             msg = z[:i].replace('digits','decimal digits')
@@ -459,8 +461,7 @@
             sage: E = EllipticCurve('389a')
             sage: L = E.lseries().dokchitser(200)
             sage: L.taylor_series(1,3)
-            6.2239725530250970363983975962696997888173850098274602272589e-73 + (-3.527106203544994604921190324282024612952450859320...e-73)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3)                          # 32-bit
-            6.2239725530250970363983942830358807065824196704980264311105e-73 + (-3.5271062035449946049211884466825561834034352383203420991340e-73)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3)                          # 64-bit
+            6.2240188634103774348273446965620801288836328651973234573133e-73 + (-3.527132447498646306292650465494647003849868770...e-73)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3)
         """
         self.__check_init()        
         a = self.__CC(a)
@@ -514,8 +515,8 @@
         EXAMPLES::
         
             sage: L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1, poles=[1], residues=[-1], init='1')
-            sage: L.check_functional_equation ()
-            -2.71050543200000e-20                        # 32-bit
+            sage: L.check_functional_equation()
+            -1.35525271600000e-20                        # 32-bit
             -2.71050543121376e-20                        # 64-bit
         
         If we choose the sign in functional equation for the
@@ -525,7 +526,7 @@
         ::
         
             sage: L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=-11, poles=[1], residues=[-1], init='1')
-            sage: L.check_functional_equation ()
+            sage: L.check_functional_equation()
             -9.73967861488124
         """
         self.__check_init()
diff -r f77808909c54 -r 8a361e1b884e sage/libs/pari/decl.pxi
--- a/sage/libs/pari/decl.pxi	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/libs/pari/decl.pxi	Mon Aug 16 15:43:27 2010 +0200
@@ -35,6 +35,10 @@
 
 
     # parigen.h
+
+    extern int DEFAULTPREC       #  64 bits precision
+    extern int MEDDEFAULTPREC    # 128 bits precision
+    extern int BIGDEFAULTPREC    # 192 bits precision
     long    typ(GEN x)
     long    settyp(GEN x, long s)
     long    isclone(GEN x)
@@ -44,10 +48,8 @@
     long    setlg(GEN x, long s)
     long    signe(GEN x)
     long    setsigne(GEN x, long s)
-    long    lgeflist(GEN x)
-    long    setlgeflist(GEN x, long s)
-    long    lgefint(GEN x)
-    long    setlgefint(GEN x, long s)
+    long    lgefint(GEN x)               # macro
+    long    setlgefint(GEN x, long s)    # macro
     long    expo(GEN x)
     long    setexpo(GEN x, long s)
     long    valp(GEN x)
@@ -58,6 +60,7 @@
     long    setvarn(GEN x, long s)
 
     # paricast.h
+
     long    mael2(GEN,long,long)
     long    mael3(GEN,long,long,long)
     long    mael4(GEN,long,long,long,long)
@@ -74,6 +77,7 @@
     long    coeff(GEN,long,long)
 
     # paricom.h
+    
     GEN     gpi
     GEN     geuler
     GEN     gen_m1
@@ -85,30 +89,27 @@
     GEN     gnil
 
     # level1.h (incomplete!)
+    
     GEN     cgetc(long x)
     GEN     cgetg_copy(long lx, GEN x)
     GEN     cgetg(long x, long y)
     GEN     cgeti(long x)
     GEN     cgetr(long x)
+    GEN     real_0_bit(long bitprec)
 
     # misc ...
-    GEN     gp_read_str(char *t)
-    GEN     gp_read_file(FILE *f)
-
-    GEN     real_0_bit(long bitprec)
     long    itos(GEN x)
     double  gtodouble(GEN x)
     GEN     stoi(long s)
     # These types are actually an enum type, but I can't get Pyrex to "properly"
     # wrap enums.  It doesn't matter as long as they are treated as ints by pyrexc.
-    extern int t_INT, t_REAL, t_INTMOD, t_FRAC, t_COMPLEX, t_PADIC, t_QUAD, \
+    extern int t_INT, t_REAL, t_INTMOD, t_FRAC, t_FFELT, t_COMPLEX, t_PADIC, t_QUAD, \
            t_POLMOD, t_POL, t_SER, t_RFRAC, t_QFR, t_QFI, t_VEC, t_COL,  \
-           t_MAT, t_LIST, t_STR, t_VECSMALL
+           t_MAT, t_LIST, t_STR, t_VECSMALL, t_CLOSURE
 
     extern unsigned long precdl
     extern char * diffptr
 
-    extern int BYTES_IN_LONG
     extern int BITS_IN_LONG
     
     ctypedef unsigned long pari_sp
@@ -118,13 +119,12 @@
 
 
     # Flx.c 
+
     GEN     Fl_to_Flx(ulong x, long sv)
-    GEN     Flm_id(long n)
     GEN     Flm_to_FlxV(GEN x, long sv)
     GEN     Flm_to_FlxX(GEN x, long v,long w)
     GEN     Flm_to_ZM(GEN z)
     GEN     Flv_to_Flx(GEN x, long vs)
-    GEN     Flv_to_ZC(GEN z)
     GEN     Flv_to_ZV(GEN z)
     GEN     Flv_polint(GEN xa, GEN ya, ulong p, long vs)
     GEN     Flv_roots_to_pol(GEN a, ulong p, long vs)
@@ -141,7 +141,6 @@
     ulong   Flx_extresultant(GEN a, GEN b, ulong p, GEN *ptU, GEN *ptV)
     GEN     Flx_gcd(GEN a, GEN b, ulong p)
     GEN     Flx_gcd_i(GEN a, GEN b, ulong p)
-    GEN     Flx_invmontgomery(GEN T, ulong p)
     int     Flx_is_squarefree(GEN z, ulong p)
     GEN     Flx_mul(GEN x, GEN y, ulong p)
     GEN     Flx_neg(GEN x, ulong p)
@@ -150,18 +149,14 @@
     GEN     Flx_pow(GEN x, long n, ulong p)
     GEN     Flx_recip(GEN x)
     GEN     Flx_red(GEN z, ulong p)
-    GEN     Flx_rem_montgomery(GEN x, GEN mg, GEN T, ulong p)
     GEN     Flx_rem(GEN x, GEN y, ulong p)
     GEN     Flx_renormalize(GEN x, long l)
     ulong   Flx_resultant(GEN a, GEN b, ulong p)
     GEN     Flx_shift(GEN a, long n)
     GEN     Flx_sqr(GEN x, ulong p)
     GEN     Flx_sub(GEN x, GEN y, ulong p)
-    long    Flx_valuation(GEN x)
     GEN     FlxM_to_ZXM(GEN z)
-    GEN     FlxV_Flv_innerprod(GEN V, GEN W, ulong p)
     GEN     FlxV_to_Flm(GEN v, long n)
-    GEN     FlxV_to_ZXC(GEN x)
     GEN     FlxX_add(GEN P, GEN Q, ulong p)
     GEN     FlxX_shift(GEN a, long n)
     GEN     FlxX_to_Flm(GEN v, long n)
@@ -192,7 +187,6 @@
 
      # alglin1.c 
 
-    GEN     Flm_Flv_mul(GEN x, GEN y, ulong p)
     GEN     Flm_deplin(GEN x, ulong p)
     GEN     Flm_indexrank(GEN x, ulong p)
     GEN     Flm_inv(GEN x, ulong p)
@@ -201,7 +195,6 @@
     GEN     Flm_mul(GEN x, GEN y, ulong p)
     GEN     FlxqM_ker(GEN x, GEN T, ulong p)
     GEN     FpC_FpV_mul(GEN x, GEN y, GEN p)
-    GEN     FpM_FpV_mul(GEN x, GEN y, GEN p)
     GEN     FpM_deplin(GEN x, GEN p)
     GEN     FpM_image(GEN x, GEN p)
     GEN     FpM_intersect(GEN x, GEN y, GEN p)
@@ -217,84 +210,54 @@
     GEN     FqM_suppl(GEN x, GEN T, GEN p)
     GEN     QM_inv(GEN M, GEN dM)
     GEN     ZM_inv(GEN M, GEN dM)
-    void    appendL(GEN x, GEN t)
-    GEN     cget1(long l, long t)
     GEN     concat(GEN x, GEN y)
-    GEN     concatsp(GEN x, GEN y)
-    GEN     concatsp3(GEN x, GEN y, GEN z)
     GEN     deplin(GEN x)
     GEN     det(GEN a)
     GEN     det0(GEN a,long flag)
     GEN     det2(GEN a)
-    GEN     dethnf(GEN x)
-    GEN     dethnf_i(GEN mat)
     GEN     detint(GEN x)
     GEN     diagonal(GEN x)
     GEN     eigen(GEN x, long prec)
-    GEN     extract(GEN x, GEN l)
+    GEN     shallowextract(GEN x, GEN l)
     GEN     extract0(GEN x, GEN l1, GEN l2)
-    GEN     gaddmat(GEN x, GEN y)
-    GEN     gaddmat_i(GEN x, GEN y)
     GEN     gauss(GEN a, GEN b)
     GEN     gaussmodulo(GEN M, GEN D, GEN Y)
     GEN     gaussmodulo2(GEN M, GEN D, GEN Y)
-    GEN     gscalcol(GEN x, long n)
-    GEN     gscalcol_i(GEN x, long n)
-    GEN     gscalcol_proto(GEN z, GEN myzero, long n)
-    GEN     gscalmat(GEN x, long n)
-    GEN     gscalsmat(long x, long n)
+    GEN     scalarmat_s(long x, long n)
     GEN     gtomat(GEN x)
     GEN     gtrans(GEN x)
-    GEN     gtrans_i(GEN x)
     int     hnfdivide(GEN A, GEN B)
-    GEN     idmat(long n)
-    GEN     idmat_intern(long n,GEN myun,GEN myzero)
+    GEN     matid(long n)
     GEN     image(GEN x)
     GEN     image2(GEN x)
     GEN     imagecompl(GEN x)
     GEN     indexrank(GEN x)
     GEN     inverseimage(GEN mat, GEN y)
     long    isdiagonal(GEN x)
-    long    isscalarmat(GEN x, GEN s)
     GEN     ker(GEN x)
     GEN     keri(GEN x)
-    GEN     matextract(GEN x, GEN l1, GEN l2)
     GEN     matimage0(GEN x,long flag)
     GEN     matker0(GEN x, long flag)
     GEN     matmuldiagonal(GEN x, GEN d)
     GEN     matmultodiagonal(GEN x, GEN y)
     GEN     matsolvemod0(GEN M, GEN D, GEN Y,long flag)
-    GEN     mattodiagonal(GEN m)
-    GEN     mattodiagonal_i(GEN m)
     long    rank(GEN x)
     GEN     row(GEN A, long x1)
     GEN     row_i(GEN A, long x0, long x1, long x2)
-    GEN     rowextract_i(GEN A, long x1, long x2)
-    GEN     rowextract_ip(GEN A, GEN p, long x1, long x2)
-    GEN     rowextract_p(GEN A, GEN p)
-    GEN     sindexrank(GEN x)
+    GEN     indexrank(GEN x)
     # we rename sum to pari_sum to avoid conflicts with
     # python's sum function
     GEN     pari_sum "sum"(GEN v, long a, long b)
     GEN     suppl(GEN x)
     GEN     vconcat(GEN A, GEN B)
     GEN     vec_ei(long n, long i)
-    GEN     vec_Cei(long n, long i, GEN c)
-    GEN     vecextract_i(GEN A, long y1, long y2)
-    GEN     vecextract_ip(GEN A, GEN p, long y1, long y2)
-    GEN     vecextract_p(GEN A, GEN p)
 
     # alglin2.c 
 
-    GEN     QuickNormL1(GEN x,long prec)
-    GEN     QuickNormL2(GEN x,long prec)
     GEN     ZM_to_zm(GEN z)
     GEN     adj(GEN x)
-    GEN     assmat(GEN x)
     GEN     caract(GEN x, int v)
-    GEN     caract2(GEN p, GEN x, int v)
     GEN     caradj(GEN x, long v, GEN *py)
-    GEN     caradj0(GEN x, long v)
     GEN     carhess(GEN x, long v)
     GEN     charpoly0(GEN x, int v,long flag)
     GEN     conjvec(GEN x,long prec)
@@ -307,51 +270,38 @@
     GEN     hnf(GEN x)
     GEN     hnfall(GEN x)
     GEN     hnflll(GEN x)
-    GEN     hnflll_i(GEN A, GEN *ptB, int remove)
     GEN     hnfmod(GEN x, GEN detmat)
     GEN     hnfmodid(GEN x,GEN p)
-    GEN     hnfmodidpart(GEN x, GEN p)
     GEN     hnfperm(GEN x)
     GEN     intersect(GEN x, GEN y)
     GEN     jacobi(GEN a, long prec)
     GEN     matfrobenius(GEN M, long flag, long v)
     GEN     matrixqz(GEN x, GEN pp)
     GEN     matrixqz0(GEN x, GEN pp)
-    GEN     matrixqz2(GEN x)
-    GEN     matrixqz3(GEN x)
-    GEN     signat(GEN a)
+    GEN     qfsign(GEN a)
     GEN     smith(GEN x)
-    GEN     smith2(GEN x)
-    GEN     smithall(GEN x, GEN *ptU, GEN *ptV)
+    GEN     smithall(GEN x)
     GEN     smithclean(GEN z)
-    GEN     sqred(GEN a)
-    GEN     sqred1(GEN a)
-    GEN     sqred1intern(GEN a)
-    GEN     sqred3(GEN a)
+    GEN     qfgaussred(GEN a)
     GEN     zm_to_ZM(GEN z)
     GEN     zx_to_ZX(GEN z)
 
     # anal.c 
 
     void    addhelp(entree *ep, char *s)
-    void    delete_named_var(entree *ep)
     long    delete_var()
-    entree  *fetch_named_var(char *s, int doerr)
+    entree  *fetch_named_var(char *s)
     long    fetch_user_var(char *s)
     long    fetch_var()
-    GEN     flisexpr(char *t)
-    GEN     flisseq(char *t)
+    GEN     gp_read_str(char *s)
     void    freeep(entree *ep)
     entree  *gp_variable(char *s)
-    long    hashvalue(char *s)
     entree* install(void *f, char *name, char *code)
     entree  *is_entry(char *s)
     void    kill0(entree *ep)
-    GEN     lisexpr(char *t)
-    GEN     lisseq(char *t)
     long    manage_var(long n, entree *ep)
     void    name_var(long n, char *s)
-    GEN     readseq(char *c, int strict)
+    GEN     readseq(char *t)
     GEN     strtoGENstr(char *s)
     GEN     type0(GEN x)
 
@@ -359,56 +309,34 @@
 
     GEN     bestappr0(GEN x, GEN a, GEN b)
     GEN     bestappr(GEN x, GEN k)
-    long    carrecomplet(GEN x, GEN *pt)
     long    cgcd(long a,long b)
     void    check_quaddisc(GEN x, long *s, long *r, char *f)
     GEN     chinese(GEN x, GEN y)
-    GEN     chinois(GEN x, GEN y)
     GEN     classno2(GEN x)
     GEN     classno(GEN x)
     long    clcm(long a,long b)
-    GEN     compimag(GEN x, GEN y)
-    GEN     compimagraw(GEN x, GEN y)
-    GEN     compraw(GEN x, GEN y)
-    GEN     compreal(GEN x, GEN y)
-    GEN     comprealraw(GEN x, GEN y)
     GEN     contfrac0(GEN x, GEN b, long flag)
     GEN     fibo(long n)
-    GEN     Fp_gener_fact(GEN p, GEN fa)
-    GEN     Fp_gener(GEN p)
-    GEN     FpXQ_gener(GEN T, GEN p)    
-    GEN     fundunit(GEN x)
     GEN     gboundcf(GEN x, long k)
-    GEN     gcarrecomplet(GEN x, GEN *pt)
-    GEN     gcarreparfait(GEN x)
+    GEN     gissquareall(GEN x, GEN *pt)
+    GEN     gissquare(GEN x)
     GEN     gcf2(GEN b, GEN x)
     GEN     gcf(GEN x)
-    GEN     gener(GEN m)
-    GEN     gfundunit(GEN x)
-    GEN     ggener(GEN m)
+    GEN     quadunit(GEN x)
     long    gisanypower(GEN x, GEN *pty)
-    GEN     gisfundamental(GEN x)
     GEN     gisprime(GEN x, long flag)
     GEN     gispseudoprime(GEN x, long flag)
-    GEN     gispsp(GEN x)
-    GEN     gkrogs(GEN x, long y)
     GEN     gkronecker(GEN x, GEN y)
-    GEN     gmillerrabin(GEN n, long k)
     GEN     gnextprime(GEN n)
     GEN     gprecprime(GEN n)
-    GEN     gracine(GEN a)
-    GEN     gregula(GEN x, long prec)
+    GEN     quadregulator(GEN x, long prec)
     GEN     hclassno(GEN x)
-    long    hil0(GEN x, GEN y, GEN p)
-    long    hil(GEN x, GEN y, GEN p)
-    long    isanypower(GEN x, GEN *y)
-    long    isfundamental(GEN x)
+    long    hilbert0 "hilbert"(GEN x, GEN y, GEN p)
+    long    Z_isfundamental(GEN x)
     long    ispower(GEN x, GEN k, GEN *pty)
     long    isprimeAPRCL(GEN N)
     long    isprime(GEN x)
-    long    isprimeSelfridge(GEN x)
     long    ispseudoprime(GEN x, long flag)
-    long    ispsp(GEN x)
     long    krois(GEN x, long y)
     long    kronecker(GEN x, GEN y)
     long    krosi(long s, GEN x)
@@ -427,36 +355,26 @@
     GEN     nupow(GEN x, GEN n)
     GEN     order(GEN x)
     GEN     pnqn(GEN x)
-    GEN     powraw(GEN x, long n)
-    GEN     powrealraw(GEN x, long n)
     GEN     primeform(GEN x, GEN p, long prec)
     GEN     Qfb0(GEN x, GEN y, GEN z, GEN d, long prec)
     GEN     qfbclassno0(GEN x,long flag)
-    GEN     qfbimagsolvep(GEN Q, GEN n)
     GEN     qfbred0(GEN x, long flag, GEN D, GEN isqrtD, GEN sqrtD)
     GEN     qfbsolve(GEN Q, GEN n)
     GEN     qfi(GEN x, GEN y, GEN z)
     GEN     qfr(GEN x, GEN y, GEN z, GEN d)
     GEN     quaddisc(GEN x)
-    GEN     racine(GEN a)
     GEN     redimag(GEN x)
     GEN     redreal(GEN x)
     GEN     redrealnod(GEN x, GEN isqrtD)
-    GEN     regula(GEN x, long prec)
     GEN     rhoreal(GEN x)
     GEN     rhorealnod(GEN x, GEN isqrtD)
-    GEN     seq_umul(ulong a, ulong b)
-    GEN     sqcompimag(GEN x)
-    GEN     sqcompreal(GEN x)
     ulong   Fl_sqrt(ulong a, ulong p)
-    ulong   Fl_gener_fact(ulong p, GEN fa)
-    ulong   Fl_gener(ulong p)
+    GEN     znprimroot0(GEN m)
     GEN     znstar(GEN x)
 
     # arith2.c 
 
     GEN     addprimes(GEN primes)
-    GEN     auxdecomp(GEN n, long all)
     long    bigomega(GEN n)
     GEN     binaire(GEN x)
     long    bittest(GEN x, long n)
@@ -469,8 +387,7 @@
     GEN     coredisc(GEN n)
     GEN     coredisc0(GEN n,long flag)
     GEN     coredisc2(GEN n)
-    GEN     decomp(GEN n)
-    GEN     decomp_small(long n)
+    GEN     Z_factor(GEN n)
     GEN     divisors(GEN n)
     GEN     factorint(GEN n, long flag)
     GEN     gbigomega(GEN n)
@@ -479,29 +396,24 @@
     GEN     gbitnegimply(GEN x, GEN y)
     GEN     gbitor(GEN x, GEN y)
     GEN     gbittest(GEN x, GEN n)
-    GEN	    gbittest3(GEN x, GEN n, long c)
     GEN     gbitxor(GEN x, GEN y)
-    GEN     gboundfact(GEN n, long lim)
     GEN     gissquarefree(GEN x)
-    GEN     gmu(GEN n)
+    GEN     gmoebius(GEN n)
     GEN     gnumbdiv(GEN n)
     GEN     gomega(GEN n)
-    GEN     gphi(GEN n)
     GEN     gsumdiv(GEN n)
     GEN     gsumdivk(GEN n,long k)
     char*   initprimes(ulong maxnum)
     long    issquarefree(GEN x)
     ulong   maxprime()
     void    maxprime_check(ulong c)
-    long    mu(GEN n)
     GEN     numbdiv(GEN n)
     long    omega(GEN n)
-    GEN     phi(GEN n)
+    GEN     geulerphi(GEN n)
     GEN     prime(long n)
     GEN     primepi(GEN x)
     GEN     primes(long n)
     GEN     removeprimes(GEN primes)
-    GEN     smallfact(GEN n)
     GEN     sumdiv(GEN n)
     GEN     sumdivk(GEN n,long k)
 
@@ -509,169 +421,89 @@
 
     GEN     bnfnewprec(GEN nf, long prec)
     GEN     bnrnewprec(GEN bnr, long prec)
-    void    check_pol_int(GEN x, char *s)
-    GEN     check_units(GEN x, char *f)
     void    checkbid(GEN bid)
     GEN     checkbnf(GEN bnf)
-    GEN     checkbnf_discard(GEN bnf)
     void    checkbnr(GEN bnr)
     void    checkbnrgen(GEN bnr)
-    void    checkid(GEN x, long N)
     GEN     checknf(GEN nf)
     GEN     checknfelt_mod(GEN nf, GEN x, char *s)
-    void    checkprimeid(GEN bid)
     void    checkrnf(GEN rnf)
-    GEN     galois(GEN x, long prec)
     GEN     galoisapply(GEN nf, GEN aut, GEN x)
+    GEN     polgalois(GEN x, long prec)
     GEN     get_bnf(GEN x,int *t)
     GEN     get_bnfpol(GEN x, GEN *bnf, GEN *nf)
     GEN     get_nf(GEN x,int *t)
     GEN     get_nfpol(GEN x, GEN *nf)
-    GEN     get_primeid(GEN x)
     GEN     glambdak(GEN nfz, GEN s, long prec)
-    int     gpolcomp(GEN p1, GEN p2)
     GEN     gsmith(GEN x)
-    GEN     gsmith2(GEN x)
+    GEN     gsmithall(GEN x)
     GEN     gzetak(GEN nfz, GEN s, long prec)
     GEN     gzetakall(GEN nfz, GEN s, long flag, long prec)
-    GEN     initalg(GEN x, long prec)
-    GEN     initalgred(GEN x, long prec)
-    GEN     initalgred2(GEN x, long prec)
-    GEN     initzeta(GEN pol, long prec)
     GEN     mathnf0(GEN x,long flag)
     GEN     matsnf0(GEN x,long flag)
     long    nf_get_r1(GEN nf)
     long    nf_get_r2(GEN nf)
     void    nf_get_sign(GEN nf, long *r1, long *r2)
-    long    nfgetprec(GEN x)
-    GEN     nfinit0(GEN x,long flag, long prec)
+    GEN     nfinit0(GEN x, long flag, long prec)
     GEN     nfnewprec(GEN nf, long prec)
-    GEN     nfnewprec_i(GEN nf, long prec)
     GEN     rootsof1(GEN x)
     GEN     tschirnhaus(GEN x)
 
     # base2.c 
 
-    GEN     allbase(GEN f, int flag, GEN *dx, GEN *dK, GEN *index, GEN *ptw)
     GEN     base(GEN x, GEN *y)
     GEN     base2(GEN x, GEN *y)
     void    checkmodpr(GEN modpr)
     GEN     compositum(GEN pol1, GEN pol2)
     GEN     compositum2(GEN pol1, GEN pol2)
     GEN     discf(GEN x)
-    GEN     discf2(GEN x)
-    GEN     factoredbase(GEN x, GEN p, GEN *y)
-    GEN     factoreddiscf(GEN x, GEN p)
-    GEN     ff_to_nf(GEN x, GEN modpr)
-    GEN     fix_relative_pol(GEN nf, GEN x, int chk_lead)
-    GEN     gcdpm(GEN f1,GEN f2,GEN pm)
     long    idealval(GEN nf,GEN ix,GEN vp)
     GEN     idealprodprime(GEN nf, GEN L)
     GEN     indexpartial(GEN P, GEN DP)
-    GEN     modprX(GEN x, GEN nf,GEN modpr)
-    GEN     modprX_lift(GEN x, GEN modpr)
-    GEN     modprM(GEN z, GEN nf,GEN modpr)
-    GEN     modprM_lift(GEN z, GEN modpr)
-    GEN     nf_to_ff_init(GEN nf, GEN *pr, GEN *T, GEN *p)
-    GEN     nf_to_ff(GEN nf, GEN x, GEN modpr)
     GEN     nfbasis(GEN x, GEN *y,long flag,GEN p)
     GEN     nfbasis0(GEN x,long flag,GEN p)
-    GEN     nfdiscf0(GEN x,long flag, GEN p)
-    GEN     nfreducemodideal(GEN nf,GEN x,GEN ideal)
+    GEN     nfdisc0(GEN x,long flag, GEN p)
     GEN     nfreducemodpr(GEN nf, GEN x, GEN modpr)
     GEN     polcompositum0(GEN pol1, GEN pol2,long flag)
-    GEN     primedec(GEN nf,GEN p)
+    GEN     idealprimedec(GEN nf,GEN p)
     GEN     rnfbasis(GEN bnf, GEN order)
     GEN     rnfdet(GEN nf, GEN order)
-    GEN     rnfdet2(GEN nf, GEN A, GEN I)
     GEN     rnfdiscf(GEN nf, GEN pol)
     GEN     rnfequation(GEN nf, GEN pol2)
     GEN     rnfequation0(GEN nf, GEN pol2, long flall)
     GEN     rnfequation2(GEN nf, GEN pol)
-    GEN     rnfhermitebasis(GEN bnf, GEN order)
+    GEN     rnfhnfbasis(GEN bnf, GEN order)
     long    rnfisfree(GEN bnf, GEN order)
     GEN     rnflllgram(GEN nf, GEN pol, GEN order,long prec)
     GEN     rnfpolred(GEN nf, GEN pol, long prec)
     GEN     rnfpolredabs(GEN nf, GEN pol, long flag)
     GEN     rnfpseudobasis(GEN nf, GEN pol)
     GEN     rnfsimplifybasis(GEN bnf, GEN order)
-    GEN     rnfsteinitz(GEN nf, GEN order)
-    GEN     smallbase(GEN x, GEN *y)
-    GEN     smalldiscf(GEN x)
-    long    val_fact(ulong n, ulong p)
-    GEN     zk_to_ff_init(GEN nf, GEN *pr, GEN *T, GEN *p)
-    GEN     zk_to_ff(GEN x, GEN modpr)
-    GEN     zkmodprinit(GEN nf, GEN pr)
 
     # base3.c 
 
-    GEN     _algtobasis(GEN nf, GEN x)
-    GEN     _algtobasis_cp(GEN nf, GEN x)
-    GEN     _basistoalg(GEN nf, GEN x)
     GEN     algtobasis(GEN nf, GEN x)
-    GEN     algtobasis_i(GEN nf,GEN x)
-    GEN     arch_to_perm(GEN arch)
     GEN     basistoalg(GEN nf, GEN x)
-    GEN     element_div(GEN nf, GEN x, GEN y)
-    GEN     element_inv(GEN nf, GEN x)
-    GEN     element_invmodideal(GEN nf, GEN x, GEN ideal)
-    GEN     element_mul(GEN nf,GEN x,GEN y)
-    GEN     element_muli(GEN nf,GEN x,GEN y)
-    GEN     element_mulid(GEN nf, GEN x, long i)
-    GEN     element_mulvec(GEN nf, GEN x, GEN v)
-    GEN     element_pow(GEN nf,GEN x,GEN k)
-    GEN     element_pow_mod_p(GEN nf, GEN x, GEN n, GEN p)
-    GEN     element_powmodideal(GEN nf,GEN x,GEN k,GEN ideal)
-    GEN     element_powmodidele(GEN nf,GEN x,GEN k,GEN idele,GEN structarch)
-    GEN     element_sqr(GEN nf,GEN x)
-    GEN     element_sqri(GEN nf, GEN x)
-    long    element_val(GEN nf, GEN x, GEN vp)
-    GEN     eltmul_get_table(GEN nf, GEN x)
+    long    nfval(GEN nf, GEN x, GEN vp)
     GEN     ideallist(GEN nf,long bound)
     GEN     ideallist0(GEN nf,long bound, long flag)
     GEN     ideallistarch(GEN nf, GEN list, GEN arch)
-    GEN     ideallistarch0(GEN nf, GEN list, GEN arch,long flag)
-    GEN     ideallistarchgen(GEN nf, GEN list, GEN arch)
-    GEN     ideallistunit(GEN nf,long bound)
-    GEN     ideallistunitarch(GEN bnf,GEN list,GEN arch)
-    GEN     ideallistunitarchgen(GEN bnf,GEN list,GEN arch)
-    GEN     ideallistunitgen(GEN nf,long bound)
-    GEN     ideallistzstar(GEN nf,long bound)
-    GEN     ideallistzstargen(GEN nf,long bound)
     GEN     idealstar0(GEN nf, GEN x,long flag)
-    int     isnfscalar(GEN x)
-    GEN     lllreducemodmatrix(GEN x,GEN y)
     GEN     nfdiveuc(GEN nf, GEN a, GEN b)
     GEN     nfdivrem(GEN nf, GEN a, GEN b)
     GEN     nfmod(GEN nf, GEN a, GEN b)
-    GEN     nfreducemodidele(GEN nf,GEN g,GEN idele,GEN structarch)
     GEN     reducemodinvertible(GEN x, GEN y)
-    GEN     reducemodmatrix(GEN x, GEN y)
-    GEN     reducemodHNF(GEN x, GEN y, GEN *Q)
-    GEN     set_sign_mod_idele(GEN nf, GEN x, GEN y, GEN idele, GEN sarch)
-    GEN     smithrel(GEN H, GEN *newU, GEN *newUi)
     GEN     vecmodii(GEN a, GEN b)
-    GEN     zarchstar(GEN nf,GEN x,GEN arch)
-    GEN     zideallog(GEN nf,GEN x,GEN bigideal)
+    GEN     ideallog(GEN nf,GEN x,GEN bigideal)
     GEN     zidealstar(GEN nf, GEN x)
-    GEN     zidealstarinit(GEN nf, GEN x)
-    GEN     zidealstarinitall(GEN nf, GEN x,long flun)
-    GEN     zidealstarinitgen(GEN nf, GEN x)
     GEN     znlog(GEN x, GEN g)
-    GEN     zsigne(GEN nf,GEN alpha,GEN arch)
-    GEN     zsigns(GEN nf,GEN alpha)
 
     # base4.c 
 
-    int     Z_ishnfall(GEN x)
-    GEN     element_divmodpr(GEN nf, GEN x, GEN y, GEN modpr)
-    GEN     element_invmodpr(GEN nf, GEN y, GEN modpr)
-    GEN     element_mulmodpr(GEN nf, GEN x, GEN y, GEN modpr)
-    GEN     element_powmodpr(GEN nf, GEN x, GEN k, GEN modpr)
-    GEN     element_reduce(GEN nf, GEN x, GEN ideal)
-    GEN     ideal_two_elt(GEN nf, GEN ix)
-    GEN     ideal_two_elt0(GEN nf, GEN ix, GEN a)
-    GEN     ideal_two_elt2(GEN nf, GEN x, GEN a)
+    GEN     nfreduce(GEN nf, GEN x, GEN ideal)
+    GEN     idealtwoelt(GEN nf, GEN ix)
+    GEN     idealtwoelt0(GEN nf, GEN ix, GEN a)
+    GEN     idealtwoelt2(GEN nf, GEN x, GEN a)
     GEN     idealadd(GEN nf, GEN x, GEN y)
     GEN     idealaddmultoone(GEN nf, GEN list)
     GEN     idealaddtoone(GEN nf, GEN x, GEN y)
@@ -687,43 +519,28 @@
     GEN     idealdivpowprime(GEN nf, GEN x, GEN vp, GEN n)
     GEN     idealmulpowprime(GEN nf, GEN x, GEN vp, GEN n)
     GEN     idealfactor(GEN nf, GEN x)
-    GEN     idealhermite(GEN nf, GEN x)
-    GEN     idealhermite2(GEN nf, GEN a, GEN b)
+    GEN     idealhnf(GEN nf, GEN x)
     GEN     idealhnf0(GEN nf, GEN a, GEN b)
     GEN     idealintersect(GEN nf, GEN x, GEN y)
     GEN     idealinv(GEN nf, GEN ix)
-    GEN     ideallllred(GEN nf,GEN ix,GEN vdir,long prec)
+    GEN     idealred0(GEN nf, GEN ix, GEN vdir)
     GEN     idealred_elt(GEN nf, GEN I)
-    GEN     ideallllred_elt(GEN nf, GEN I, GEN vdir)
     GEN     idealmul(GEN nf, GEN ix, GEN iy)
     GEN     idealmul0(GEN nf, GEN ix, GEN iy, long flag, long prec)
-    GEN     idealmulh(GEN nf, GEN ix, GEN iy)
-    GEN     idealmulprime(GEN nf,GEN ix,GEN vp)
-    GEN     idealmulred(GEN nf, GEN ix, GEN iy, long prec)
+    GEN     idealmulred(GEN nf, GEN ix, GEN iy)
     GEN     idealnorm(GEN nf, GEN x)
     GEN     idealpow(GEN nf, GEN ix, GEN n)
     GEN     idealpow0(GEN nf, GEN ix, GEN n, long flag, long prec)
     GEN     idealpowred(GEN nf, GEN ix, GEN n,long prec)
     GEN     idealpows(GEN nf, GEN ideal, long iexp)
     long    idealtyp(GEN *ideal, GEN *arch)
-    GEN     ideleaddone(GEN nf, GEN x, GEN idele)
-    int     ishnfall(GEN x)
-    int     isidentity(GEN x)
-    GEN     hnfall_i(GEN A, GEN *ptB, long remove)
     long    isideal(GEN nf,GEN x)
-    long    isinvector(GEN v, GEN x, long n)
     GEN     minideal(GEN nf,GEN ix,GEN vdir,long prec)
     GEN     mul_content(GEN cx, GEN cy)
     GEN     nfdetint(GEN nf,GEN pseudo)
-    GEN     nfhermite(GEN nf, GEN x)
-    GEN     nfhermitemod(GEN nf, GEN x, GEN detmat)
     GEN     nfkermodpr(GEN nf, GEN x, GEN modpr)
-    GEN     nfmodprinit(GEN nf, GEN pr)
-    GEN     nfsmith(GEN nf, GEN x)
+    GEN     nfsnf(GEN nf, GEN x)
     GEN     nfsolvemodpr(GEN nf, GEN a, GEN b, GEN modpr)
-    GEN     prime_to_ideal(GEN nf, GEN vp)
-    GEN     principalideal(GEN nf, GEN a)
-    GEN     principalidele(GEN nf, GEN a, long prec)
     GEN     vecdiv(GEN x, GEN y)
     GEN     vecinv(GEN x)
     GEN     vecmul(GEN x, GEN y)
@@ -731,7 +548,6 @@
 
     # base5.c 
 
-    GEN     lift_to_pol(GEN x)
     GEN     matalgtobasis(GEN nf, GEN x)
     GEN     matbasistoalg(GEN nf, GEN x)
     GEN     rnfalgtobasis(GEN rnf, GEN x)
@@ -749,43 +565,34 @@
     GEN     rnfidealreltoabs(GEN rnf, GEN x)
     GEN     rnfidealtwoelement(GEN rnf,GEN x)
     GEN     rnfidealup(GEN rnf, GEN x)
-    GEN     rnfinitalg(GEN nf,GEN pol,long prec)
+    GEN     rnfinit(GEN nf, GEN pol)
 
     # bibli1.c 
 
     GEN     ZM_zc_mul(GEN x, GEN y)
     GEN     ZM_zm_mul(GEN x, GEN y)
     GEN     T2_from_embed(GEN x, long r1)
-    GEN     algdep(GEN x, long n, long prec)
-    GEN     algdep0(GEN x, long n, long bit,long prec)
-    GEN     algdep2(GEN x, long n, long bit)
+    GEN     algdep(GEN x, long n)
+    GEN     algdep0(GEN x, long n, long bit)
     GEN     factoredpolred(GEN x, GEN p)
     GEN     factoredpolred2(GEN x, GEN p)
     GEN     kerint(GEN x)
-    GEN     kerint1(GEN x)
-    GEN     lindep(GEN x, long prec)
-    GEN     lindep0(GEN x, long flag,long prec)
+    GEN     lindep(GEN x)
+    GEN     lindep0(GEN x, long flag)
     GEN     lindep2(GEN x, long bit)
     GEN     lll(GEN x, long prec)
     GEN     lllgen(GEN x)
     GEN     lllgram(GEN x, long prec)
-    GEN     lllgramall(GEN x, long alpha, long flag)
     GEN     lllgramgen(GEN x)
     GEN     lllgramint(GEN x)
-    GEN     lllgramintern(GEN x, long alpha, long flag, long prec)
     GEN     lllgramkerim(GEN x)
     GEN     lllgramkerimgen(GEN x)
     GEN     lllint(GEN x)
-    GEN     lllint_i(GEN x, long alpha, int gram, GEN *h, GEN *ptfl, GEN *ptB)
-    GEN     lllint_ip(GEN x, long alpha)
-    GEN     lllintern(GEN x, long D, long flag, long prec)
     GEN     lllintpartial(GEN mat)
-    GEN     lllintpartial_ip(GEN mat)
     GEN     lllkerim(GEN x)
     GEN     lllkerimgen(GEN x)
     GEN     matkerint0(GEN x,long flag)
     GEN     minim(GEN a, GEN borne, GEN stockmax)
-    GEN     nf_get_LLL(GEN nf)
     GEN     qfrep0(GEN a, GEN borne, long flag)
     GEN     qfminim0(GEN a, GEN borne, GEN stockmax,long flag, long prec)
     GEN     minim2(GEN a, GEN borne, GEN stockmax)
@@ -798,8 +605,8 @@
     GEN     polredabs0(GEN x, long flag)
     GEN     polredabs2(GEN x)
     GEN     polredabsall(GEN x, long flun)
-    GEN     qflll0(GEN x, long flag, long prec)
-    GEN     qflllgram0(GEN x, long flag, long prec)
+    GEN     qflll0(GEN x, long flag)
+    GEN     qflllgram0(GEN x, long flag)
     GEN     smallpolred(GEN x)
     GEN     smallpolred2(GEN x)
     char    *stackmalloc(size_t N)
@@ -807,13 +614,11 @@
 
     # bibli2.c 
 
-    GEN     binome(GEN x, long k)
-    int     cmp_pol(GEN x, GEN y)
+    GEN     binomial(GEN x, long k)
     int     cmp_prime_ideal(GEN x, GEN y)
     int     cmp_prime_over_p(GEN x, GEN y)
-    int     cmp_vecint(GEN x, GEN y)
     GEN     convol(GEN x, GEN y)
-    GEN     cyclo(long n, long v)
+    GEN     polcyclo(long n, long v)
     GEN     dirdiv(GEN x, GEN y)
     GEN     dirmul(GEN x, GEN y)
     GEN     dirzetak(GEN nf, GEN b)
@@ -822,44 +627,38 @@
     GEN     gen_sort(GEN x, int flag, int (*cmp)(GEN,GEN))
     GEN     genrand(GEN N)
     GEN     getheap()
-    long    getrand()
+    GEN     getrand()
     long    getstack()
     long    gettime()
     GEN     gprec(GEN x, long l)
-    GEN     gprec_trunc(GEN x, long pr)
     GEN     gprec_w(GEN x, long pr)
     GEN     ggrando(GEN x, long n)
-    GEN     gtor(GEN x, long l)
     GEN     gtoset(GEN x)
     GEN     indexlexsort(GEN x)
     GEN     indexsort(GEN x)
     GEN     laplace(GEN x)
-    GEN     legendre(long n, long v)
+    GEN     pollegendre(long n, long v)
     GEN     lexsort(GEN x)
     GEN     mathilbert(long n)
     GEN     matqpascal(long n, GEN q)
-    GEN     modreverse_i(GEN a, GEN T)
     GEN     numtoperm(long n, GEN x)
-    int     pari_compare_int(int *a,int *b)
-    int     pari_compare_long(long *a,long *b)
     GEN     permtonum(GEN x)
     GEN     polint(GEN xa, GEN ya, GEN x, GEN *dy)
     GEN     polrecip(GEN x)
-    GEN     polymodrecip(GEN x)
+    GEN     modreverse(GEN x)
     GEN     roots_to_pol(GEN a, long v)
     GEN     setintersect(GEN x, GEN y)
     long    setisset(GEN x)
     GEN     setminus(GEN x, GEN y)
-    long    setrand(long seed)
+    void    setrand(GEN seed)
     long    setsearch(GEN x, GEN y, long flag)
     GEN     setunion(GEN x, GEN y)
-    GEN     sindexlexsort(GEN x)
-    GEN     sindexsort(GEN x)
+    GEN     indexlexsort(GEN x)
+    GEN     indexsort(GEN x)
     GEN     sort(GEN x)
     long    tablesearch(GEN T, GEN x, int (*cmp)(GEN,GEN))
     GEN     tayl(GEN x, long v, long precdl)
-    GEN     tchebi(long n, long v)
-    GEN     vecbinome(long n)
+    GEN     polchebyshev1(long n, long v)
     GEN     vecsort(GEN x, GEN k)
     GEN     vecsort0(GEN x, GEN k, long flag)
 
@@ -869,46 +668,33 @@
     GEN     buchreal(GEN D, GEN gsens, GEN gcbach, GEN gcbach2, GEN gRELSUP, long prec)
     GEN     cgetalloc(long t, size_t l)
     GEN     quadclassunit0(GEN x, long flag,GEN data, long prec)
-    GEN     quadhilbert(GEN D, GEN flag, long prec)
+    GEN     quadhilbert(GEN D, long prec)
     GEN     quadray(GEN bnf, GEN f, GEN flag, long prec)
 
-
     # buch2.c 
-
-    GEN     bnfclassunit0(GEN P,long flag,GEN data,long prec)
+    
     GEN     bnfinit0(GEN P,long flag,GEN data,long prec)
-    GEN     bnfmake(GEN sbnf,long prec)
-    GEN     buchall(GEN P, double bach, double bach2, long nbrelpid, long flun, long prec)
-    GEN     buchfu(GEN bignf)
+    GEN     bnf_get_fu(GEN bignf)
     GEN     check_and_build_obj(GEN S, int tag, GEN (*build)(GEN))
-    GEN     classgrouponly(GEN P,GEN data,long prec)
     GEN     isprincipal(GEN bignf, GEN x)
-    GEN     isprincipalall(GEN bignf, GEN x,long flall)
+    GEN     bnfisprincipal0(GEN bignf, GEN x,long flall)
     GEN     isprincipalfact(GEN bnf,GEN P, GEN e, GEN C, long flag)
     GEN     isprincipalforce(GEN bignf,GEN x)
     GEN     isprincipalgen(GEN bignf, GEN x)
     GEN     isprincipalgenforce(GEN bignf,GEN x)
-    GEN     isunit(GEN bignf, GEN x)
-    GEN     quick_isprincipalgen(GEN bnf, GEN x)
+    GEN     bnfisunit(GEN bignf, GEN x)
     GEN     regulator(GEN P,GEN data,long prec)
     GEN     signunits(GEN bignf)
-    GEN     smallbuchinit(GEN pol,double bach,double bach2,long nbrelpid,long prec)
-    GEN     zsignunits(GEN bnf, GEN archp, int add_zu)
 
-    # buch3.c 
+    # buch3.c
 
-    GEN     bnrclass0(GEN bignf, GEN ideal, long flag)
     GEN     bnrconductor(GEN arg0,GEN arg1,GEN arg2,GEN flag)
     GEN     bnrconductorofchar(GEN bnr,GEN chi)
     GEN     bnrdisc0(GEN arg0, GEN arg1, GEN arg2, long flag)
     GEN     bnrdisclist0(GEN bnf,GEN borne, GEN arch, long all)
-    GEN     bnrinit0(GEN bignf,GEN ideal,long flag)
     long    bnrisconductor(GEN arg0,GEN arg1,GEN arg2)
     GEN     buchnarrow(GEN bignf)
-    GEN     buchray(GEN bignf,GEN ideal)
-    GEN     buchrayinit(GEN bignf,GEN ideal)
-    GEN     buchrayinitgen(GEN bignf,GEN ideal)
-    long    certifybuchall(GEN bnf)
+    long    bnfcertify(GEN bnf)
     GEN     conductor(GEN bnr,GEN subgroup,long all)
     GEN     decodemodule(GEN nf, GEN fa)
     GEN     discrayabs(GEN bnr,GEN subgroup)
@@ -918,12 +704,11 @@
     GEN     discrayabslistlong(GEN bnf, long bound)
     GEN     discrayrel(GEN bnr,GEN subgroup)
     GEN     discrayrelcond(GEN bnr,GEN subgroup)
-    GEN     idealmodidele(GEN bnr, GEN x)
     GEN     isprincipalray(GEN bignf, GEN x)
-    GEN     isprincipalrayall(GEN bignf, GEN x,long flall)
+    GEN     bnrisprincipal(GEN bignf, GEN x,long flall)
     GEN     isprincipalraygen(GEN bignf, GEN x)
-    GEN     rayclassno(GEN bignf,GEN ideal)
-    GEN     rayclassnolist(GEN bnf,GEN listes)
+    GEN     bnrclassno(GEN bignf,GEN ideal)
+    GEN     bnrclassnolist(GEN bnf,GEN listes)
     GEN     rnfconductor(GEN bnf, GEN polrel, long flag)
     GEN     rnfkummer(GEN bnr, GEN subgroup, long all, long prec)
     GEN     rnfnormgroup(GEN bnr, GEN polrel)
@@ -933,26 +718,24 @@
 
     GEN     bnfisnorm(GEN bnf,GEN x,long flag,long PREC)
     GEN     rnfisnorm(GEN S, GEN x, long flag)
-    GEN     rnfisnorminit(GEN bnf, GEN relpol, int galois)
     GEN     bnfissunit(GEN bnf,GEN suni,GEN x)
     GEN     bnfsunit(GEN bnf,GEN s,long PREC)
     long    nfhilbert(GEN bnf,GEN a,GEN b)
     long    nfhilbert0(GEN bnf,GEN a,GEN b,GEN p)
-    long    nfhilbertp(GEN bnf,GEN a,GEN b,GEN p)
-    long    qpsoluble(GEN pol,GEN p)
-    long    qpsolublenf(GEN bnf,GEN pol,GEN p)
-    long    zpsoluble(GEN pol,GEN p)
-    long    zpsolublenf(GEN bnf,GEN pol,GEN p)
+
+    # ellanal.c
+
+    GEN     ellanalyticrank(GEN e, GEN eps, long prec)
+    GEN     ellL1(GEN e, long r, long prec)
 
     # elliptic.c 
 
     GEN     addell(GEN e, GEN z1, GEN z2)
     GEN     akell(GEN e, GEN n)
     GEN     anell(GEN e, long n)
-    GEN     apell(GEN e, GEN p)
-    GEN     apell2(GEN e, GEN p)
+    GEN     ellap(GEN e, GEN p)
     GEN     bilhell(GEN e, GEN z1, GEN z2, long prec)
-    GEN     coordch(GEN e, GEN ch)
+    GEN     ellchangecurve(GEN e, GEN ch)
     GEN     ellap0(GEN e, GEN p, long flag)
     GEN     elleisnum(GEN om, long k, long flag, long prec)
     GEN     elleta(GEN om, long prec)
@@ -963,30 +746,25 @@
     GEN     ellsigma(GEN om, GEN z, long flag, long prec)
     GEN     elltors0(GEN e, long flag)
     GEN     ellwp0(GEN e, GEN z, long flag, long prec, long PREC)
-
     GEN     ellzeta(GEN om, GEN z, long prec)
     GEN     ghell(GEN e, GEN a, long prec)
-    GEN     ghell2(GEN e, GEN a, long prec)
-    GEN     globalreduction(GEN e1)
-    GEN     initell(GEN x, long prec)
+    GEN     ellglobalred(GEN e1)
     GEN     elllocalred(GEN e, GEN p1)
-    GEN     lseriesell(GEN e, GEN s, GEN A, long prec)
+    GEN     elllseries(GEN e, GEN s, GEN A, long prec)
     GEN     mathell(GEN e, GEN x, long prec)
     int     oncurve(GEN e, GEN z)
-    GEN     ordell(GEN e, GEN x, long prec)
+    GEN     ellordinate(GEN e, GEN x, long prec)
     GEN     orderell(GEN e, GEN p)
-    GEN     pointch(GEN x, GEN ch)
+    GEN     ellchangepoint(GEN x, GEN ch)
     GEN     pointell(GEN e, GEN z, long prec)
     GEN     powell(GEN e, GEN z, GEN n)
-    GEN     smallinitell(GEN x)
     GEN     subell(GEN e, GEN z1, GEN z2)
     GEN     taniyama(GEN e)
-    GEN     torsell(GEN e)
     GEN     weipell(GEN e, long precdl)
     GEN     zell(GEN e, GEN z, long prec)
 
     # es.c 
-    GEN     GENtocanonicalstr(GEN x)
+    
     GEN     GENtoGENstr(GEN x)
     char*   GENtoTeXstr(GEN x)
     char*   GENtostr(GEN x)
@@ -995,33 +773,18 @@
     GEN     Strexpand(GEN g)
     GEN     Strtex(GEN g)
     void    brute(GEN g, char format, long dec)
-    void    bruteall(GEN g, char f, long d, long sp)
-    void    bruterr(GEN x,char format,long dec)
-    void    error0(GEN g)
-    void    etatpile(unsigned int n)
-    char*   expand_tilde(char *s)
+    void    dbgGEN(GEN x, long nb)
     int     file_is_binary(FILE *f)
-    void    flusherr()
-    void    fprintferr(char* pat, ...)
+    void    gpwritebin(char *filename, GEN x)
+    GEN     gp_read_file(char *filename)
+    GEN     gp_read_str(char *s)
     void    killallfiles(int check)
-    int     killfile(pariFILE *f)
-    GEN     lisGEN(FILE *f)
+    GEN     gp_read_stream(FILE *f)
     void    matbrute(GEN g, char format, long dec)
-    pariFILE* newfile(FILE *f, char *name, int type)
-    void    os_close(long fd)
     char*   os_getenv(char *s)
-    long    os_open(char *s, int mode)
-    void    os_read(long fd, char ch[], long s)
     void    (*os_signal(int sig, void (*f)(int)))(int)
-    void    outbeaut(GEN x)
-    void    outbeauterr(GEN x)
-    void    outbrute(GEN x)
-    void    outerr(GEN x)
     void    outmat(GEN x)
     void    output(GEN x)
-    void    outsor(GEN x)
-    void    outtex(GEN x)
-    char*   pGENtostr(GEN g, long flag)
     void    pari_fclose(pariFILE *f)
     pariFILE*   pari_fopen(char *s, char *mode)
     pariFILE*   pari_safefopen(char *s, char *mode)
@@ -1029,47 +792,38 @@
     char*   pari_strndup(char *s, long n)
     char*   pari_unique_filename(char *s)
     void    pari_unlink(char *s)
-    void    pariflush()
-    void    pariputc(char c)
-    void    pariputs(char *s)
-    void    pariputsf(char *format, ...)
-    int     popinfile()
+    void    pari_flush()
+    void    pari_putc(char c)
+    void    pari_puts(char *s)
     #void    print(GEN g)   # syntax error
     void    print1(GEN g)
-    void    printp(GEN g)
-    void    printp1(GEN g)
     void    printtex(GEN g)
     GEN     readbin(char *name, FILE *f)
-    void    sor(GEN g, char fo, long dd, long chmp)
     void    switchin(char *name)
     void    switchout(char *name)
     void    texe(GEN g, char format, long dec)
     pariFILE* try_pipe(char *cmd, int flag)
     char*   type_name(long t)
-    void    voir(GEN x, long nb)
-    #void    vpariputs(char* format, va_list args)
     void    write0(char *s, GEN g)
     void    write1(char *s, GEN g)
-    void    writebin(char *name, GEN x)
     void    writetex(char *s, GEN g)
 
     # galconj.c 
 
     GEN     checkgal(GEN gal)
-    GEN     galoisconj(GEN nf)
     GEN     galoisconj0(GEN nf, long flag, GEN d, long prec)
-    GEN     galoisconj2(GEN x, long nbmax, long prec)
-    GEN     galoisconj4(GEN T, GEN den, long flag, long karma)
     GEN     galoisexport(GEN gal, long format)
     GEN     galoisfixedfield(GEN gal, GEN v, long flag, long y)
     GEN     galoisidentify(GEN gal)
     GEN     galoisinit(GEN nf, GEN den)
     GEN     galoisisabelian(GEN gal, long flag)
+    long    galoisisnormal(GEN gal, GEN sub)
     GEN     galoispermtopol(GEN gal, GEN perm)
     GEN     galoissubgroups(GEN G)
     GEN     galoissubfields(GEN G, long flag, long v)
     long    numberofconjugates(GEN T, long pdepart)
     GEN     vandermondeinverse(GEN L, GEN T, GEN den, GEN prep)
+    
     # gen1.c 
 
     GEN     gadd(GEN x, GEN y)
@@ -1080,30 +834,23 @@
     GEN     gsub(GEN x, GEN y)
 
     # gen2.c 
-    GEN     gopgs2(GEN (*f)(GEN, GEN), GEN y, long s)
-    GEN     gopsg2(GEN (*f)(GEN, GEN), long s, GEN y)
-    void    gopsgz(GEN (*f)(GEN, GEN), long s, GEN y, GEN z)
-    int     opgs2(int (*f)(GEN, GEN), GEN y, long s)
-
-    long    ZX_valuation(GEN x, GEN *Z)
+    
     GEN     ZX_mul(GEN x, GEN y)
-    GEN     cgetimag()
     GEN     cgetp(GEN x)
     GEN     cvtop(GEN x, GEN p, long l)
     GEN     cvtop2(GEN x, GEN y)
-    GEN     from_Kronecker(GEN z, GEN pol)
     GEN     gabs(GEN x, long prec)
     void    gaffect(GEN x, GEN y)
     void    gaffsg(long s, GEN x)
     GEN     gclone(GEN x)
     int     gcmp(GEN x, GEN y)
     int     gcmpsg(long x, GEN y)
-    int     gcmp0(GEN x)
-    int     gcmp1(GEN x)
-    int     gcmp_1(GEN x)
+    int     gequal0(GEN x)
+    int     gequal1(GEN x)
+    int     gequalm1(GEN x)
     GEN     gcvtop(GEN x, GEN p, long r)
-    int     gegal(GEN x, GEN y)
-    int     gegalsg(long s, GEN x)
+    int     gequal(GEN x, GEN y)
+    int     gequalsg(long s, GEN x)
     long    gexpo(GEN x)
     long    ggval(GEN x, GEN p)
     long    glength(GEN x)
@@ -1117,8 +864,7 @@
     GEN     gtolist(GEN x)
     long    gtolong(GEN x)
     int     lexcmp(GEN x, GEN y)
-    GEN     listconcat(GEN list1, GEN list2)
-    GEN     listcreate(long n)
+    GEN     listcreate()
     GEN     listinsert(GEN list, GEN object, long index)
     void    listkill(GEN list)
     GEN     listput(GEN list, GEN object, long index)
@@ -1126,16 +872,10 @@
     GEN     matsize(GEN x)
     GEN     normalize(GEN x)
     GEN     normalizepol(GEN x)
-    GEN     normalizepol_i(GEN x, long lx)
-    long    polvaluation(GEN x, GEN *z)
-    long    polvaluation_inexact(GEN x, GEN *Z)
-    GEN     pureimag(GEN x)
-    GEN     quadtoc(GEN x, long l)
     long    sizedigit(GEN x)
     long    u_lval(ulong x, ulong p)
     long    u_lvalrem(ulong x, ulong p, ulong *py)
     long    u_pvalrem(ulong x, GEN p, ulong *py)
-    GEN     to_Kronecker(GEN P, GEN Q)
     GEN     vecmax(GEN x)
     GEN     vecmin(GEN x)
     long    Z_lval(GEN n, ulong p)
@@ -1146,23 +886,20 @@
 
     # gen3.c 
 
-    GEN     _toser(GEN x)
-    GEN     Mod0(GEN x, GEN y,long flag)
     GEN     ceil_safe(GEN x)
     GEN     ceilr(GEN x)
     GEN     centerlift(GEN x)
     GEN     centerlift0(GEN x,long v)
-    GEN     coefs_to_col(long n, ...)
-    GEN     coefs_to_int(long n, ...)
-    GEN     coefs_to_pol(long n, ...)
-    GEN     coefs_to_vec(long n, ...)
+    GEN     mkcoln(long n, ...)
+    GEN     mkintn(long n, ...)
+    GEN     mkpoln(long n, ...)
+    GEN     mkvecn(long n, ...)
     GEN     compo(GEN x, long n)
     GEN     deg1pol(GEN x1, GEN x0,long v)
-    GEN     deg1pol_i(GEN x1, GEN x0,long v)
     long    degree(GEN x)
     GEN     denom(GEN x)
     GEN     deriv(GEN x, long v)
-    GEN     derivpol(GEN x)
+    GEN     RgX_deriv(GEN x)
     GEN     derivser(GEN x)
     GEN     diviiround(GEN x, GEN y)
     GEN     divrem(GEN x, GEN y, long v)
@@ -1177,10 +914,8 @@
     GEN     geq(GEN x, GEN y)
     GEN     geval(GEN x)
     GEN     gfloor(GEN x)
-    GEN     gfloor2n(GEN x, long s)
     GEN     gfrac(GEN x)
     GEN     gge(GEN x, GEN y)
-    GEN     ggprecision(GEN x)
     GEN     ggrando(GEN x, long n)
     GEN     ggt(GEN x, GEN y)
     GEN     gimag(GEN x)
@@ -1188,7 +923,7 @@
     GEN     gle(GEN x, GEN y)
     GEN     glt(GEN x, GEN y)
     GEN     gmod(GEN x, GEN y)
-    GEN     gmodulcp(GEN x,GEN y)
+    GEN     gmodulo(GEN x,GEN y)
     GEN     gmodgs(GEN x, long y)
     GEN     gmodulo(GEN x,GEN y)
     GEN     gmodulsg(long x, GEN y)
@@ -1217,19 +952,16 @@
     GEN     gtrunc(GEN x)
     int     gvar(GEN x)
     int     gvar2(GEN x)
-    int     gvar9(GEN x)
     GEN     hqfeval(GEN q, GEN x)
     GEN     imag_i(GEN x)
     GEN     int2n(long n)
     GEN     integ(GEN x, long v)
     int     iscomplex(GEN x)
     int     isexactzero(GEN g)
-    int     isexactzeroscalar(GEN g)
     int     isinexact(GEN x)
     int     isinexactreal(GEN x)
     long    isint(GEN n, long *ptk)
     int     issmall(GEN n, long *ptk)
-    int     ismonome(GEN x)
     GEN     lift(GEN x)
     GEN     lift0(GEN x,long v)
     GEN     lift_intern0(GEN x,long v)
@@ -1238,7 +970,6 @@
     GEN     mkintn(long n, ...)
     GEN     mkpoln(long n, ...)
     GEN     mkvecn(long n, ...)
-    GEN     mulmat_real(GEN x, GEN y)
     GEN     numer(GEN x)
     GEN     padicappr(GEN f, GEN a)
     long    padicprec(GEN x, GEN p)
@@ -1249,7 +980,6 @@
     GEN     pollead(GEN x,long v)
     long    precision(GEN x)
     GEN     precision0(GEN x,long n)
-    GEN     qf_base_change(GEN q, GEN M, int flag)
     GEN     qfeval(GEN q, GEN x)
     GEN     real_i(GEN x)
     GEN     real2n(long n, long prec)
@@ -1259,12 +989,10 @@
     GEN     scalarpol(GEN x, long v)
     GEN     scalarser(GEN x, long v, long prec)
     GEN     simplify(GEN x)
-    GEN     simplify_i(GEN x)
     GEN     tayl(GEN x, long v, long precdl)
     GEN     toser_i(GEN x)
     GEN     truecoeff(GEN x, long n)
     GEN     trunc0(GEN x, GEN *pte)
-    GEN     u2toi(ulong a, ulong b)
     GEN     zerocol(long n)
     GEN     zeromat(long m, long n)
     GEN     zeropadic(GEN p, long e)
@@ -1278,12 +1006,8 @@
 
     # ifactor1.c 
 
-    long    BSW_psp(GEN N)
     long    is_357_power(GEN x, GEN *pt, ulong *mask)
-    long    is_odd_power(GEN x, GEN *pt, ulong *curexp, ulong cutoffbits)
-    long    millerrabin(GEN n, long k)
     GEN     nextprime(GEN n)
-    GEN     plisprime(GEN N, long flag)
     GEN     precprime(GEN n)
 
     # init.c 
@@ -1292,16 +1016,9 @@
     void    TIMERstart(pari_timer *T)
     long    allocatemoremem(size_t newsize)
     GEN     changevar(GEN x, GEN y)
-    void    disable_dbg(long val)
-    GEN     dummycopy(GEN x)
-    void    err(long numerr, ...)
-    #void   *err_catch(long errnum, jmp_buf *penv)
-    void    err_leave(void **v)
-    ## forcecopy is deprecated, use gcopy instead
-    ## GEN     forcecopy(GEN x)
-    void    freeall()
+    void    pari_err(long numerr, ...)
+    long    err_catch(long errnum, jmp_buf *penv)
     GEN     gcopy(GEN x)
-    GEN     gcopy_i(GEN x, long lx)
     GEN     gerepile(pari_sp ltop, pari_sp lbot, GEN q)
     void    gerepileall(pari_sp av, int n, ...)
     void    gerepileallsp(pari_sp av, pari_sp tetpil, int n, ...)
@@ -1313,21 +1030,19 @@
     GEN     gerepileupto(pari_sp av, GEN q)
     GEN     gerepileuptoint(pari_sp av, GEN q)
     GEN     gerepileuptoleaf(pari_sp av, GEN q)
-    char*   gpmalloc(size_t bytes)
-    char*   gprealloc(void *pointer,size_t size)
+    char*   pari_malloc(size_t bytes)
+    char*   pari_realloc(void *pointer,size_t size)
     void    gunclone(GEN x)
-    void    killbloc(GEN x)
+    void    killblock(GEN x)
     void    msgTIMER(pari_timer *T, char *format, ...)
     void    msgtimer(char *format, ...)
-    GEN     newbloc(long n)
+    GEN     newblock(long n)
+    void    pari_close()
     void    pari_init(size_t parisize, ulong maxprime)
-    void    pari_close()
-    GEN     reorder(GEN x)
+    void    pari_init_opts(size_t parisize, ulong maxprime, ulong init_opts)
     void    stackdummy(GEN x, long l)
-    GEN     stackify(GEN x)
-    stackzone* switch_stack(stackzone *z, long n)
-    long    taille(GEN x)
-    long    taille2(GEN x)
+    long    gsizebyte(GEN x)
+    long    gsizeword(GEN x)
     long    timer()
     long    timer2()
 
@@ -1411,17 +1126,14 @@
     GEN     divsi(long x, GEN y)
     GEN     divsr(long x, GEN y)
     GEN     dvmdii(GEN x, GEN y, GEN *z)
-    int     egalii(GEN x, GEN y)
+    int     equalii(GEN x, GEN y)
     GEN     floorr(GEN x)
     GEN     gcdii(GEN x, GEN y)
     GEN     int_normalize(GEN x, long known_zero_words)
     int     invmod(GEN a, GEN b, GEN *res)
-    ulong   invrev(ulong b)
     ulong   Fl_inv(ulong x, ulong p)
-    GEN     ishiftr(GEN x, long n)
     GEN     modii(GEN x, GEN y)
     void    modiiz(GEN x, GEN y, GEN z)
-    void    mpdivz(GEN x, GEN y, GEN z)
     GEN     mulii(GEN x, GEN y)
     GEN     mulir(GEN x, GEN y)
     GEN     mulrr(GEN x, GEN y)
@@ -1431,13 +1143,10 @@
     GEN     mului(ulong x, GEN y)
     GEN     mulur(ulong x, GEN y)
     GEN     muluu(ulong x, ulong y)
-    long    pari_rand31()
     GEN     randomi(GEN x)
     int     ratlift(GEN x, GEN m, GEN *a, GEN *b, GEN amax, GEN bmax)
-    GEN     resmod2n(GEN x, long n)
     double  rtodbl(GEN x)
     GEN     shifti(GEN x, long n)
-    GEN     shifti3(GEN x, long n, long flag)
     GEN     sqri(GEN x)
     #define sqrti(x) sqrtremi((x),NULL)
     GEN     sqrtremi(GEN S, GEN *R)
@@ -1450,11 +1159,9 @@
 
     GEN     nffactor(GEN nf,GEN x)
     GEN     nffactormod(GEN nf,GEN pol,GEN pr)
-    int     nfisgalois(GEN nf, GEN x)
     GEN     nfroots(GEN nf,GEN pol)
     GEN     rnfcharpoly(GEN nf,GEN T,GEN alpha,int n)
     GEN     rnfdedekind(GEN nf,GEN T,GEN pr)
-    GEN     unifpol(GEN nf,GEN pol,long flag)
 
     # part.c 
 
@@ -1463,13 +1170,7 @@
     # perm.c 
 
     GEN     abelian_group(GEN G)
-    GEN     bitvec_alloc(long n)
-    void    bitvec_clear(GEN bitvec, long b)
-    void    bitvec_set(GEN bitvec, long b)
-    GEN     bitvec_shorten(GEN bitvec, long n)
-    long    bitvec_test(GEN bitvec, long b)
     GEN     cyclicgroup(GEN g, long s)
-    GEN     cyclicperm(long l, long d)
     GEN     cyc_pow(GEN cyc, long exp)
     GEN     cyc_pow_perm(GEN cyc, long exp)
     GEN     dicyclicgroup(GEN g1, GEN g2, long s1, long s2)
@@ -1490,7 +1191,6 @@
     GEN     groupelts_abelian_group(GEN S)
     int     perm_commute(GEN p, GEN q)
     GEN     perm_cycles(GEN v)
-    GEN     perm_identity(long l)
     GEN     perm_inv(GEN x)
     GEN     perm_mul(GEN s, GEN t)
     long    perm_order(GEN perm)
@@ -1502,7 +1202,6 @@
     GEN     vecsmall_append(GEN V, long s)
     long    vecsmall_coincidence(GEN u, GEN v)
     GEN     vecsmall_concat(GEN u, GEN v)
-    GEN     vecsmall_const(long n, long c)
     GEN     vecsmall_copy(GEN x)
     int     vecsmall_lexcmp(GEN x, GEN y)
     long    vecsmall_pack(GEN V, long base, long mod)
@@ -1534,39 +1233,26 @@
     long    FqX_is_squarefree(GEN P, GEN T, GEN p)
     long    FqX_nbfact(GEN u, GEN T, GEN p)
     long    FqX_nbroots(GEN f, GEN T, GEN p)
-    GEN     FpX_rand(long d, long v, GEN p)
+    GEN     random_FpX(long d, long v, GEN p)
     GEN     FpX_roots(GEN f, GEN p)
-    GEN     apprgen(GEN f, GEN a)
-    GEN     apprgen9(GEN f, GEN a)
+    GEN     padicappr(GEN f, GEN a)
     GEN     factcantor(GEN x, GEN p)
     GEN     factmod(GEN f, GEN p)
-    GEN     factmod9(GEN f, GEN p, GEN a)
+    GEN     factorff(GEN f, GEN p, GEN a)
     GEN     factormod0(GEN f, GEN p, long flag)
     GEN     factorpadic0(GEN f,GEN p,long r,long flag)
-    GEN     factorpadic2(GEN x, GEN p, long r)
-    GEN     factorpadic4(GEN x, GEN p, long r)
-    GEN     ffinit(GEN p,long n, long v)
+    GEN     factorpadic(GEN x, GEN p, long r)
     int     gdvd(GEN x, GEN y)
-    long    hensel_lift_accel(long n, long *pmask)
-    GEN     init_Fq(GEN p, long n, long v)
-    GEN     padicsqrtnlift(GEN a, GEN n, GEN S, GEN p, long e)
-    int     poldvd(GEN x, GEN y, GEN *z)
     GEN     poldivrem(GEN x, GEN y, GEN *pr)
-    GEN     poldivrem_i(GEN x, GEN y, GEN *pr, long vx)
     GEN     rootmod(GEN f, GEN p)
     GEN     rootmod0(GEN f, GEN p,long flag)
     GEN     rootmod2(GEN f, GEN p)
     GEN     rootpadic(GEN f, GEN p, long r)
     GEN     rootpadicfast(GEN f, GEN p, long e)
-    GEN     rootpadiclift(GEN T, GEN S, GEN q, long e)
-    GEN     rootpadicliftroots(GEN f, GEN S, GEN q, long e)
-    GEN     roots2(GEN pol,long PREC)
-    GEN     rootsold(GEN x, long l)
     GEN     simplefactmod(GEN f, GEN p)
 
     # polarit2.c 
 
-    GEN     Newton_exponents(long e)
     GEN     Q_content(GEN x)
     GEN     Q_denom(GEN x)
     GEN     Q_div_to_int(GEN x, GEN c)
@@ -1579,7 +1265,6 @@
     GEN     centermod(GEN x, GEN p)
     GEN     centermod_i(GEN x, GEN p, GEN ps2)
     GEN     centermodii(GEN x, GEN p, GEN po2)
-    GEN     concat_factor(GEN f, GEN g)
     GEN     content(GEN x)
     GEN     deg1_from_roots(GEN L, long v)
     GEN     discsr(GEN x)
@@ -1587,11 +1272,8 @@
     GEN     factor(GEN x)
     GEN     factor0(GEN x,long flag)
     GEN     factorback(GEN fa,GEN nf)
-    GEN     factorback0(GEN fa,GEN e, GEN nf)
-    GEN     factorbackelt(GEN fa, GEN e, GEN nf)
-    GEN     factpol(GEN x, long hint)
     GEN     gbezout(GEN x, GEN y, GEN *u, GEN *v)
-    GEN     gcd0(GEN x, GEN y,long flag)
+    GEN     ggcd0(GEN x, GEN )
     GEN     gdeflate(GEN x, long v, long d)
     GEN     gdivexact(GEN x, GEN y)
     GEN     ggcd(GEN x, GEN y)
@@ -1599,39 +1281,32 @@
     GEN     gisirreducible(GEN x)
     GEN     glcm(GEN x, GEN y)
     GEN     glcm0(GEN x, GEN y)
-    GEN     hensel_lift_fact(GEN pol, GEN Q, GEN T, GEN p, GEN pe, long e)
-    GEN     leftright_pow(GEN,GEN,void*,GEN (*sqr)(void*,GEN),GEN (*mul)(void*,GEN,GEN))
-    GEN     leftright_pow_u(GEN x, ulong n, void *data, GEN (*sqr)(void*,GEN), GEN (*mul)(void*,GEN,GEN))
+    GEN     gen_pow(GEN,GEN,void*,GEN (*sqr)(void*,GEN),GEN (*mul)(void*,GEN,GEN))
+    GEN     gen_pow_u(GEN x, ulong n, void *data, GEN (*sqr)(void*,GEN), GEN (*mul)(void*,GEN,GEN))
     long    logint(GEN B, GEN y, GEN *ptq)
     GEN     newtonpoly(GEN x, GEN p)
     GEN     nfgcd(GEN P, GEN Q, GEN nf, GEN den)
     GEN     nfisincl(GEN a, GEN b)
     GEN     nfisisom(GEN a, GEN b)
     GEN     nfrootsQ(GEN x)
-    GEN     poldeflate(GEN x0, long *m)
-    GEN     poldeflate_i(GEN x0, long d)
     GEN     poldisc0(GEN x, long v)
     GEN     polfnf(GEN a, GEN t)
     GEN     polhensellift(GEN pol, GEN fct, GEN p, long exp)
-    GEN     polinflate(GEN x0, long d)
     GEN     polresultant0(GEN x, GEN y,long v,long flag)
     GEN     polsym(GEN x, long n)
     GEN     primitive_part(GEN x, GEN *c)
     GEN     primpart(GEN x)
-    GEN     pseudorem(GEN x, GEN y)
     GEN     quadgen(GEN x)
     GEN     quadpoly(GEN x)
     GEN     quadpoly0(GEN x, long v)
     GEN     reduceddiscsmith(GEN pol)
     GEN     resultant2(GEN x, GEN y)
-    GEN     resultantducos(GEN x, GEN y)
     GEN     roots_from_deg1(GEN x)
     GEN     sort_factor(GEN y, int (*cmp)(GEN,GEN))
     GEN     sort_factor_gen(GEN y, int (*cmp)(GEN,GEN))
     GEN     sort_vecpol(GEN a, int (*cmp)(GEN,GEN))
     GEN     srgcd(GEN x, GEN y)
     long    sturmpart(GEN x, GEN a, GEN b)
-    GEN     subresall(GEN u, GEN v, GEN *sol)
     GEN     subresext(GEN x, GEN y, GEN *U, GEN *V)
     GEN     sylvestermatrix(GEN x,GEN y)
     GEN     vecbezout(GEN x, GEN y)
@@ -1639,7 +1314,6 @@
 
     # polarit3.c 
 
-    ulong   Fl_pow(ulong x, ulong n, ulong p)
     GEN     Fp_pows(GEN A, long k, GEN N)
     GEN     Fp_powu(GEN x, ulong k, GEN p)
     GEN     FpM_red(GEN z, GEN p)
@@ -1648,8 +1322,6 @@
     GEN     FpV_red(GEN z, GEN p)
     GEN     FpV_roots_to_pol(GEN V, GEN p, long v)
     GEN     FpV_to_mod(GEN z, GEN p)
-    GEN     FpX_FpXQ_compo(GEN f,GEN x,GEN T,GEN p)
-    GEN     FpX_FpXQV_compo(GEN f,GEN x,GEN T,GEN p)
     GEN     FpX_Fp_add(GEN y,GEN x,GEN p)
     GEN     FpX_Fp_mul(GEN y,GEN x,GEN p)
     GEN     FpX_add(GEN x,GEN y,GEN p)
@@ -1686,15 +1358,11 @@
     GEN     FpXQX_sqr(GEN x, GEN T, GEN p)
     GEN     FpXQX_extgcd(GEN x, GEN y, GEN T, GEN p, GEN *ptu, GEN *ptv)
     GEN     FpXQX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *pr)
-    GEN     FpXQX_safegcd(GEN P, GEN Q, GEN T, GEN p)
     GEN     FpXQXV_prod(GEN V, GEN Tp, GEN p)
-    GEN     FpXQYQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p)
-    GEN     FpXV_FpV_innerprod(GEN V, GEN W, GEN p)
     GEN     FpXV_prod(GEN V, GEN p)
     GEN     FpXV_red(GEN z, GEN p)
     GEN     FpXX_red(GEN z, GEN p)
     GEN     FpX_rescale(GEN P, GEN h, GEN p)
-    GEN     FpY_FpXY_resultant(GEN a, GEN b0, GEN p)
     GEN     Fq_inv(GEN x, GEN T, GEN p)
     GEN     Fq_invsafe(GEN x, GEN T, GEN p)
     GEN     Fq_add(GEN x, GEN y, GEN T, GEN p)
@@ -1707,7 +1375,6 @@
     GEN     FqM_to_FlxM(GEN x, GEN T, GEN pp)
     GEN     FqV_roots_to_pol(GEN V, GEN T, GEN p, long v)
     GEN     FqV_red(GEN z, GEN T, GEN p)
-    GEN     FqV_to_FlxC(GEN v, GEN T, GEN pp)
     GEN     FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p)
     GEN     FqX_div(GEN x, GEN y, GEN T, GEN p)
     GEN     FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z)
@@ -1717,24 +1384,13 @@
     GEN     FqX_mul(GEN x, GEN y, GEN T, GEN p)
     GEN     FqX_sqr(GEN x, GEN T, GEN p)
     GEN     QXQ_inv(GEN A, GEN B)
-    GEN     ZX_caract(GEN A, GEN B, long v)
     GEN     ZX_disc(GEN x)
     int     ZX_is_squarefree(GEN x)
     GEN     ZX_resultant(GEN A, GEN B)
-    GEN     ZX_QX_resultant(GEN A, GEN B)
-    GEN     ZX_s_add(GEN y,long x)
     long    brent_kung_optpow(long d, long n)
-    GEN     modulargcd(GEN a,GEN b)
-    GEN     rescale_pol(GEN P, GEN h)
-    GEN     unscale_pol(GEN P, GEN h)
-    GEN     stopoly(ulong m, ulong p, long v)
-    GEN     stopoly_gen(GEN m, GEN p, long v)
-    int     u_pow(int p, int k)
-    long    u_val(ulong n, ulong p)
 
     # RgX.c 
 
-    int     is_rational(GEN x)
     int     RgX_is_rational(GEN x)
     GEN     RgM_to_RgXV(GEN x, long v)
     GEN     RgM_to_RgXX(GEN x, long v,long w)
@@ -1746,13 +1402,11 @@
     GEN     RgX_divrem(GEN x,GEN y,GEN *r)
     GEN     RgX_mul(GEN x,GEN y)
     GEN     RgX_mulspec(GEN a, GEN b, long na, long nb)
-    GEN     RgX_powers(GEN a, GEN T, long l)
     GEN     RgXQX_divrem(GEN x,GEN y,GEN T,GEN *r)
     GEN     RgXQX_mul(GEN x,GEN y,GEN T)
     GEN     RgXQX_red(GEN P, GEN T)
     GEN     RgXQX_RgXQ_mul(GEN x, GEN y, GEN T)
     GEN     RgX_Rg_mul(GEN y, GEN x)
-    GEN     RgX_RgX_compo(GEN f, GEN x, GEN T)
     GEN     RgX_shift(GEN x, long n)
     GEN     RgX_sqr(GEN x)
     GEN     RgX_sqrspec(GEN a, long na)
@@ -1768,17 +1422,15 @@
     GEN     roots(GEN x,long l)
     GEN     roots0(GEN x,long flag,long l)
 
-    #subcyclo.c 
+    # subcyclo.c 
 
     GEN     galoissubcyclo(GEN N, GEN sg, long flag, long v)
     GEN     polsubcyclo(long n, long d, long v)
-    GEN     subcyclo(long n, long d, long v)
     GEN     znstar_small(GEN zn)
 
-    # subfields.c 
+    # subfield.c 
 
-    GEN     subfields(GEN nf,GEN d)
-    GEN     subfields0(GEN nf,GEN d)
+    GEN     nfsubfields(GEN nf, long d)
 
     # subgroup.c 
 
@@ -1810,10 +1462,6 @@
     GEN     intmellininv0(entree *ep, GEN sig, GEN x, char *ch, GEN tab, long prec)
     GEN     intmellininvshort(GEN sig, GEN x, GEN tab, long prec)
     GEN     intlaplaceinv0(entree *ep, GEN sig, GEN x, char *ch, GEN tab, long prec)
-    GEN     intnuminit(GEN a, GEN b, long m, long prec)
-    GEN     intnuminitgen0(entree *ep, GEN a, GEN b, char *ch, long m, long flag, long prec)
-    GEN     intfuncinit0(entree *ep, GEN a, GEN b, char *ch, long flag, long m, long prec)
-    # GEN     intnumdoub0(entree *epx, GEN a, GEN b, entree *epy, char *chc, char *chd, char *chf, GEN tabext, GEN tabint, long prec) 
     GEN     intfoursin0(entree *ep, GEN a, GEN b, GEN x, char *ch, GEN tab, long prec)
     GEN     intfourcos0(entree *ep, GEN a, GEN b, GEN x, char *ch, GEN tab, long prec)
     GEN     intfourexp0(entree *ep, GEN a, GEN b, GEN x, char *ch, GEN tab, long prec)
@@ -1821,10 +1469,8 @@
     GEN     sumnum0(entree *ep, GEN a, GEN sig, char *ch, GEN tab, long flag, long prec)
     GEN     sumnumalt(void *E, GEN (*f)(GEN,void*),GEN a,GEN s,GEN tab,long flag,long prec)
     GEN     sumnumalt0(entree *ep, GEN a, GEN sig, char *ch, GEN tab, long flag, long prec)
-    GEN     sumnuminit(GEN sig, long m, long sgn, long prec)
     GEN     matrice(GEN nlig, GEN ncol,entree *ep1, entree *ep2, char *ch)
     GEN     polzag(long n, long m)
-    GEN     polzagreel(long n, long m, long prec)
     GEN     prodeuler(void *E, GEN (*eval)(GEN,void*), GEN ga, GEN gb, long prec)
     GEN     prodeuler0(entree *ep, GEN a, GEN b, char *ch, long prec)
     GEN     prodinf(void *E, GEN (*eval)(GEN,void*), GEN a, long prec)
@@ -1871,7 +1517,6 @@
     GEN     gsqrt(GEN x, long prec)
     GEN     gsqrtn(GEN x, GEN n, GEN *zetan, long prec)
     GEN     gtan(GEN x, long prec)
-    GEN     log0(GEN x,long flag, long prec)
     GEN     mpcos(GEN x)
     GEN     mpeuler(long prec)
     GEN     mpexp(GEN x)
@@ -1883,7 +1528,6 @@
     void    mpsincos(GEN x, GEN *s, GEN *c)
     GEN     sqrtr(GEN x)
     GEN     sqrtnr(GEN x, long n)
-    GEN     palog(GEN x)
     GEN     powgi(GEN x, GEN n)
     GEN     teich(GEN x)
 
@@ -1917,14 +1561,10 @@
     GEN     eta0(GEN x, long flag,long prec)
     GEN     gerfc(GEN x, long prec)
     GEN     gpolylog(long m, GEN x, long prec)
-    void    gpolylogz(long m, GEN x, GEN y)
     GEN     gzeta(GEN x, long prec)
     GEN     hyperu(GEN a, GEN b, GEN gx, long prec)
     GEN     incgam(GEN a, GEN x, long prec)
     GEN     incgam0(GEN a, GEN x, GEN z,long prec)
-    GEN     incgam1(GEN a, GEN x, long prec)
-    GEN     incgam2(GEN a, GEN x, long prec)
-    GEN     incgam3(GEN a, GEN x, long prec)
     GEN     incgamc(GEN a, GEN x, long prec)
     GEN     hbessel1(GEN n, GEN z, long prec)
     GEN     hbessel2(GEN n, GEN z, long prec)
@@ -1934,13 +1574,8 @@
     GEN     nbessel(GEN n, GEN z, long prec)
     GEN     jell(GEN x, long prec)
     GEN     kbessel(GEN nu, GEN gx, long prec)
-    GEN     kbessel0(GEN nu, GEN gx, long flag,long prec)
-    GEN     kbessel2(GEN nu, GEN x, long prec)
     GEN     polylog(long m, GEN x, long prec)
     GEN     polylog0(long m, GEN x, long flag, long prec)
-    GEN     polylogd(long m, GEN x, long prec)
-    GEN     polylogdold(long m, GEN x, long prec)
-    GEN     polylogp(long m, GEN x, long prec)
     GEN     szeta(long x, long prec)
     GEN     theta(GEN q, GEN z, long prec)
     GEN     thetanullk(GEN q, long k, long prec)
@@ -1948,13 +1583,11 @@
     GEN     veceint1(GEN C, GEN nmax, long prec)
     GEN     vecthetanullk(GEN q, long k, long prec)
     GEN     weber0(GEN x, long flag,long prec)
-    GEN     wf(GEN x, long prec)
-    GEN     wf2(GEN x, long prec)
+    GEN     weberf(GEN x, long prec)
+    GEN     weberf2(GEN x, long prec)
 
-    GEN     padicfieldslist(GEN p, GEN m, GEN d, long flag)
 
 cdef extern from 'pari/paripriv.h':
-#cdef extern from 'pari/pari.h':
     struct __x:
         char format  # e,f,g 
         long fieldw  # 0 (ignored) or field width 
@@ -1974,6 +1607,3 @@
     long *   int_LSW(GEN x)
     long *   int_precW(long * xp)
     long *   int_nextW(long * xp)
-
-    
-
diff -r f77808909c54 -r 8a361e1b884e sage/libs/pari/gen.pyx
--- a/sage/libs/pari/gen.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/libs/pari/gen.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -4,9 +4,6 @@
 AUTHORS:
 
 - William Stein (2006-03-01): updated to work with PARI 2.2.12-beta
-  (this involved changing almost every doc string, among other things;
-  the precision behavior of PARI seems to change from any version to
-  the next...).
 
 - William Stein (2006-03-06): added newtonpoly
 
@@ -135,7 +132,7 @@
     sage: e = pari([0,0,0,-82,0]).ellinit(precision=150)
     sage: eta1 = e.elleta()[0]
     sage: R(eta1)
-    3.6054636014326520863839536934492002728802618
+    3.6054636014326520859158205642077267748102690
 
 Number fields and precision: TODO
 """
@@ -274,10 +271,8 @@
     if not prec_in_bits:
         return prec
     cdef int wordsize
-    if is_64_bit:
-        wordsize = 64
-    else:
-        wordsize = 32
+    wordsize = BITS_IN_LONG
+    
     # increase prec_in_bits to the nearest multiple of wordsize
     cdef int padded_bits
     padded_bits = (prec_in_bits + wordsize - 1) & ~(wordsize - 1)
@@ -301,13 +296,8 @@
         [(3, 32), (4, 64), (5, 96), (6, 128), (7, 160), (8, 192), (9, 224)]  # 32-bit
         [(3, 64), (4, 128), (5, 192), (6, 256), (7, 320), (8, 384), (9, 448)] # 64-bit
     """
-    cdef int wordsize
-    if is_64_bit:
-        wordsize = 64
-    else:
-        wordsize = 32
     # see user's guide to the pari library, page 10
-    return int((prec_in_words - 2)*wordsize)
+    return int((prec_in_words - 2) * BITS_IN_LONG)
 
 def prec_dec_to_words(int prec_in_dec):
     r"""
@@ -794,6 +784,8 @@
             raise IndexError, "index out of bounds"
         
         elif pari_type == t_VEC or pari_type == t_MAT:
+            #t_VEC    : row vector        [ code ] [  x_1  ] ... [  x_k  ]
+            #t_MAT    : matrix            [ code ] [ col_1 ] ... [ col_k ]
             if PyDict_Contains(self._refers_to, n):
                 return self._refers_to[n]
             else:
@@ -806,15 +798,23 @@
                 return val
 
         elif pari_type == t_VECSMALL:
+            #t_VECSMALL: vec. small ints  [ code ] [ x_1 ] ... [ x_k ]
             return self.g[n+1]
 
         elif pari_type == t_STR:
+            #t_STR    : string            [ code ] [ man_1 ] ... [ man_k ]
             return chr( (<char *>(self.g+1))[n] )
         
         elif pari_type == t_LIST:
-            return P.new_ref(gel(self.g,n+2), self)
+            #t_LIST   : list              [ code ] [ n ] [ nmax ][ vec ]
+            return self.component(n+1)
+            #code from previous version, now segfaults:
+            #return P.new_ref(gel(self.g,n+2), self)
 
         elif pari_type in (t_INTMOD, t_POLMOD):
+            #t_INTMOD : integermods       [ code ] [ mod  ] [ integer ]
+            #t_POLMOD : poly mod          [ code ] [ mod  ] [ polynomial ]
+
             # if we keep going we would get:
             #   [0] = modulus
             #   [1] = lift to t_INT or t_POL
@@ -1117,14 +1117,14 @@
         if not signe(x):
             return "0"
         lx = lgefint(x)-2  # number of words
-        size = lx*2*BYTES_IN_LONG
+        size = lx*2*sizeof(long)
         s = <char *>sage_malloc(size+2) # 1 char for sign, 1 char for '\0'
         sp = s + size+1
         sp[0] = 0
         xp = int_LSW(x)
         for i from 0 <= i < lx:
             w = xp[0]
-            for j from 0 <= j < 2*BYTES_IN_LONG:
+            for j from 0 <= j < 2*sizeof(long):
                 sp = sp-1
                 sp[0] = hexdigits[w & 15]
                 w = w>>4
@@ -1228,7 +1228,7 @@
             sage: pari('[2^150,1]').intvec_unsafe()
             Traceback (most recent call last):
             ...
-            PariError: impossible assignment I-->S (23)
+            PariError:  (15)
         """
         cdef int n, L
         cdef object v
@@ -1400,7 +1400,7 @@
             sage: complex(g)
             Traceback (most recent call last):
             ...
-            PariError: incorrect type (20)
+            PariError: incorrect type (11)
         """
         cdef double re, im
         _sig_on
@@ -1423,7 +1423,7 @@
             sage: a.__nonzero__()
             False
         """
-        return not gcmp0(self.g)
+        return not gequal0(self.g)
 
 
     ###########################################
@@ -1469,17 +1469,41 @@
 
     def qfbhclassno(gen n):
         r"""
-        Computes the Hurwitz-Kronecker class number of n.
-        
-        If n is large (more than `5*10^5`), the result is
-        conditional upon GRH.
-        
-        EXAMPLES::
-        
+        Computes the Hurwitz-Kronecker class number of `n`.
+
+        INPUT:
+
+        - `n` (gen) -- a non-negative integer
+        
+        .. note::
+
+           If `n` is large (more than `5*10^5`), the result is
+           conditional upon GRH.
+        
+        EXAMPLES:
+
+        The Hurwitx class number is 0 is n is congruent to 1 or 2 modulo 4::
             sage: pari(-10007).qfbhclassno()
-            77
-            sage: pari(-3).qfbhclassno()
+            0
+            sage: pari(-2).qfbhclassno()
+            0
+
+        It is -1/12 for n=0::
+
+            sage: pari(0).qfbhclassno()
+            -1/12
+
+        Otherwise it is the number of classes of positive definite
+        binary quadratic forms with discriminant `-n`, weighted by
+        `1/m` where `m` is the number of automorphisms of the form::
+        
+            sage: pari(4).qfbhclassno()
+            1/2
+            sage: pari(3).qfbhclassno()
             1/3
+            sage: pari(23).qfbhclassno()
+            3
+        
         """
         _sig_on
         return P.new_gen(hclassno(n.g))
@@ -1514,16 +1538,14 @@
             sage: pari(17).ispseudoprime()
             True
             sage: n = pari(561)     # smallest Carmichael number
-            sage: n.ispseudoprime() # not just any old pseudo-primality test!
-            False
             sage: n.ispseudoprime(2)
             False
         """
-        cdef GEN z
-        _sig_on
-        z = gispseudoprime(self.g, flag)
-        _sig_off
-        return bool(gcmp(z, stoi(0)))
+        cdef long z
+        _sig_on
+        z = ispseudoprime(self.g, flag)
+        _sig_off
+        return (z != 0)
 
     def ispower(gen self, k=None):
         r"""
@@ -1571,7 +1593,7 @@
         
         if k is None:
             _sig_on
-            n = isanypower(self.g, &x)
+            n = gisanypower(self.g, &x)
             if n == 0:
                 _sig_off
                 return 1, self
@@ -1645,7 +1667,7 @@
         moebius(x): Moebius function of x.
         """
         _sig_on
-        return P.new_gen(gmu(x.g))
+        return P.new_gen(gmoebius(x.g))
 
     def sign(gen x):
         """
@@ -1872,7 +1894,7 @@
         """
         t0GEN(y)
         _sig_on
-        return P.new_gen(gmodulcp(x.g,t0))
+        return P.new_gen(gmodulo(x.g,t0))
     
     def Pol(self, v=-1):
         """
@@ -1897,7 +1919,7 @@
                sage: pari('x+y').Pol('y')
                Traceback (most recent call last):
                ...
-               PariError:  (8)
+               PariError:  (5)
         
         INPUT:
         
@@ -2110,7 +2132,7 @@
             sage: pari('1/(x*y)').Set()
             ["1/(y*x)"]
             sage: pari('["bc","ab","bc"]').Set()
-            ["ab", "bc"]
+            ["\"ab\"", "\"bc\""]
         """
         _sig_on            
         return P.new_gen(gtoset(x.g))
@@ -2137,14 +2159,14 @@
         EXAMPLES::
         
             sage: pari([1,2,['abc',1]]).Str()
-            [1, 2, [abc, 1]]
+            "[1, 2, [abc, 1]]"
             sage: pari([1,1, 1.54]).Str()
-            [1, 1, 1.54000000000000]
+            "[1, 1, 1.54000000000000]"
             sage: pari(1).Str()       # 1 is automatically converted to string rep
-            1
+            "1"
             sage: x = pari('x')       # PARI variable "x"
             sage: x.Str()             # is converted to string rep.
-            x
+            "x"
             sage: x.Str().type()
             't_STR'
         """
@@ -2180,13 +2202,13 @@
         EXAMPLES::
         
             sage: pari([65,66,123]).Strchr()
-            AB{
+            "AB{"
             sage: pari('"Sage"').Vecsmall()   # pari('"Sage"') --> PARI t_STR
             Vecsmall([83, 97, 103, 101])
             sage: _.Strchr()
-            Sage
+            "Sage"
             sage: pari([83, 97, 103, 101]).Strchr()
-            Sage
+            "Sage"
         """
         _sig_on        
         return P.new_gen(Strchr(x.g))
@@ -2227,18 +2249,13 @@
         
             sage: v=pari('x^2')
             sage: v.Strtex()
-            x^2
+            "x^2"
             sage: v=pari(['1/x^2','x'])
             sage: v.Strtex()
-            \frac{1}{x^2}x
+            "\\frac{1}{x^2}x"
             sage: v=pari(['1 + 1/x + 1/(y+1)','x-1'])
             sage: v.Strtex()
-            \frac{ \left(y
-             + 2\right)  x
-             + \left(y
-             + 1\right) }{ \left(y
-             + 1\right)  x}x
-             - 1
+            "\\frac{ \\left(y\n + 2\\right)  x\n + \\left(y\n + 1\\right) }{ \\left(y\n + 1\\right)  x}x\n - 1"
         """
         if typ(x.g) != t_VEC:
             x = P.vector(1, [x])
@@ -2409,7 +2426,7 @@
             sage: pari('"2"').binary()
             Traceback (most recent call last):
             ...
-            TypeError: x (=2) must be of type t_INT, but is of type t_STR.
+            TypeError: x (="2") must be of type t_INT, but is of type t_STR.
         """
         if typ(x.g) != t_INT:
             raise TypeError, "x (=%s) must be of type t_INT, but is of type %s."%(x,x.type())
@@ -2727,35 +2744,6 @@
         return P.new_gen(centerlift0(x.g, P.get_var(v)))
 
     
-    def changevar(gen x, y):
-        """
-        changevar(gen x, y): change variables of x according to the vector
-        y.
-        
-        .. warning::
-
-           This doesn't seem to work right at all in Sage (!). Use
-           with caution. *STRANGE*
-        
-        INPUT:
-        
-        
-        -  ``x`` - gen
-        
-        -  ``y`` - gen (or coercible to gen)
-        
-        
-        OUTPUT: gen
-        
-        EXAMPLES::
-        
-            sage: pari('x^3+1').changevar(pari(['y']))
-            y^3 + 1
-        """
-        t0GEN(y)
-        _sig_on
-        return P.new_gen(changevar(x.g, t0))
-    
     def component(gen x, long n):
         """
         component(x, long n): Return n'th component of the internal
@@ -2797,7 +2785,7 @@
             sage: pari('x').component(0)
             Traceback (most recent call last):
             ...
-            PariError:  (8)
+            PariError:  (5)
         """
         _sig_on
         return P.new_gen(compo(x.g, n))
@@ -2829,7 +2817,7 @@
             sage: pari('Mod(x,x^3-3)').conj()
             Traceback (most recent call last):
             ...
-            PariError: incorrect type (20)
+            PariError: incorrect type (11)
         """
         _sig_on
         return P.new_gen(gconj(x.g))
@@ -2926,7 +2914,7 @@
             sage: pari('"hello world"').floor()
             Traceback (most recent call last):
             ...
-            PariError: incorrect type (20)
+            PariError: incorrect type (11)
         """
         _sig_on
         return P.new_gen(gfloor(x.g))
@@ -2952,7 +2940,7 @@
             sage: pari('sqrt(-2)').frac()
             Traceback (most recent call last):
             ...
-            PariError: incorrect type (20)
+            PariError: incorrect type (11)
         """
         _sig_on
         return P.new_gen(gfrac(x.g))
@@ -3283,7 +3271,7 @@
             Mat([3, 2])
             sage: x = pari('1.5 + 0*I')
             sage: x.type()
-            't_COMPLEX'
+            't_REAL'
             sage: x.simplify()
             1.50000000000000
             sage: y = x.simplify()
@@ -3293,45 +3281,60 @@
         _sig_on
         return P.new_gen(simplify(x.g))
     
+    def sizeword(gen x):
+        """
+        Return the total number of machine words occupied by the
+        complete tree of the object x.  A machine word is 32 or
+        64 bits, depending on the computer.
+        
+        INPUT:
+        
+        -  ``x`` - gen
+        
+        OUTPUT: int (a Python int)
+        
+        EXAMPLES::
+        
+            sage: pari('0').sizeword()
+            2
+            sage: pari('1').sizeword()
+            3
+            sage: pari('1000000').sizeword()
+            3
+            sage: pari('10^100').sizeword()
+            13      # 32-bit
+            8       # 64-bit
+            sage: pari(RDF(1.0)).sizeword()
+            4       # 32-bit
+            3       # 64-bit
+            sage: pari('x').sizeword()
+            9
+            sage: pari('x^20').sizeword()
+            66
+            sage: pari('[x, I]').sizeword()
+            20
+        """
+        return gsizeword(x.g)
+    
     def sizebyte(gen x):
         """
-        sizebyte(x): Return the total number of bytes occupied by the
-        complete tree of the object x. Note that this number depends on
-        whether the computer is 32-bit or 64-bit (see examples).
-        
-        INPUT:
-        
-        
-        -  ``x`` - gen
-        
+        Return the total number of bytes occupied by the complete tree
+        of the object x. Note that this number depends on whether the
+        computer is 32-bit or 64-bit.
+        
+        INPUT:
+        
+        -  ``x`` - gen
         
         OUTPUT: int (a Python int)
         
-        EXAMPLES::
+        EXAMPLE::
         
             sage: pari('1').sizebyte()
             12           # 32-bit
             24           # 64-bit
-            sage: pari('10').sizebyte()
-            12           # 32-bit
-            24           # 64-bit
-            sage: pari('10000000000000').sizebyte()
-            16           # 32-bit
-            24           # 64-bit
-            sage: pari('10^100').sizebyte()
-            52           # 32-bit
-            64           # 64-bit
-            sage: pari('x').sizebyte()
-            36           # 32-bit
-            72           # 64-bit
-            sage: pari('x^20').sizebyte()
-            264          # 32-bit
-            528          # 64-bit
-            sage: pari('[x, 10^100]').sizebyte()
-            100          # 32-bit
-            160          # 64-bit
-        """
-        return taille2(x.g)
+        """
+        return gsizebyte(x.g)
     
     def sizedigit(gen x):
         """
@@ -3994,7 +3997,7 @@
         """
         t0GEN(x)
         _sig_on
-        return P.new_gen(kbessel0(nu.g, t0, flag, pbw(precision)))
+        return P.new_gen(kbessel(nu.g, t0, pbw(precision)))
 
     def besseln(gen nu, x, precision=0):
         """
@@ -4186,7 +4189,7 @@
         
             sage: C.<i> = ComplexField()
             sage: pari(i).eta()
-            0.998129069925959 + 0.E-21*I
+            0.998129069925959
         """
         _sig_on
         if flag == 1:
@@ -4238,7 +4241,7 @@
             sage: pari(-1).gamma()
             Traceback (most recent call last):
             ...
-            PariError:  (8)
+            PariError:  (5)
         """
         _sig_on
         return P.new_gen(ggamma(s.g, pbw(precision)))
@@ -4600,10 +4603,10 @@
             2.00000000000000
             sage: z^5
             1.00000000000000 + 5.42101086 E-19*I        # 32-bit
-            1.00000000000000 + 4.87890977618477 E-19*I  # 64-bit
+            1.00000000000000 + 5.96311194867027 E-19*I  # 64-bit
             sage: (s*z)^5
             2.00000000000000 + 1.409462824 E-18*I       # 32-bit
-            2.00000000000000 + 7.58941520739853 E-19*I  # 64-bit
+            2.00000000000000 + 9.21571846612679 E-19*I  # 64-bit
         """
         # TODO: ???  lots of good examples in the PARI docs ???
         cdef GEN zetan
@@ -4646,8 +4649,13 @@
             sage: pari(1).tanh()
             0.761594155955765
             sage: C.<i> = ComplexField()
-            sage: pari(i).tanh()
-            0.E-19 + 1.55740772465490*I
+            sage: z = pari(i); z
+            0.E-19 + 1.00000000000000*I
+            sage: result = z.tanh()
+            sage: result.real() <= 1e-18
+            True
+            sage: result.imag()
+            1.55740772465490
         """
         _sig_on
         return P.new_gen(gth(x.g, pbw(precision)))
@@ -4724,11 +4732,12 @@
         
             sage: C.<i> = ComplexField()
             sage: pari(i).weber()
-            1.18920711500272 + 0.E-19*I
+            1.18920711500272 + 0.E-19*I                 # 32-bit
+            1.18920711500272 + 2.71050543121376 E-20*I  # 64-bit
             sage: pari(i).weber(1)    
             1.09050773266526 + 0.E-19*I
             sage: pari(i).weber(2)
-            1.09050773266526 + 0.E-19*I
+            1.09050773266526
         """
         _sig_on
         return P.new_gen(weber0(x.g, flag, pbw(precision)))
@@ -4820,7 +4829,7 @@
             1/3*x + O(x^2)
         """
         _sig_on
-        return P.new_gen(binome(x.g, k))
+        return P.new_gen(binomial(x.g, k))
 
     def contfrac(gen x, b=0, long lmax=0):
         """
@@ -4866,7 +4875,7 @@
         """
         t0GEN(y)
         _sig_on
-        return P.new_gen(gcd0(x.g, t0, flag))
+        return P.new_gen(ggcd0(x.g, t0))
 
     def issquare(gen x, find_root=False):
         """
@@ -4878,7 +4887,7 @@
         cdef gen g
         _sig_on
         if find_root:
-            t = gcarrecomplet(x.g, &G)
+            t = gissquareall(x.g, &G)
             v = bool(P.new_gen_noclear(t))
             if v:
                 return v, P.new_gen(G)
@@ -4886,7 +4895,7 @@
                 _sig_off
                 return v, None
         else:
-            return P.new_gen(gcarreparfait(x.g))
+            return P.new_gen(gissquare(x.g))
 
 
     def issquarefree(gen self):
@@ -4934,7 +4943,7 @@
             4
         """
         _sig_on
-        return P.new_gen(phi(n.g))
+        return P.new_gen(geulerphi(n.g))
 
     def primepi(gen self):
         """
@@ -5043,8 +5052,8 @@
         EXAMPLES: An elliptic curve with integer coefficients::
         
             sage: e = pari([0,1,0,1,0]).ellinit(); e
-            [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-28, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, 1.68575035481260 + 2.15651564749964*I, -0.687257278928726 + 7.57138254 E-30*I, -0.343628639464363 - 1.37139930484298*I, 7.27069403586288] # 32-bit
-            [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-38, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, 1.68575035481260 + 2.15651564749964*I, -0.687257278928726 + 1.76284987179941 E-39*I, -0.343628639464363 - 1.37139930484298*I, 7.27069403586288] # 64-bit
+            [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-28, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, -1.68575035481260 - 2.15651564749964*I, 1.37451455785745 - 1.084202173 E-19*I,      -0.687257278928726 + 0.984434956803824*I, 7.27069403586288] # 32-bit
+            [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-38, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, -1.68575035481260 - 2.15651564749964*I, 1.37451455785745 - 5.42101086242752 E-19*I, -0.687257278928726 + 0.984434956803824*I, 7.27069403586288] # 64-bit
         
         Its inexact components have the default precision of 53 bits::
         
@@ -5110,7 +5119,7 @@
             [17, [1, 0, 0, 0], 4]
         """
         _sig_on        
-        return self.new_gen(globalreduction(self.g))
+        return self.new_gen(ellglobalred(self.g))
 
     def elladd(self, z0, z1):
         """
@@ -5227,22 +5236,34 @@
         else:
             return self.new_gen(anell(self.g, n))
 
+    def ellanalyticrank(self, long precision = 0):
+        r"""
+        Returns a 2-component vector with the order of vanishing at
+        `s = 1` of the L-function of the elliptic curve and the value
+        of the first non-zero derivative.
+        
+        EXAMPLE::
+            
+            sage: E = EllipticCurve('389a1')
+            sage: pari(E).ellanalyticrank()
+            [2, 1.51863300057685]
+        """
+        _sig_on
+        return self.new_gen(ellanalyticrank(self.g, <GEN>0, pbw(precision)))
+
     def ellap(self, p):
         r"""
-        e.ellap(p): Returns the prime-indexed coefficient `a_p` of
-        the `L`-function of the elliptic curve `e`, i.e.
-        the `p`-th Fourier coefficient of the newform attached to
-        e.
-        
-        The computation uses the baby-step giant-step method and a trick
-        due to Mestre, and requires `O(p^{1/4})` time and
-        `O(p^{1/4})` storage.
-        
-            If p is not prime, this function will return an incorrect answer.
-        
-            The curve e must be a medium or long vector of the type given by
-            ellinit. For this function to work for every n and not just those
-            prime to the conductor, e must be a minimal Weierstrass equation.
+        e.ellap(p): Returns the prime-indexed coefficient `a_p` of the
+        `L`-function of the elliptic curve `e`, i.e. the `p`-th Fourier
+        coefficient of the newform attached to e.
+        
+        The computation uses the Shanks--Mestre method, or the SEA
+        algorithm.
+        
+        .. WARNING::
+            
+            For this function to work for every n and not just those prime
+            to the conductor, e must be a minimal Weierstrass equation.
             If this is not the case, use the function ellminimalmodel first
             before using ellap (or you will get INCORRECT RESULTS!)
         
@@ -5267,7 +5288,7 @@
         """
         t0GEN(p)
         _sig_on
-        return self.new_gen(apell(self.g, t0))
+        return self.new_gen(ellap(self.g, t0))
 
 
     def ellaplist(self, long n, python_ints=False):
@@ -5329,17 +5350,17 @@
         _sig_on
         g = primes(gtolong(primepi(t0)))
 
-        # 2. Replace each prime in the table by apell of it.
+        # 2. Replace each prime in the table by ellap of it.
         cdef long i
 
         if python_ints:
-            v = [gtolong(apell(self.g, <GEN> g[i+1])) \
+            v = [gtolong(ellap(self.g, <GEN> g[i+1])) \
                         for i in range(glength(g))]
             (<PariInstance>pari).clear_stack()
             return v
         else:
             for i from 0 <= i < glength(g):
-                g[i+1] = <long> apell(self.g, <GEN> g[i+1])
+                g[i+1] = <long> ellap(self.g, <GEN> g[i+1])
             return self.new_gen(g)
 
 
@@ -5397,7 +5418,7 @@
         """
         t0GEN(ch)
         _sig_on
-        return self.new_gen(coordch(self.g, t0))
+        return self.new_gen(ellchangecurve(self.g, t0))
 
     def elleta(self):
         """
@@ -5409,7 +5430,13 @@
         
             sage: e = pari([0,0,0,-82,0]).ellinit()
             sage: e.elleta()
-            [3.60546360143265, 10.8163908042980*I]
+            [3.60546360143265, 3.60546360143265*I]
+            sage: w1,w2 = e.omega()
+            sage: eta1, eta2 = e.elleta()
+            sage: w1*eta2-w2*eta1
+            6.28318530717959*I
+            sage: w1*eta2-w2*eta1 == pari(2*pi*I)
+            True
         """
         _sig_on
         # the prec argument has no effect
@@ -5715,7 +5742,7 @@
         t0GEN(s); t1GEN(A)
         _sig_on
         # the argument prec has no effect
-        return self.new_gen(lseriesell(self.g, t0, t1, prec))
+        return self.new_gen(elllseries(self.g, t0, t1, prec))
 
     def ellminimalmodel(self):
         """
@@ -5816,7 +5843,7 @@
         t0GEN(x)
         _sig_on
         # the prec argument has no effect
-        return self.new_gen(ordell(self.g, t0, prec))
+        return self.new_gen(ellordinate(self.g, t0, prec))
 
     def ellpointtoz(self, P, long precision=0):
         """
@@ -6031,7 +6058,7 @@
             sage: e = pari([0,0,0,1,0]).ellinit()
             sage: e.ellzeta(1)
             1.06479841295883 + 0.E-19*I                # 32-bit
-            1.06479841295883 - 5.42101086242752 E-20*I # 64-bit
+            1.06479841295883 + 5.42101086242752 E-20*I # 64-bit
             sage: C.<i> = ComplexField()
             sage: e.ellzeta(i-1)
             -0.350122658523049 - 0.350122658523049*I
@@ -6063,7 +6090,7 @@
             sage: C.<i> = ComplexField()
             sage: e.ellztopoint(1+i)
             [0.E-19 - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] # 32-bit
-            [8.67655312026478 E-20 - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] # 64-bit
+            [...  - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] # 64-bit
         
         Complex numbers belonging to the period lattice of e are of course
         sent to the point at infinity on e::
@@ -6089,7 +6116,7 @@
         
             sage: e = pari([0, -1, 1, -10, -20]).ellinit()
             sage: e.omega()
-            [1.26920930427955, 0.634604652139777 + 1.45881661693850*I]
+            [1.26920930427955, -0.634604652139777 - 1.45881661693850*I]
         """
         return self[14:16]
 
@@ -6121,16 +6148,17 @@
         """
         return self[12]
 
-    
-    
-
     def ellj(self):
-        _sig_on
-        return P.new_gen(jell(self.g, prec))
-
-
-    ###########################################
-    # 6: Functions related to general NUMBER FIELDS
+        try:
+            dprec = prec_words_to_dec(self.precision())
+        except AttributeError:
+            dprec = prec
+        _sig_on
+        return P.new_gen(jell(self.g, dprec))
+
+
+    ###########################################
+    # 6: Functions related to NUMBER FIELDS 
     ###########################################
     def bnfcertify(self):
         r"""
@@ -6154,7 +6182,7 @@
         """
         cdef long n
         _sig_on
-        n = certifybuchall(self.g)
+        n = bnfcertify(self.g)
         _sig_off
         return n
     
@@ -6175,7 +6203,7 @@
     def bnfisprincipal(self, x, long flag=1):
         t0GEN(x)
         _sig_on
-        return self.new_gen(isprincipalall(self.g, t0, flag))
+        return self.new_gen(bnfisprincipal0(self.g, t0, flag))
 
     def bnfnarrow(self):
         _sig_on
@@ -6183,12 +6211,12 @@
 
     def bnfunit(self):
         _sig_on
-        return self.new_gen(buchfu(self.g))
+        return self.new_gen(bnf_get_fu(self.g))        
 
     def bnfisunit(self, x):
         t0GEN(x)
         _sig_on
-        return self.new_gen(isunit(self.g, t0))
+        return self.new_gen(bnfisunit(self.g, t0))
 
     def dirzetak(self, n):
         t0GEN(n)
@@ -6227,7 +6255,7 @@
     def idealred(self, I, vdir=0):
         t0GEN(I); t1GEN(vdir)
         _sig_on
-        return self.new_gen(ideallllred(self.g, t0, t1, prec))
+        return self.new_gen(idealred0(self.g, t0, t1 if vdir else NULL))
 
     def idealadd(self, x, y):
         t0GEN(x); t1GEN(y)
@@ -6282,7 +6310,7 @@
         t0GEN(a)
         _sig_on
         if b is None:
-            return self.new_gen(idealhermite(self.g, t0))
+            return self.new_gen(idealhnf(self.g, t0))
         else:
             t1GEN(b)
             return self.new_gen(idealhnf0(self.g, t0, t1))
@@ -6322,7 +6350,7 @@
         """
         t0GEN(x); t1GEN(bid)
         _sig_on
-        return self.new_gen(zideallog(self.g, t0, t1))
+        return self.new_gen(ideallog(self.g, t0, t1))
 
     def idealmul(self, x, y, long flag=0):
         t0GEN(x); t1GEN(y)
@@ -6330,7 +6358,7 @@
         if flag == 0:
             return self.new_gen(idealmul(self.g, t0, t1))
         else:
-            return self.new_gen(idealmulred(self.g, t0, t1, prec))
+            return self.new_gen(idealmulred(self.g, t0, t1))
 
     def idealnorm(self, x):
         t0GEN(x)
@@ -6371,7 +6399,7 @@
             sage: nf = F._pari_()
             sage: I = pari('[1, -1, 2]~')
             sage: nf.idealstar(I)
-            [[[43, 9, 5; 0, 1, 0; 0, 0, 1], [0]], [42, [42]], Mat([[43, [9, 1, 0]~, 1, 1, [-5, -9, 1]~], 1]), [[[[42], [[3, 0, 0]~], [[3, 0, 0]~], [[]~], 1]], [[], [], [;]]], Mat(1)]
+            [[[43, 9, 5; 0, 1, 0; 0, 0, 1], [0]], [42, [42]], Mat([[43, [9, 1, 0]~, 1, 1, [-5, -9, 1]~], 1]), [[[[42], [[3, 0, 0]~], [[3, 0, 0]~], [Vecsmall([])], 1]], [[], [], []]], Mat(1)]
         """
         t0GEN(I)
         _sig_on
@@ -6381,11 +6409,11 @@
         t0GEN(x)
         if a is None:
             _sig_on
-            return self.new_gen(ideal_two_elt0(self.g, t0, NULL))
+            return self.new_gen(idealtwoelt0(self.g, t0, NULL))
         else:
             t1GEN(a)
             _sig_on
-            return self.new_gen(ideal_two_elt0(self.g, t0, t1))
+            return self.new_gen(idealtwoelt0(self.g, t0, t1))
 
     def idealval(self, x, p):
         t0GEN(x); t1GEN(p)
@@ -6395,7 +6423,7 @@
     def elementval(self, x, p):
         t0GEN(x); t1GEN(p)
         _sig_on
-        return element_val(self.g, t0, t1)
+        return nfval(self.g, t0, t1)
 
     def modreverse(self):
         """
@@ -6404,7 +6432,7 @@
         EXAMPLES:
         """
         _sig_on
-        return self.new_gen(polymodrecip(self.g))
+        return self.new_gen(modreverse(self.g))
 
     def nfbasis(self, long flag=0, p=0):
         cdef gen _p
@@ -6485,7 +6513,7 @@
         else:
             g = <GEN>NULL
         _sig_on
-        return self.new_gen(nfdiscf0(self.g, flag, g))
+        return self.new_gen(nfdisc0(self.g, flag, g))
 
     def nfeltreduce(self, x, I):
         """
@@ -6505,17 +6533,13 @@
         """
         t0GEN(x); t1GEN(I)
         _sig_on
-        return self.new_gen(element_reduce(self.g, t0, t1))
+        return self.new_gen(nfreduce(self.g, t0, t1))
 
     def nffactor(self, x):
         t0GEN(x)
         _sig_on
         return self.new_gen(nffactor(self.g, t0))
 
-    def galoisconj(self):
-        _sig_on
-        return self.new_gen(galoisconj(self.g))
-
     def nfgenerator(self):
         f = self[0]
         x = f.variable()
@@ -6576,12 +6600,12 @@
         
             sage: nf = pari('x^2 + 1').nfinit()
             sage: nf.nfrootsof1()
-            [4, [0, 1]~]
+            [4, -x]
         """
         _sig_on
         return P.new_gen(rootsof1(self.g))
 
-    def nfsubfields(self, d=0):
+    def nfsubfields(self, long d=0):
         """
         Find all subfields of degree d of number field nf (all subfields if
         d is null or omitted). Result is a vector of subfields, each being
@@ -6594,14 +6618,10 @@
         
         -  ``self`` - nf number field
         
-        -  ``d`` - integer
-        """
-        if d == 0:
-            _sig_on
-            return self.new_gen(subfields0(self.g, <GEN>0))
-        t0GEN(d)
-        _sig_on
-        return self.new_gen(subfields0(self.g, t0))
+        -  ``d`` - C long integer
+        """
+        _sig_on
+        return self.new_gen(nfsubfields(self.g, d))
 
     def rnfcharpoly(self, T, a, v='x'):
         t0GEN(T); t1GEN(a); t2GEN(v)
@@ -6693,15 +6713,36 @@
         """
         t0GEN(poly)
         _sig_on
-        return P.new_gen(rnfinitalg(self.g, t0, prec))
+        return P.new_gen(rnfinit(self.g, t0))
 
     def rnfisfree(self, poly):
         t0GEN(poly)
         _sig_on
-        return rnfisfree(self.g, t0)
-
-
-    
+        r = rnfisfree(self.g, t0)
+        _sig_off
+        return r
+
+    def quadhilbert(self):
+        r"""
+        Returns a polynomial over `\QQ` whose roots generate the
+        Hilbert class field of the quadratic field of discriminant
+        ``self`` (which must be fundamental).
+        
+        EXAMPLES::
+            
+            sage: pari(-23).quadhilbert()
+            x^3 - x^2 + 1
+            sage: pari(145).quadhilbert()
+            x^4 - x^3 - 3*x^2 + x + 1
+            sage: pari(-12).quadhilbert()   # Not fundamental
+            Traceback (most recent call last):
+            ...
+            PariError:  (5)
+        """
+        _sig_on
+        # Precision argument is only used for real quadratic extensions
+        # and will be automatically increased by PARI if needed.
+        return P.new_gen(quadhilbert(self.g, DEFAULTPREC))
 
 
     ##################################################
@@ -6828,9 +6869,9 @@
         f.polgalois(): Galois group of the polynomial f
         """
         _sig_on
-        return self.new_gen(galois(self.g, prec))
-
-    def nfgaloisconj(self):
+        return self.new_gen(polgalois(self.g, prec))
+
+    def nfgaloisconj(self, long flag=0, denom=None, long prec=0):
         r"""
         Edited from the pari documentation:
 
@@ -6851,8 +6892,13 @@
             sage: nf.nfgaloisconj()
             [-x, x]~
         """
-        _sig_on
-        return self.new_gen(galoisconj(self.g))
+        global t0
+        if denom is not None:
+            t0GEN(denom)
+        else:
+            t0 = NULL
+        _sig_on
+        return self.new_gen(galoisconj0(self.g, flag, t0, pbw(prec)))
 
     def nfroots(self, poly):
         r"""
@@ -7034,7 +7080,7 @@
         t0GEN(y)
         if z is None:
             _sig_on
-            return P.new_gen(extract(self.g, t0))
+            return P.new_gen(shallowextract(self.g, t0))
         else:
             t1GEN(z)
             _sig_on
@@ -7101,7 +7147,7 @@
         _sig_on        
         return self.new_gen(adj(self.g)).Mat()
 
-    def qflll(self, long flag=0, precision=0):
+    def qflll(self, long flag=0):
         """
         qflll(x,flag=0): LLL reduction of the vectors forming the matrix x
         (gives the unimodular transformation matrix). The columns of x must
@@ -7114,9 +7160,9 @@
         polynomial coefficients.
         """
         _sig_on
-        return self.new_gen(qflll0(self.g,flag,pbw(precision))).Mat()
+        return self.new_gen(qflll0(self.g,flag)).Mat()
               
-    def qflllgram(self, long flag=0, precision=0):
+    def qflllgram(self, long flag=0):
         """
         qflllgram(x,flag=0): LLL reduction of the lattice whose gram matrix
         is x (gives the unimodular transformation matrix). flag is optional
@@ -7127,7 +7173,7 @@
         polynomials.
         """
         _sig_on
-        return self.new_gen(qflllgram0(self.g,flag,pbw(precision))).Mat()
+        return self.new_gen(qflllgram0(self.g,flag)).Mat()
 
     def lllgram(self):
         return self.qflllgram(0)
@@ -7212,7 +7258,7 @@
             sage: pari('matrix(3,3,i,j,i)').matker()
             [-1, -1; 1, 0; 0, 1]            
             sage: pari('[1,2,3;4,5,6;7,8,9]*Mod(1,2)').matker()
-            [Mod(1, 2); Mod(0, 2); 1]
+            [Mod(1, 2); Mod(0, 2); Mod(1, 2)]
         """
         _sig_on        
         return self.new_gen(matker0(self.g, flag))
@@ -7236,14 +7282,11 @@
             sage: pari('[2,1;2,1]').matker()
             [-1/2; 1]
             sage: pari('[2,1;2,1]').matkerint()
-            [-1; 2]
-        
-        This is worrisome (so be careful!)::
-        
+            [1; -2]        
             sage: pari('[2,1;2,1]').matkerint(1)
-            Mat(1)
-        """
-        _sig_on        
+            [1; -2]
+        """
+        _sig_on
         return self.new_gen(matkerint0(self.g, flag))
 
     def matdet(self, long flag=0):
@@ -7430,11 +7473,6 @@
 
 
     ###########################################
-    # 9: SUMS, products, integrals and similar functions
-    ###########################################
-
-
-    ###########################################
     # polarit2.c 
     ###########################################
     def factor(gen self, limit=-1, bint proof=1):
@@ -7478,7 +7516,7 @@
             sage: pari('x^3 - y^3').factor()
             Traceback (most recent call last):
             ...
-            PariError: sorry, (15)
+            PariError:  (7)
         """
         cdef int r
         if limit == -1 and typ(self.g) == t_INT and proof:
@@ -7501,7 +7539,7 @@
         t0GEN(y)
         t1GEN(p)
         _sig_on
-        return hil0(x.g, t0, t1)
+        return hilbert0(x.g, t0, t1)
         
     def chinese(self, y):
         t0GEN(y)
@@ -7540,7 +7578,7 @@
             Mod(236736367459211723407, 473472734918423446802)
         """
         _sig_on        
-        return P.new_gen(ggener(self.g))
+        return P.new_gen(znprimroot0(self.g))
         
     def __abs__(self):
         return self.abs()
@@ -7662,6 +7700,7 @@
         elif t == t_REAL:     return 't_REAL'
         elif t == t_INTMOD:   return 't_INTMOD'
         elif t == t_FRAC:     return 't_FRAC'
+        elif t == t_FFELT:    return 't_FFELT'
         elif t == t_COMPLEX:  return 't_COMPLEX'
         elif t == t_PADIC:    return 't_PADIC'
         elif t == t_QUAD:     return 't_QUAD'
@@ -7677,6 +7716,7 @@
         elif t == t_LIST:     return 't_LIST'
         elif t == t_STR:      return 't_STR'
         elif t == t_VECSMALL: return 't_VECSMALL'
+        elif t == t_CLOSURE:  return 't_CLOSURE'
         else:
             raise TypeError, "Unknown Pari type: %s"%t
 
@@ -7696,26 +7736,23 @@
         dif = self.new_gen_noclear(dy)
         return self.new_gen(g), dif
 
-    def algdep(self, long n, bit=0):
-        """
-        EXAMPLES::
-        
-            sage: n = pari.set_real_precision (200)
+    def algdep(self, long n):
+        """
+        EXAMPLES::
+        
+            sage: n = pari.set_real_precision(210)
             sage: w1 = pari('z1=2-sqrt(26); (z1+I)/(z1-I)')
             sage: f = w1.algdep(12); f
             545*x^11 - 297*x^10 - 281*x^9 + 48*x^8 - 168*x^7 + 690*x^6 - 168*x^5 + 48*x^4 - 281*x^3 - 297*x^2 + 545*x
-            sage: f(w1)
-            7.75513996 E-200 + 5.70672991 E-200*I     # 32-bit
-            3.780069700150794274 E-209 - 9.362977321012524836 E-211*I   # 64-bit
+            sage: f(w1).abs() < 1.0e-200
+            True
             sage: f.factor()
             [x, 1; x + 1, 2; x^2 + 1, 1; x^2 + x + 1, 1; 545*x^4 - 1932*x^3 + 2790*x^2 - 1932*x + 545, 1]
             sage: pari.set_real_precision(n)
-            200
-        """
-        cdef long b
-        b = bit
-        _sig_on
-        return self.new_gen(algdep0(self.g, n, b, prec))
+            210
+        """
+        _sig_on
+        return self.new_gen(algdep(self.g, n))
 
     def concat(self, y):
         t0GEN(y)
@@ -7724,7 +7761,7 @@
 
     def lindep(self, flag=0):
         _sig_on
-        return self.new_gen(lindep0(self.g, flag, prec))
+        return self.new_gen(lindep0(self.g, flag))
 
     def listinsert(self, obj, long n):
         t0GEN(obj)
@@ -7768,9 +7805,9 @@
             sage: e = pari([0,1,1,-2,0]).ellinit()
             sage: om = e.omega()
             sage: om
-            [2.49021256085506, 1.97173770155165*I]
-            sage: om.elleisnum(2)
-            -5.28864933965426
+            [2.49021256085506, -1.97173770155165*I]
+            sage: om.elleisnum(2) # was:  -5.28864933965426
+            10.0672605281120 
             sage: om.elleisnum(4)
             112.000000000000
             sage: om.elleisnum(100)
@@ -7905,7 +7942,28 @@
         """
         t0GEN(y)
         _sig_on
-        return self.new_gen(pointch(self.g, t0))
+        return self.new_gen(ellchangepoint(self.g, t0))
+
+    def debug(gen self, long depth = -1):
+        r"""
+        Show the internal structure of self (like \x in gp).
+
+        EXAMPLE::
+
+            sage: pari('[1/2, 1.0*I]').debug()  # random addresses
+            [&=0000000004c5f010] VEC(lg=3):2200000000000003 0000000004c5eff8 0000000004c5efb0
+              1st component = [&=0000000004c5eff8] FRAC(lg=3):0800000000000003 0000000004c5efe0 0000000004c5efc8
+                num = [&=0000000004c5efe0] INT(lg=3):0200000000000003 (+,lgefint=3):4000000000000003 0000000000000001
+                den = [&=0000000004c5efc8] INT(lg=3):0200000000000003 (+,lgefint=3):4000000000000003 0000000000000002
+              2nd component = [&=0000000004c5efb0] COMPLEX(lg=3):0c00000000000003 00007fae8a2eb840 0000000004c5ef90
+                real = gen_0
+                imag = [&=0000000004c5ef90] REAL(lg=4):0400000000000004 (+,expo=0):6000000000000000 8000000000000000 0000000000000000
+        """
+        _sig_on
+        dbgGEN(self.g, depth)
+        _sig_off
+        return
+
 
     ##################################################
     # Technical functions that can be used by other
@@ -8072,7 +8130,7 @@
         s = str(x)
         cdef GEN g
         _sig_on
-        g = flisseq(s)
+        g = gp_read_str(s)
         _sig_off
         return g
         
@@ -8133,7 +8191,6 @@
         """
         cdef gen g
         g = _new_gen(x)
-        
         global mytop, avma
         avma = mytop
         _sig_off
@@ -8141,7 +8198,7 @@
 
     cdef void clear_stack(self):
         """
-        Clear the entire PARI stack and turn off call _sig_off.
+        Clear the entire PARI stack and call _sig_off.
         """
         global mytop, avma
         avma = mytop
@@ -8394,13 +8451,13 @@
         
             sage: K.<a>=NumberField(x^3-2)
             sage: pari(K)
-            [x^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 - 1.09112363597172*I, -0.793700525984100 + 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, -1.72108416091916, 0.581029111014503; 1, 0.461163111024285, -2.16843016298270], 0, [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]]], [1.25992104989487, -0.629960524947437 - 1.09112363597172*I], [1, x, x^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
+            [x^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 - 1.09112363597172*I, -0.793700525984100 + 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, -1.72108416091916, 0.581029111014503; 1, 0.461163111024285, -2.16843016298270], [1, 1, 2; 1, -2, 1; 1, 0, -2], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]]], [1.25992104989487, -0.629960524947437 - 1.09112363597172*I], [1, x, x^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
         
         ::
         
             sage: E = EllipticCurve('37a1')
             sage: pari(E)
-            [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 2.99345864623196, 2.45138938198679*I, -0.471319277956811, -1.43545651866868*I, 7.33813274078958]
+            [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 2.99345864623196, -2.45138938198679*I, 0.942638555913623, 1.32703057887968*I, 7.33813274078958]
         """
         cdef int length, i
         cdef gen v
@@ -8621,43 +8678,38 @@
     ## Support for GP Scripts
     ##############################################
 
-
-    def read(self, filename):
-        r"""
-        Read a script from the named filename into the interpreter, where s
-        is a string. The functions defined in the script are then available
-        for use from Sage/PARI.
-        
-        EXAMPLE:
-        
-        If foo.gp is a script that contains
-        
-        ::
-        
-                            {foo(n) =
-                                n^2
-                            }
-                        
-        
-        and you type ``read("foo.gp")``, then the command
-        ``pari("foo(12)")`` will create the Python/PARI gen
-        which is the integer 144.
-        
-        CONSTRAINTS: The PARI script must *not* contain the following
-        function calls:
-        
-        print, default, ??? (please report any others that cause trouble)
-        """
-        F = open(filename).read()
-        while True:
-            i = F.find("}")
-            if i == -1:
-                _read_script(F)
-                break
-            s = F[:i+1]            
-            _read_script(s)
-            F = F[i+1:]
-        return
+    def read(self, bytes filename):
+        r"""
+        Read a script from the named filename into the interpreter.  The
+        functions defined in the script are then available for use from
+        Sage/PARI.  The result of the last command in ``filename`` is
+        returned.
+        
+        EXAMPLES:
+        
+        Create a gp file::
+        
+            sage: import tempfile
+            sage: gpfile = tempfile.NamedTemporaryFile(mode="w")
+            sage: gpfile.file.write("mysquare(n) = {\n")
+            sage: gpfile.file.write("    n^2;\n")
+            sage: gpfile.file.write("}\n")
+            sage: gpfile.file.write("polcyclo(5)\n")
+            sage: gpfile.file.flush()
+        
+        Read it in Sage, we get the result of the last line::
+
+            sage: pari.read(gpfile.name)
+            x^4 + x^3 + x^2 + x + 1
+
+        Call the function defined in the gp file::
+
+            sage: pari('mysquare(12)')
+            144
+        """
+        _sig_on
+        return self.new_gen(gp_read_file(filename))
+
 
     ##############################################
 
@@ -8805,7 +8857,7 @@
             1
         """
         _sig_on
-        return self.new_gen(legendre(n, self.get_var(v)))
+        return self.new_gen(pollegendre(n, self.get_var(v)))
 
     def poltchebi(self, long n, v=-1):
         """
@@ -8822,7 +8874,7 @@
             1
         """
         _sig_on
-        return self.new_gen(tchebi(n, self.get_var(v)))
+        return self.new_gen(polchebyshev1(n, self.get_var(v)))
         
     def factorial(self, long n):
         """
@@ -8857,7 +8909,7 @@
             x - 1
         """
         _sig_on
-        return self.new_gen(cyclo(n, self.get_var(v)))
+        return self.new_gen(polcyclo(n, self.get_var(v)))
 
     def polsubcyclo(self, long n, long d, v=-1):
         """
@@ -8890,37 +8942,28 @@
         _sig_on
         return self.new_gen(polzag(n, m))
 
-    def listcreate(self, long n):
-        """
-        listcreate(n): return an empty pari list of maximal length n.
-        
-        EXAMPLES::
-        
-            sage: pari.listcreate(20)
-            List([])
-        """
-        _sig_on
-        return self.new_gen(listcreate(n))
-
-    def getrand(self):
-        """
-        Returns Pari's current random number seed.
-        
-        EXAMPLES::
-        
-            sage: pari.setrand(50)
-            sage: pari.getrand()
-            50
-            sage: pari.pari_rand31()
-            621715893
-            sage: pari.getrand()
-            621715893
-        """
-        return getrand()
-
-    def setrand(self, long seed):
+#  In pari 2.4.3 listcreate is "redundant and obsolete"
+#
+#     def listcreate(self, long n=0):
+#         """
+#         listcreate(): return an empty pari list
+        
+#         EXAMPLES::
+        
+#             sage: pari.listcreate()
+#             List([])
+#         """
+#         _sig_on
+#         return self.new_gen(listcreate())
+
+    def setrand(self, seed):
         """
         Sets Pari's current random number seed.
+
+        INPUT:
+
+        - ``seed`` -- either an integer, or a GEN of type t_VECSMALL
+          as output by ``getrand()``
         
         This should not be called directly; instead, use Sage's global
         random number seed handling in ``sage.misc.randstate``
@@ -8928,23 +8971,33 @@
         
         EXAMPLES::
         
-            sage: pari.setrand(12345)
-            sage: pari.getrand()
-            12345
-        """
-        setrand(seed)
-
-    def pari_rand31(self):
-        """
-        Returns a random number from Pari's random number generator.
-        
-        .. warning::
-
-           You probably don't want to use this; it's a very poor
-           random number generator. Sage exposes it only as a way to
-           test :meth:`getrand` and :meth:`setrand`.
-        """
-        return pari_rand31()
+            sage: pari.setrand(50)
+            sage: a = pari.getrand(); a
+            Vecsmall([...])
+            sage: pari.setrand(a)
+            sage: a == pari.getrand()
+            True
+        """        
+        setrand(P.toGEN(seed,0))
+
+    def getrand(self):
+        """
+        Returns Pari's current random number seed.
+
+        OUTPUT:
+
+        GEN of type t_VECSMALL
+        
+        EXAMPLES::
+        
+            sage: pari.setrand(50)
+            sage: a = pari.getrand(); a
+            Vecsmall([...])
+            sage: pari.setrand(a)
+            sage: a == pari.getrand()
+            True
+        """
+        return self.new_gen(getrand())
 
     def vector(self, long n, entries=None):
         """
@@ -9106,7 +9159,7 @@
 
 cdef size_t fix_size(size_t a):
     cdef size_t b
-    b = a - (a & (BYTES_IN_LONG-1))     # sizeof(long) | b <= a  
+    b = a - (a & (sizeof(long)-1))     # sizeof(long) | b <= a  
     if b < 1024:
         b = 1024
     return b
@@ -9232,17 +9285,6 @@
     """
     TESTS::
     
-    We only run this test on Linux, since on some machine this will
-    allocate insane amounts of RAM and lead to segfaults (e.g., on
-    FreeBSD and Solaris).
-
-        sage: if os.uname()[0]=="Linux":
-        ...       pari.listcreate(2^62 if is_64_bit else 2^30)
-        ... else:
-        ...       raise MemoryError
-        Traceback (most recent call last):
-        ...
-        MemoryError...
     """
     _sig_off
     if retries > 100:
diff -r f77808909c54 -r 8a361e1b884e sage/libs/pari/gen_py.py
--- a/sage/libs/pari/gen_py.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/libs/pari/gen_py.py	Mon Aug 16 15:43:27 2010 +0200
@@ -51,11 +51,11 @@
     Some more exotic examples:
         sage: K.<a>=NumberField(x^3-2)
         sage: pari(K)
-        [x^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 - 1.09112363597172*I, -0.793700525984100 + 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, -1.72108416091916, 0.581029111014503; 1, 0.461163111024285, -2.16843016298270], 0, [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]]], [1.25992104989487, -0.629960524947437 - 1.09112363597172*I], [1, x, x^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
-
+        [x^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 - 1.09112363597172*I, -0.793700525984100 + 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, -1.72108416091916, 0.581029111014503; 1, 0.461163111024285, -2.16843016298270], [1, 1, 2; 1, -2, 1; 1, 0, -2], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]]], [1.25992104989487, -0.629960524947437 - 1.09112363597172*I], [1, x, x^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
+    
         sage: E = EllipticCurve('37a1')
         sage: pari(E)
-        [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 2.99345864623196, 2.45138938198679*I, -0.471319277956811, -1.43545651866868*I, 7.33813274078958]
+        [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 2.99345864623196, -2.45138938198679*I, 0.942638555913623, 1.32703057887968*I, 7.33813274078958]
     """
     return gen.pari(x)
 
@@ -110,7 +110,9 @@
 
     Conversion of complex numbers: the next example is converting from
     an element of the Symbolic Ring, which goes via the string
-    representation and hence the precision is architecture-dependent:
+    representation and hence the precision is architecture-dependent::
+    
+        sage: I = SR(I)
         sage: a = pari(1.0+2.0*I).python(); a
         1.000000000000000000000000000 + 2.000000000000000000000000000*I  # 32-bit
         1.0000000000000000000000000000000000000 + 2.0000000000000000000000000000000000000*I # 64-bit
@@ -182,7 +184,7 @@
             elif yprec == 0:
                 prec = gen.prec_words_to_bits(xprec)
             else:
-                prec = min(gen.prec_words_to_bits(xprec),gen.prec_words_to_bits(yprec))
+                prec = max(gen.prec_words_to_bits(xprec),gen.prec_words_to_bits(yprec))
             R = RealField(prec)
             C = ComplexField(prec)
             return C(R(z.real()), R(z.imag()))
diff -r f77808909c54 -r 8a361e1b884e sage/libs/pari/pari_err.h
--- a/sage/libs/pari/pari_err.h	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/libs/pari/pari_err.h	Mon Aug 16 15:43:27 2010 +0200
@@ -6,13 +6,13 @@
 // this means that the code is not reentrant -- beware !
 // THAT MEANS NO CALLING TO PARI from inside the trap....
 // Should replace by a stack, that would work.
-static void *__catcherr = NULL;
+static long __catcherr = 0;
 
 #define _pari_raise(errno) { \
         PyErr_SetObject(PyExc_PariError, PyInt_FromLong(errno)); \
     }
 
-#define _pari_endcatch { err_leave(&__catcherr); } 
+#define _pari_endcatch { err_leave(__catcherr); } 
 
 /* Careful with pari_retries !
  * It should not be in a register, we flag it as "volatile".
@@ -21,7 +21,7 @@
         long pari_errno; \
         long volatile pari_retries = 0; \
         jmp_buf __env; \
-        __catcherr = NULL; \
+        __catcherr = 0; \
         if ((pari_errno=setjmp(__env))) { \
             _pari_trap(pari_errno, pari_retries); \
             if(PyErr_Occurred()) { \
@@ -32,4 +32,3 @@
         } \
         __catcherr = err_catch(CATCH_ALL, &__env); \
     }
-
diff -r f77808909c54 -r 8a361e1b884e sage/matrix/matrix2.pyx
--- a/sage/matrix/matrix2.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/matrix/matrix2.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -4335,13 +4335,15 @@
             sage: OL = L.ring_of_integers()
             sage: m = matrix(OL, 2, 2, [1,2,3,4+w])
             sage: m.echelon_form()
-            [    1    -2]
+            [    1     2]
             [    0 w - 2]
-            sage: m.echelon_form(transformation=True)
-            (
-            [    1    -2]  [-3*w - 2    w + 1]
-            [    0 w - 2], [      -3        1]
-            )
+            sage: E, T = m.echelon_form(transformation=True); E,T
+            (
+            [    1     2]  [ 1  0]
+            [    0 w - 2], [-3  1]
+            )
+            sage: E == T*m
+            True
         """
         self.check_mutability()
         cdef Matrix d, a
@@ -7021,12 +7023,16 @@
         
             sage: R = EquationOrder(x^2 + 5, 's') # class number 2
             sage: s = R.ring_generators()[0]
-            sage: matrix(R, 2, 2, [s-1,-s,-s,2*s+1]).smith_form()
-            (
-            [     1      0]  [   -1    -1]  [    1 s + 1]
-            [     0 -s - 6], [    s s - 1], [    0     1]
-            )
-        
+            sage: A = matrix(R, 2, 2, [s-1,-s,-s,2*s+1])
+            sage: D, U, V = A.smith_form()
+            sage: D, U, V
+            (
+            [     1      0]  [    4 s + 4]  [       1 -5*s + 6]
+            [     0 -s - 6], [    s s - 1], [       0        1]
+            )
+            sage: D == U*A*V
+            True
+            
         Others don't, but they fail quite constructively::
         
             sage: matrix(R,2,2,[s-1,-s-2,-2*s,-s-2]).smith_form()
@@ -7125,7 +7131,7 @@
             sage: m = matrix(OL, 3, 5, [a^2 - 3*a - 1, a^2 - 3*a + 1, a^2 + 1, -a^2 + 2, -3*a^2 - a - 1, -6*a - 1, a^2 - 3*a - 1, 2*a^2 + a + 5, -2*a^2 + 5*a + 1, -a^2 + 13*a - 3, -2*a^2 + 4*a - 2, -2*a^2 + 1, 2*a, a^2 - 6, 3*a^2 - a])
             sage: r,s,p = m._echelon_form_PID()
             sage: s[2]
-            (0, 0, -3*a^2 - 18*a + 34, -68*a^2 + 134*a - 53, -111*a^2 + 275*a - 90)
+            (0, 0, 3*a^2 + 18*a - 34, 68*a^2 - 134*a + 53, 111*a^2 - 275*a + 90)
             sage: r * m == s and r.det() == 1
             True
 
@@ -7199,11 +7205,14 @@
     
         sage: from sage.matrix.matrix2 import _smith_diag
         sage: OE = EquationOrder(x^2 - x + 2, 'w')
-        sage: _smith_diag(matrix(OE, 2, [2,0,0,3]))
+        sage: A = matrix(OE, 2, [2,0,0,3])
+        sage: D,U,V = _smith_diag(A); D,U,V
         (
-        [1 0]  [-1  1]  [ 1 -3]
-        [0 6], [-3  2], [ 1 -2]
+        [1 0]  [2 1]  [ 1 -3]
+        [0 6], [3 2], [-1  4]
         )
+        sage: D == U*A*V
+        True
         sage: m = matrix(GF(7),2, [3,0,0,6]); d,u,v = _smith_diag(m); d
         [1 0]
         [0 1]
diff -r f77808909c54 -r 8a361e1b884e sage/matrix/matrix_integer_dense.pyx
--- a/sage/matrix/matrix_integer_dense.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/matrix/matrix_integer_dense.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -2162,12 +2162,9 @@
             [x^3 - 12*x^2 - 18*x]
             sage: A.frobenius(1, var='y')
             [y^3 - 12*y^2 - 18*y]
-            sage: A.frobenius(2)
-            (
-            [ 0  0  0]  [    -1      2     -1]
-            [ 1  0 18]  [     0  23/15 -14/15]
-            [ 0  1 12], [     0  -2/15   1/15]
-            )
+            sage: F, B = A.frobenius(2)
+            sage: A == B^(-1)*F*B
+            True
             sage: a=matrix([])
             sage: a.frobenius(2)
             ([], [])
@@ -2475,7 +2472,7 @@
             [4 5 6 7]
             sage: M._kernel_matrix_using_pari()
             [ 1 -1 -1  1]
-            [ 0 -1  2 -1]
+            [ 1 -2  1  0]
 
         Testing matrices with no rows or no columns::
 
@@ -2568,18 +2565,15 @@
             [1 0]
             [0 1]
         
-        Semidefinite and indefinite forms raise a ValueError::
+        Semidefinite and indefinite forms no longer raise a ValueError::
         
             sage: Matrix(ZZ,2,2,[2,6,6,3]).LLL_gram()
-            Traceback (most recent call last):
-            ...
-            ValueError: not a definite matrix
+            [-3 -1]
+            [ 1  0]
             sage: Matrix(ZZ,2,2,[1,0,0,-1]).LLL_gram()
-            Traceback (most recent call last):
-            ...
-            ValueError: not a definite matrix
-        
-        BUGS: should work for semidefinite forms (PARI is ok)
+            [ 0 -1]
+            [ 1  0]
+        
         """
         if self._nrows != self._ncols:
             raise ArithmeticError, "self must be a square matrix"
diff -r f77808909c54 -r 8a361e1b884e sage/misc/randstate.pyx
--- a/sage/misc/randstate.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/misc/randstate.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -55,22 +55,28 @@
 
     sage: set_random_seed(0)
     sage: rtest()
-    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 1698070399, 8045, 0.96619117347084138)
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit
     sage: set_random_seed(1)
     sage: rtest()
-    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1046254370, 60359, 0.83350776541997362)
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit
     sage: set_random_seed(2)
     sage: rtest()
-    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ], 2137873234, 27695, 0.19982565117278328)
+    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ],  637693405, 27695, 0.19982565117278328)  # 32-bit
+    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ], 1642898426, 27695, 0.19982565117278328)  # 64-bit
     sage: set_random_seed(0)
     sage: rtest()
-    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 1698070399, 8045, 0.96619117347084138)
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit
     sage: set_random_seed(1)
     sage: rtest()
-    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1046254370, 60359, 0.83350776541997362)
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit
     sage: set_random_seed(2)
     sage: rtest()
-    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ], 2137873234, 27695, 0.19982565117278328)
+    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ],  637693405, 27695, 0.19982565117278328)  # 32-bit
+    (207, 0.505364206568040, 4*x^2 + 1/2, (1,2)(4,5), [ 0, 0, 1, 0, 1 ], 1642898426, 27695, 0.19982565117278328)  # 64-bit
 
 Once we've set the random number seed, we can check what seed was used.
 (This is not the current random number state; it does not change when
@@ -80,7 +86,8 @@
     sage: initial_seed()
     12345L
     sage: rtest()
-    (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 1506569166, 14005, 0.92053315995181839)
+    (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 912534076, 14005, 0.92053315995181839)   # 32-bit
+    (720, 0.0216737401150802, x^2 - x, (), [ 1, 0, 0, 0, 0 ], 1911581957, 14005, 0.92053315995181839)  # 64-bit
     sage: initial_seed()
     12345L
 
@@ -215,9 +222,11 @@
 
     sage: set_random_seed(0)
     sage: r1 = rtest(); r1
-    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 1698070399, 8045, 0.96619117347084138)
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 963229057, 8045, 0.96619117347084138)  # 32-bit
+    (303, -0.187141682737491, 1/2*x^2 - 1/95*x - 1/2, (1,2,3)(4,5), [ 0, 0, 0, 0, 1 ], 265625921, 8045, 0.96619117347084138)  # 64-bit
     sage: r2 = rtest(); r2
-    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 697338742, 1271, 0.001767155077382232)
+    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 14082860, 1271, 0.001767155077382232)  # 32-bit
+    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 53231108, 1271, 0.001767155077382232)  # 64-bit
 
 We get slightly different results with an intervening ``with seed``. ::
 
@@ -225,9 +234,11 @@
     sage: r1 == rtest()
     True
     sage: with seed(1): rtest()
-    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1046254370, 60359, 0.83350776541997362)
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit
     sage: r2m = rtest(); r2m
-    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 697338742, 19769, 0.001767155077382232)
+    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 14082860, 19769, 0.001767155077382232)  # 32-bit
+    (105, -0.581229341007821, -x^2 - x - 6, (1,3), [ 1, 0, 0, 1, 1 ], 53231108, 19769, 0.001767155077382232)  # 64-bit
     sage: r2m == r2
     False
 
@@ -241,8 +252,13 @@
     sage: set_random_seed(0)
     sage: r1 == rtest()
     True
-    sage: with seed(1): (rtest(), rtest())
-    ((978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1046254370, 60359, 0.83350776541997362), (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1077419109, 10234, 0.0033332230808060803))
+    sage: with seed(1):
+    ...       rtest();
+    ...       rtest();
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit
+    (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1966097838, 10234, 0.0033332230808060803)       # 32-bit
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 807447831, 60359, 0.83350776541997362)   # 64-bit
+    (138, -0.247578366457583, 2*x - 24, (), [ 1, 1, 1, 0, 1 ], 1010791326, 10234, 0.0033332230808060803)       # 64-bit
     sage: r2m == rtest()
     True
 
@@ -261,7 +277,8 @@
     ... finally:
     ...       ctx.__exit__(None, None, None)
     <sage.misc.randstate.randstate object at 0x...>
-    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1046254370, 60359, 0.83350776541997362)
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ], 1161603091, 60359, 0.83350776541997362)  # 32-bit
+    (978, 0.184109262667515, -3*x^2 - 1/12, (4,5), [ 0, 1, 1, 0, 0 ],  807447831, 60359, 0.83350776541997362)  # 64-bit
     False
     sage: r2m == rtest()
     True
@@ -724,7 +741,8 @@
              sage: set_random_seed(987654321)
              sage: current_randstate().set_seed_gp()
              sage: gp.random()
-             331225388
+             1931284353  # 32-bit
+             23289294    # 64-bit
          """
          if gp is None:
              import sage.interfaces.gp
@@ -761,12 +779,19 @@
          seed the Pari random number generator.  If not, seeds the
          generator.
 
+         .. note::
+
+            Since pari 2.4.3, pari's random number generator has
+            changed a lot.  the seed output by getrand() is now a
+            vector of integers.
+
          EXAMPLES::
 
              sage: set_random_seed(5551212)
              sage: current_randstate().set_seed_pari()
-             sage: pari.pari_rand31()
-             1530973455
+             sage: pari.getrand()
+             Vecsmall([-605155968, -1710928329, -1586713982, 499606189, 1618483736, -1576529895, 43752884, 106717308, -930071483, 321538842, 1598474461, -347743590, 406716006, 1810575783, 2056270826, -1166689962, 1040293387, 1959748388, 788074441, -1464580713, -274308295, 1299084471, -2104338911, 1399323735, 1646180886, -832278110, 1898800809, -675539172, -1593631013, 523869351, -1994395393, 219942282, 368424265, -555925403, -1867770858, 698342297, -818805590, -994607464, -116865284, 1265614805, 1900252922, -580722552, -198531351, -2129882509, 1812284405, -1347877145, -1164666614, -1313549603, -1159399033, -1658818513, -272488410, -229831451, 851469787, -87177366, -1740037903, -1765688758, -985138574, -97899122, -1903726536, 1887390007, -682552913, -1971130091, 1574966855, 148970122, -541177543, 1736709846, 1183724135, -19019183, 2053918935, 840490301, 1182271528, 1273421407, 1572561663, 225512395, 626565962, -1181253471, -758780888, -1434727901, -819573175, -1314265692, 384348303, 1184100459, -1595624266, -556662155, 2074310573, -1060134905, -1168907598, -1343043075, -1187655433, -1162605861, -1444211612, 2031155316, 614148563, -1392900660, -1714827481, 418310157, 1448291330, 1446480041, -852337341, 1827182600, -703341877, 877294120, -829811728, 1433119270, -1824496768, 1798300852, 942179844, 1224738346, 336655421, 814117162, -939789708, -1291158718, 236676176, 669389667, -388213090, 684046529, 1743246921, -56037182, -2139646720, 1685369617, -1483380073, 732016251, 1267219746, 668469280, 1810986717, -1007997717, 296256694, -94638339, 127, -1815312131])  # 32-bit
+             Vecsmall([-1663504465577119476, 8784837841516067975, -5753820859304384612, 7910476022165771223, 6378811681469992489, 3478119678794873599, -2969132587832846191, -3501245520902282933, 6835709013821079552, -5453456450671134746, 7485350670722002798, -646198498812561273, -5390830345676571461, 8485485875220951568, 729073405459086082, -6366318137081412331, 6509501773447610965, -2428457494199180088, 2453229052993118398, 942525059941410610, -1789843958132559410, 4356190189040894223, 3525704091742193738, -8518257892859783591, 92775841648694346, 7768952332531732783, -4483009232668131904, -6882047105209150443, -6711255991514678457, 603154967604764575, 1531681864397401475, 3744295157733453159, 8219445972183904765, 5726668509346246433, -5951285653740875571, 2989724034427842683, 4634723722544563791, 5985631780997324708, -5444928501739116290, -8236943782181590783, -7930915159867723920, 7190903677779160790, -3005634491680269223, -6640192508636844517, 9081091515770721720, -4476134377013530545, 6038719886506739235, -8891904444113652620, -4056426994021598076, -7549519269445664567, 2429707123854672246, -5349282552507482407, -6453423111075279821, -2166555251751144085, -6556578877414952876, -6701501356744638311, -3768552090916039196, 421962326293278732, -3780592489230588979, -8642986562900432216, -2161270029258166700, -3989783790516916031, 2852524366008151172, -638377516970894249, 63, 6396282526910566589])  # 64-bit
          """
          global _pari_seed_randstate
          if _pari_seed_randstate is not self:
diff -r f77808909c54 -r 8a361e1b884e sage/modular/cusps_nf.py
--- a/sage/modular/cusps_nf.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/modular/cusps_nf.py	Mon Aug 16 15:43:27 2010 +0200
@@ -61,7 +61,7 @@
 
     sage: t, M = alpha.is_Gamma0_equivalent(beta, N, Transformation=True)
     sage: M
-    [2*a - 4, -3*a - 4, -5*a + 2, 3*a + 13]
+    [-2*a + 4, 3*a + 4, 5*a - 2, -3*a - 13]
     sage: alpha.apply(M) == beta
     True
 
@@ -1257,7 +1257,7 @@
         [1]
         sage: I = k.ideal(3)
         sage: units_mod_ideal(I)
-        [1, a, -1, -a]
+        [1, -a, -1, a]
 
     ::
 
@@ -1291,4 +1291,4 @@
     from sage.misc.mrange import xmrange
     from sage.misc.misc import prod
 
-    return [prod([u**e for u,e in zip(ulist,ei)],k(1)) for ei in xmrange(elist)]
\ No newline at end of file
+    return [prod([u**e for u,e in zip(ulist,ei)],k(1)) for ei in xmrange(elist)]
diff -r f77808909c54 -r 8a361e1b884e sage/modular/modsym/p1list_nf.py
--- a/sage/modular/modsym/p1list_nf.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/modular/modsym/p1list_nf.py	Mon Aug 16 15:43:27 2010 +0200
@@ -58,7 +58,7 @@
 
     sage: alpha = MSymbol(N, a + 2, 3*a^2)
     sage: alpha.lift_to_sl2_Ok()
-    [-a - 1, 15*a^2 - 38*a + 86, a + 2, -a^2 + 9*a - 19]
+    [1, -4*a^2 + 9*a - 21, a + 2, a^2 - 3*a + 3]
     sage: Ok = k.ring_of_integers()
     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
     sage: det(M)
@@ -613,7 +613,7 @@
             sage: N = k.ideal(5, a + 3)
             sage: P = P1NFList(N)
             sage: P.normalize(3, a)
-            M-symbol (1: 2*a) of level Fractional ideal (5, a + 3)
+            M-symbol (1: 2*a) of level Fractional ideal (5, a - 2)
 
         We can use an MSymbol as input:
 
@@ -621,14 +621,14 @@
 
             sage: alpha = MSymbol(N, 3, a)
             sage: P.normalize(alpha)
-            M-symbol (1: 2*a) of level Fractional ideal (5, a + 3)
+            M-symbol (1: 2*a) of level Fractional ideal (5, a - 2)
 
         If we are interested in the normalizing scalar:
 
         ::
 
             sage: P.normalize(alpha, with_scalar=True)
-            (-a, M-symbol (1: 2*a) of level Fractional ideal (5, a + 3))
+            (-a, M-symbol (1: 2*a) of level Fractional ideal (5, a - 2))
             sage: r, beta = P.normalize(alpha, with_scalar=True)
             sage: (r*beta.c - alpha.c in N) and (r*beta.d - alpha.d in N)
             True
@@ -651,7 +651,7 @@
             sage: N = k.ideal(5, a + 3)
             sage: P = P1NFList(N)
             sage: P.N()
-            Fractional ideal (5, a + 3)
+            Fractional ideal (5, a - 2)
         """
         return self.__N
 
diff -r f77808909c54 -r 8a361e1b884e sage/modular/overconvergent/genus0.py
--- a/sage/modular/overconvergent/genus0.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/modular/overconvergent/genus0.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1015,7 +1015,7 @@
 
             sage: X = OverconvergentModularForms(2, 2, 1/6).eigenfunctions(8, Qp(2, 100))
             sage: X[1]
-            2-adic overconvergent modular form of weight-character 2 with q-expansion (1 + O(2^36))*q + (2^4 + 2^5 + 2^9 + 2^10 + 2^12 + 2^13 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^28 + 2^30 + 2^31 + 2^32 + 2^34 + 2^36 + 2^37 + 2^39 + O(2^40))*q^2 + (2^2 + 2^7 + 2^8 + 2^9 + 2^12 + 2^13 + 2^16 + 2^17 + 2^21 + 2^23 + 2^25 + 2^28 + 2^33 + 2^34 + 2^36 + 2^37 + O(2^38))*q^3 + (2^8 + 2^11 + 2^14 + 2^19 + 2^21 + 2^22 + 2^24 + 2^25 + 2^26 + 2^27 + 2^28 + 2^29 + 2^32 + 2^33 + 2^35 + 2^36 + O(2^44))*q^4 + (2 + 2^2 + 2^9 + 2^13 + 2^15 + 2^17 + 2^19 + 2^21 + 2^23 + 2^26 + 2^27 + 2^28 + 2^30 + 2^33 + 2^34 + 2^35 + 2^36 + O(2^37))*q^5 + (2^6 + 2^7 + 2^15 + 2^16 + 2^21 + 2^24 + 2^25 + 2^28 + 2^29 + 2^33 + 2^34 + 2^37 + O(2^42))*q^6 + (2^3 + 2^8 + 2^9 + 2^10 + 2^11 + 2^12 + 2^14 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^25 + 2^26 + 2^34 + 2^37 + 2^38 + O(2^39))*q^7 + O(q^8)
+            2-adic overconvergent modular form of weight-character 2 with q-expansion (1 + O(2^74))*q + (2^4 + 2^5 + 2^9 + 2^10 + 2^12 + 2^13 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^28 + 2^30 + 2^31 + 2^32 + 2^34 + 2^36 + 2^37 + 2^39 + 2^40 + 2^43 + 2^44 + 2^45 + 2^47 + 2^48 + 2^52 + 2^53 + 2^54 + 2^55 + 2^56 + 2^58 + 2^59 + 2^60 + 2^61 + 2^67 + 2^68 + 2^70 + 2^71 + 2^72 + 2^74 + 2^76 + O(2^78))*q^2 + (2^2 + 2^7 + 2^8 + 2^9 + 2^12 + 2^13 + 2^16 + 2^17 + 2^21 + 2^23 + 2^25 + 2^28 + 2^33 + 2^34 + 2^36 + 2^37 + 2^42 + 2^45 + 2^47 + 2^49 + 2^50 + 2^51 + 2^54 + 2^55 + 2^58 + 2^60 + 2^61 + 2^67 + 2^71 + 2^72 + O(2^76))*q^3 + (2^8 + 2^11 + 2^14 + 2^19 + 2^21 + 2^22 + 2^24 + 2^25 + 2^26 + 2^27 + 2^28 + 2^29 + 2^32 + 2^33 + 2^35 + 2^36 + 2^44 + 2^45 + 2^46 + 2^47 + 2^49 + 2^50 + 2^53 + 2^54 + 2^55 + 2^56 + 2^57 + 2^60 + 2^63 + 2^66 + 2^67 + 2^69 + 2^74 + 2^76 + 2^79 + 2^80 + 2^81 + O(2^82))*q^4 + (2 + 2^2 + 2^9 + 2^13 + 2^15 + 2^17 + 2^19 + 2^21 + 2^23 + 2^26 + 2^27 + 2^28 + 2^30 + 2^33 + 2^34 + 2^35 + 2^36 + 2^37 + 2^38 + 2^39 + 2^41 + 2^42 + 2^43 + 2^45 + 2^58 + 2^59 + 2^60 + 2^61 + 2^62 + 2^63 + 2^65 + 2^66 + 2^68 + 2^69 + 2^71 + 2^72 + O(2^75))*q^5 + (2^6 + 2^7 + 2^15 + 2^16 + 2^21 + 2^24 + 2^25 + 2^28 + 2^29 + 2^33 + 2^34 + 2^37 + 2^44 + 2^45 + 2^48 + 2^50 + 2^51 + 2^54 + 2^55 + 2^57 + 2^58 + 2^59 + 2^60 + 2^64 + 2^69 + 2^71 + 2^73 + 2^75 + 2^78 + O(2^80))*q^6 + (2^3 + 2^8 + 2^9 + 2^10 + 2^11 + 2^12 + 2^14 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^25 + 2^26 + 2^34 + 2^37 + 2^38 + 2^39 + 2^40 + 2^41 + 2^45 + 2^47 + 2^49 + 2^51 + 2^53 + 2^54 + 2^55 + 2^57 + 2^58 + 2^59 + 2^60 + 2^61 + 2^66 + 2^69 + 2^70 + 2^71 + 2^74 + 2^76 + O(2^77))*q^7 + O(q^8)
             sage: [x.slope() for x in X]
             [0, 4, 8, 14, 16, 18, 26, 30]
         """
@@ -1406,7 +1406,7 @@
             sage: M = OverconvergentModularForms(3, 0, 1/2)
             sage: f = M.eigenfunctions(3)[1]
             sage: f.gexp()
-            (3^-3 + O(3^91))*g + (3^-1 + 1 + 2*3 + 3^2 + 2*3^3 + 3^5 + 3^7 + 3^10 + 3^11 + 3^14 + 3^15 + 3^16 + 2*3^19 + 3^21 + 3^22 + 2*3^23 + 2*3^24 + 3^26 + 2*3^27 + 3^29 + 3^31 + 3^34 + 2*3^35 + 2*3^36 + 3^38 + 2*3^39 + 3^41 + 2*3^42 + 2*3^43 + 2*3^44 + 2*3^46 + 2*3^47 + 3^48 + 2*3^49 + 2*3^50 + 3^51 + 2*3^54 + 2*3^55 + 2*3^56 + 3^57 + 2*3^58 + 2*3^59 + 2*3^60 + 3^61 + 3^62 + 3^63 + 3^64 + 2*3^65 + 3^67 + 3^68 + 2*3^69 + 3^70 + 2*3^71 + 2*3^74 + 3^76 + 2*3^77 + 3^78 + 2*3^79 + 2*3^80 + 3^84 + 2*3^85 + 2*3^86 + 3^88 + 2*3^89 + 3^91 + 3^92 + O(3^93))*g^2 + O(g^3)
+            (3^-3 + O(3^95))*g + (3^-1 + 1 + 2*3 + 3^2 + 2*3^3 + 3^5 + 3^7 + 3^10 + 3^11 + 3^14 + 3^15 + 3^16 + 2*3^19 + 3^21 + 3^22 + 2*3^23 + 2*3^24 + 3^26 + 2*3^27 + 3^29 + 3^31 + 3^34 + 2*3^35 + 2*3^36 + 3^38 + 2*3^39 + 3^41 + 2*3^42 + 2*3^43 + 2*3^44 + 2*3^46 + 2*3^47 + 3^48 + 2*3^49 + 2*3^50 + 3^51 + 2*3^54 + 2*3^55 + 2*3^56 + 3^57 + 2*3^58 + 2*3^59 + 2*3^60 + 3^61 + 3^62 + 3^63 + 3^64 + 2*3^65 + 3^67 + 3^68 + 2*3^69 + 3^70 + 2*3^71 + 2*3^74 + 3^76 + 2*3^77 + 3^78 + 2*3^79 + 2*3^80 + 3^84 + 2*3^85 + 2*3^86 + 3^88 + 2*3^89 + 3^91 + 3^92 + 2*3^94 + 3^95 + O(3^97))*g^2 + O(g^3)
         """
         return self._gexp
 
diff -r f77808909c54 -r 8a361e1b884e sage/quadratic_forms/quadratic_form__ternary_Tornaria.py
--- a/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py	Mon Aug 16 15:43:27 2010 +0200
@@ -492,7 +492,7 @@
         True
         sage: Q.lll()
         Quadratic form in 4 variables over Integer Ring with coefficients: 
-        [ 1 0 -1 0 ]
+        [ 1 0 1 0 ]
         [ * 4 3 3 ]
         [ * * 6 3 ]
         [ * * * 6 ]
diff -r f77808909c54 -r 8a361e1b884e sage/rings/arith.py
--- a/sage/rings/arith.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/arith.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1199,7 +1199,7 @@
         sage: divisors(K.ideal(7))
         [Fractional ideal (1), Fractional ideal (-a), Fractional ideal (7)]
         sage: divisors(K.ideal(3))
-        [Fractional ideal (1), Fractional ideal (3), Fractional ideal (a - 2), Fractional ideal (-a - 2)]
+        [Fractional ideal (1), Fractional ideal (3), Fractional ideal (a - 2), Fractional ideal (a + 2)]
         sage: divisors(K.ideal(35))
         [Fractional ideal (1), Fractional ideal (35), Fractional ideal (-5*a), Fractional ideal (5), Fractional ideal (-a), Fractional ideal (7)]
     
@@ -2274,7 +2274,7 @@
 
         sage: K.<i> = QuadraticField(-1)
         sage: factor(122+454*i)
-        (-i) * (3*i - 2) * (4*i + 1) * (i + 1)^3 * (2*i + 1)^3
+        (-1) * (-2*i - 3) * (-i + 4) * (i + 1)^3 * (-i + 2)^3
 
     To access the data in a factorization::
     
diff -r f77808909c54 -r 8a361e1b884e sage/rings/complex_double.pyx
--- a/sage/rings/complex_double.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/complex_double.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -2167,7 +2167,7 @@
         cdef sage.libs.pari.gen.PariInstance P
         P = sage.libs.pari.gen.pari
         _sig_on
-        f = P.new_gen(algdep0(self._gen(), n, 0, PREC))
+        f = P.new_gen(algdep0(self._gen(), n, 0))
         from polynomial.polynomial_ring_constructor import PolynomialRing
         from integer_ring import ZZ
         R = PolynomialRing(ZZ ,'x')
diff -r f77808909c54 -r 8a361e1b884e sage/rings/complex_field.py
--- a/sage/rings/complex_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/complex_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -297,6 +297,10 @@
                 return complex_number.ComplexNumber(self, re, im)
 
             try:
+                return self(x.sage())
+            except:
+                pass
+            try:
                 return x._complex_mpfr_field_( self )
             except AttributeError:
                 pass
diff -r f77808909c54 -r 8a361e1b884e sage/rings/fraction_field_element.pyx
--- a/sage/rings/fraction_field_element.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/fraction_field_element.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -347,13 +347,13 @@
         
         We do the best we can over in-exact fields::
         
-            sage: R.<x> = RealField(20)[]
+            sage: R.<x> = RealField(70)[]
             sage: q = 1/(x^2 + 2)^2 + 1/(x-1); q
-            (x^4 + 4.0000*x^2 + x + 3.0000)/(x^5 - x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000)
+            (x^4 + 4.0000000000000000000*x^2 + x + 3.0000000000000000000)/(x^5 - x^4 + 4.0000000000000000000*x^3 - 4.0000000000000000000*x^2 + 4.0000000000000000000*x - 4.0000000000000000000)
             sage: whole, parts = q.partial_fraction_decomposition(); parts
-            [1.0000/(x - 1.0000), 1.0000/(x^4 + 4.0000*x^2 + 4.0000)]
+            [1.0000000000000000000/(x - 1.0000000000000000000), (-3.3881317890172013563e-21*x^3 + 3.3881317890172013563e-21*x^2 - 3.3881317890172013563e-21*x + 1.0000000000000000000)/(x^4 + 4.0000000000000000000*x^2 + 4.0000000000000000000)]
             sage: sum(parts)
-            (x^4 + 4.0000*x^2 + x + 3.0000)/(x^5 - x^4 + 4.0000*x^3 - 4.0000*x^2 + 4.0000*x - 4.0000)
+            (x^4 + 6.7762635780344027125e-21*x^3 + 4.0000000000000000000*x^2 + x + 3.0000000000000000000)/(x^5 - x^4 + 4.0000000000000000000*x^3 - 4.0000000000000000000*x^2 + 4.0000000000000000000*x - 4.0000000000000000000)
 
         TESTS:
 
diff -r f77808909c54 -r 8a361e1b884e sage/rings/integer.pyx
--- a/sage/rings/integer.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/integer.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -3042,7 +3042,7 @@
             sage: n = 920384092842390423848290348203948092384082349082
             sage: n._factor_trial_division(1000)
             2 * 11 * 41835640583745019265831379463815822381094652231
-            sage: n._factor_trial_division(2^30)
+            sage: n._factor_trial_division(2000)
             2 * 11 * 1531 * 27325696005058797691594630609938486205809701
         """
         import sage.structure.factorization as factorization
@@ -3092,6 +3092,13 @@
         
             sage: n.factor(limit=1000)
             2 * 11 * 41835640583745019265831379463815822381094652231
+
+        TESTS::
+
+            sage: n.factor(algorithm='foobar')
+            Traceback (most recent call last):
+            ...
+            ValueError: Algorithm is not known
         """
         if limit is not None:
             return self._factor_trial_division(limit)
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/class_group.py
--- a/sage/rings/number_field/class_group.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/class_group.py	Mon Aug 16 15:43:27 2010 +0200
@@ -162,11 +162,9 @@
             sage: G
             Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^4 + 23
             sage: list(G)
-            [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 32-bit
-            [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 64-bit
+            [Trivial principal fractional ideal class, Fractional ideal class (2, -1/2*a^2 + a + 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
             sage: G.list()
-            [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 32-bit
-            [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)] # 64-bit
+            [Trivial principal fractional ideal class, Fractional ideal class (2, -1/2*a^2 + a + 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
 
         TESTS::
 
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/galois_group.py
--- a/sage/rings/number_field/galois_group.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/galois_group.py	Mon Aug 16 15:43:27 2010 +0200
@@ -515,7 +515,7 @@
             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
             sage: G = K.galois_group()
             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
-            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
             sage: G.artin_symbol(17)
             Traceback (most recent call last):
             ...
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field.py
--- a/sage/rings/number_field/number_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -11,7 +11,9 @@
 
 - Robert Bradshaw (2008-10): specified embeddings into ambient fields
 
-- Simon King(2010-05): Improve coercion from GAP
+- Simon King (2010-05): Improve coercion from GAP
+
+- Jeroen Demeyer (2010-07): Upgrade to PARI 2.4.3
 
 .. note::
 
@@ -552,9 +554,7 @@
         sage: K.base_field().base_field()
         Number Field in a2 with defining polynomial x^2 + 1
     
-    A bigger tower of quadratic fields.
-    
-    ::
+    A bigger tower of quadratic fields::
     
         sage: K.<a2,a3,a5,a7> = NumberField([x^2 + p for p in [2,3,5,7]]); K
         Number Field in a2 with defining polynomial x^2 + 2 over its base field
@@ -2311,7 +2311,8 @@
             sage: K.<z> = CyclotomicField(10)
             sage: Ps = K.primes_of_degree_one_list(3)
             sage: Ps
-            [Fractional ideal (z^3 + z + 1), Fractional ideal (3*z^3 - z^2 + z - 1), Fractional ideal (2*z^3 - 3*z^2 + z - 2)]
+            [Fractional ideal (2*z^3 - z^2 - 1), Fractional ideal (2*z^3 - 2*z^2 + 2*z - 3), Fractional ideal (2*z^3 - 3*z^2 + z - 2)]  # 32-bit
+            [Fractional ideal (2*z^3 - z^2 - 1), Fractional ideal (-z^3 - 2*z^2), Fractional ideal (2*z^3 - 3*z^2 + z - 2)]  # 64-bit
             sage: [ P.norm() for P in Ps ]
             [11, 31, 41]
             sage: [ P.residue_class_degree() for P in Ps ]
@@ -2823,7 +2824,7 @@
             sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
             [2, a + 1]
             sage: K.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
-            [2, a + 1, -a]
+            [2, a + 1, a]
             sage: K.<a> = NumberField(polygen(QQ))
             sage: K.selmer_group([],5)
             []
@@ -2938,7 +2939,7 @@
 
         Let's check that embeddings are being respected::
 
-            sage: x = ZZ['x'].0
+            sage: x = polygen(ZZ)
             sage: K0.<b> = CyclotomicField(7, 'a').subfields(3)[0][0].change_names()
             sage: K1.<a1> = K0.extension(x^2 - 2*b^2, 'a1').absolute_field()
             sage: K2.<a2> = K0.extension(x^2 - 3*b^2, 'a2').absolute_field()
@@ -3277,8 +3278,7 @@
             sage: K.elements_of_norm(3)
             []
             sage: K.elements_of_norm(50)
-            [7*a - 1, -5*a + 5, a - 7]           # 32-bit
-            [7*a - 1, -5*a + 5, -7*a - 1]        # 64-bit
+            [-7*a + 1, -5*a - 5, a - 7]
         """
         proof = proof_flag(proof)        
         B = self.pari_bnf(proof).bnfisintnorm(n)
@@ -3295,9 +3295,7 @@
             sage: L.<b> = K.extension(t^2 + a); L
             Number Field in b with defining polynomial t^2 + a over its base field
         
-        We create another extension.
-        
-        ::
+        We create another extension::
         
             sage: k.<a> = NumberField(x^2 + 1); k
             Number Field in a with defining polynomial x^2 + 1
@@ -3312,9 +3310,7 @@
             sage: b.minpoly('z')
             z^2 + 2
         
-        A relative extension of a relative extension.
-        
-        ::
+        A relative extension of a relative extension::
         
             sage: k.<a> = NumberField([x^2 + 1, x^3 + x + 1])
             sage: R.<z> = k[]
@@ -3348,27 +3344,20 @@
         Here are the factors::
         
             sage: fi, fj = K.factor(13); fi,fj
-            ((Fractional ideal (-3*I - 2), 1), (Fractional ideal (3*I - 2), 1))
+            ((Fractional ideal (-2*I + 3), 1), (Fractional ideal (-2*I - 3), 1))
         
         Now we extract the reduced form of the generators::
         
             sage: zi = fi[0].gens_reduced()[0]; zi
-            -3*I - 2
+            -2*I + 3
             sage: zj = fj[0].gens_reduced()[0]; zj
-            3*I - 2
-        
-        We recover the integer that was factored in `\ZZ[i]`::
+            -2*I - 3
+        
+        We recover the integer that was factored in `\ZZ[i]` up to a unit::
         
             sage: zi*zj
-            13
-
-        We can see units are not considered::
-
-            sage: K.factor(2)
-            (Fractional ideal (I + 1))^2
-            sage: expand((I+1)^2)
-            2*I
-        
+            -13
+
         One can also factor elements or ideals of the number field::
         
             sage: K.<a> = NumberField(x^2 + 1)
@@ -3377,16 +3366,13 @@
             sage: K.factor(1+a)
             Fractional ideal (a + 1)
             sage: K.factor(1+a/5)
-            (Fractional ideal (-3*a - 2)) * (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1
-
-        The slightly odd syntax in the next example is to ensure 
-        the same result with both 32- and 64-bit systems.
-
-        ::
+            (Fractional ideal (-2*a + 3)) * (Fractional ideal (a + 1)) * (Fractional ideal (a + 2))^-1 * (Fractional ideal (-a + 2))^-1
+
+        An example over a relative number field::
 
             sage: L.<b> = K.extension(x^2 - 7)
-            sage: list(L.factor(a + 1)) == [(L.ideal((a + b + 2)/2), 1), (L.ideal((a - b - 2)/2), 1)]
-            True
+            sage: L.factor(a + 1)
+            (Fractional ideal (1/2*a*b + a + 1/2)) * (Fractional ideal (-1/2*a*b + a + 1/2))
             
         It doesn't make sense to factor the ideal (0), so this raises an error::
         
@@ -3699,7 +3685,7 @@
         
             sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
             sage: K._compute_integral_basis()
-            [1, a, 1/2*a^2 + 1/2*a]
+            [1, a, 1/2*a^2 - 1/2*a]
             sage: K.integral_basis()
             [1, 1/2*a^2 + 1/2*a, a^2]
         """
@@ -3733,8 +3719,8 @@
         
         -  ``self`` - number field, the base field
         
-        -  ``prec (default: None)`` - the precision with which
-           to compute the Minkowski embedding. (See NOTE below.)
+        -  ``prec (default: None)`` - the precision with which to
+           compute the Minkowski embedding.
         
         
         OUTPUT:
@@ -3752,9 +3738,6 @@
            be integral; however, it may only be only "almost" LLL-reduced
            when the precision is not sufficiently high.
         
-        If the following run-time error occurs: "PariError: not a definite
-        matrix in lllgram (42)" try increasing the prec parameter,
-        
         EXAMPLES::
         
             sage: F.<t> = NumberField(x^6-7*x^4-x^3+11*x^2+x-1)
@@ -3764,19 +3747,6 @@
             [-1, -1/2*t^5 + 1/2*t^4 + 3*t^3 - 3/2*t^2 - 4*t - 1/2, t, 1/2*t^5 + 1/2*t^4 - 4*t^3 - 5/2*t^2 + 7*t + 1/2, 1/2*t^5 - 1/2*t^4 - 2*t^3 + 3/2*t^2 - 1/2, 1/2*t^5 - 1/2*t^4 - 3*t^3 + 5/2*t^2 + 4*t - 5/2]
             sage: CyclotomicField(12).reduced_basis()
             [1, zeta12^2, zeta12, zeta12^3]
-        
-        ::
-        
-            sage: F.<alpha> = NumberField(x^4+x^2+712312*x+131001238)
-            sage: F.integral_basis()
-            [1, alpha, 1/2*alpha^3 + 1/2*alpha^2, alpha^3]
-            sage: F.reduced_basis(prec=64)
-            [1, alpha, alpha^3 - 2*alpha^2 + 15*alpha, 16*alpha^3 - 31*alpha^2 + 469*alpha + 267109]     # 32-bit
-            Traceback (most recent call last):                 # 64-bit
-            ...                                                # 64-bit
-            PariError: not a definite matrix in lllgram (42)   # 64-bit
-            sage: F.reduced_basis(prec=96)
-            [1, alpha, alpha^3 - 2*alpha^2 + 15*alpha, 16*alpha^3 - 31*alpha^2 + 469*alpha + 267109]
         """
         if self.is_totally_real():
             try:
@@ -4409,36 +4379,18 @@
             sage: A = x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3
             sage: K = NumberField(A, 'a')
             sage: K.units()
-            [8/275*a^3 - 12/55*a^2 + 15/11*a - 2]
-        
-        Sage might not be able to provably compute the unit group::
+            [1/275*a^3 + 4/55*a^2 - 5/11*a + 3]
+        
+        For big number fields, provably computing the unit group can
+        take a very long time.  In this case, one can ask for the
+        conjectural unit group (correct if the Generalized Riemann
+        Hypothesis is true)::
         
             sage: K = NumberField(x^17 + 3, 'a')
-            sage: K.units(proof=True) # default
-            Traceback (most recent call last):
-            ...
-            PariError: not enough precomputed primes, need primelimit ~  (35)
-        
-        In this case, one can ask for the conjectural unit group (correct
-        if the Generalized Riemann Hypothesis is true)::
-        
+            sage: K.units(proof=True)  # takes forever, not tested
+            ...
             sage: K.units(proof=False)
-            [a^9 + a - 1,
-            a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1,
-            2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4,
-            2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4,
-            a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2,
-            a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7,
-            a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1,
-            3*a^16 + 3*a^15 + 3*a^14 + 3*a^13 + 3*a^12 + 2*a^11 + 2*a^10 + 2*a^9 + a^8 - a^7 - 2*a^6 - 3*a^5 - 3*a^4 - 4*a^3 - 6*a^2 - 8*a - 8]
-        
-        The provable and the conjectural results are cached separately
-        (this fixes trac #2504)::
-        
-            sage: K.units(proof=True)
-            Traceback (most recent call last):
-            ...
-            PariError: not enough precomputed primes, need primelimit ~  (35)
+            [a^9 + a - 1, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, a^15 + a^14 + a^13 + a^12 + a^10 - a^7 - a^6 - a^2 - 1, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, a^16 - 2*a^15 - 2*a^13 - a^12 - a^11 - 2*a^10 + a^9 - 2*a^8 + 2*a^7 - 3*a^6 - 3*a^4 - 2*a^3 - a^2 - 4*a + 2, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, 3*a^16 + 3*a^15 + 3*a^14 + 3*a^13 + 3*a^12 + 2*a^11 + 2*a^10 + 2*a^9 + a^8 - a^7 - 2*a^6 - 3*a^5 - 3*a^4 - 4*a^3 - 6*a^2 - 8*a - 8]
         """
         proof = proof_flag(proof)
 
@@ -4488,42 +4440,23 @@
             sage: U = K.unit_group(); U
             Unit group with structure C10 x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375
             sage: U.gens()
-            [-1/275*a^3 + 7/55*a^2 - 6/11*a + 4, 8/275*a^3 - 12/55*a^2 + 15/11*a - 2]
+            [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3]
             sage: U.invariants()
             [10, 0]
             sage: [u.multiplicative_order() for u in U.gens()]
             [10, +Infinity]
 
-        Sage might not be able to provably compute the unit group::
-
+        For big number fields, provably computing the unit group can
+        take a very long time.  In this case, one can ask for the
+        conjectural unit group (correct if the Generalized Riemann
+        Hypothesis is true)::
+        
             sage: K = NumberField(x^17 + 3, 'a')
-            sage: K.unit_group(proof=True) # default
-            Traceback (most recent call last):
-            ...
-            PariError: not enough precomputed primes, need primelimit ~  (35)
-
-        In this case, one can ask for the conjectural unit group (correct if
-        the Generalized Riemann Hypothesis is true)::
-            
+            sage: K.unit_group(proof=True)  # takes forever, not tested
+            ...
             sage: U = K.unit_group(proof=False); U; U.gens()
             Unit group with structure C2 x Z x Z x Z x Z x Z x Z x Z x Z of Number Field in a with defining polynomial x^17 + 3
-            [-1,
-            a^9 + a - 1,
-            a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1,
-            2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4,
-            2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4,
-            a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2,
-            a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7,
-            a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1,
-            3*a^16 + 3*a^15 + 3*a^14 + 3*a^13 + 3*a^12 + 2*a^11 + 2*a^10 + 2*a^9 + a^8 - a^7 - 2*a^6 - 3*a^5 - 3*a^4 - 4*a^3 - 6*a^2 - 8*a - 8]
-
-        The provable and the conjectural results are cached separately
-        (this fixes trac #2504)::
-
-            sage: K.units(proof=True)
-            Traceback (most recent call last):
-            ...
-            PariError: not enough precomputed primes, need primelimit ~  (35)
+            [-1, a^9 + a - 1, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, a^15 + a^14 + a^13 + a^12 + a^10 - a^7 - a^6 - a^2 - 1, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, a^16 - 2*a^15 - 2*a^13 - a^12 - a^11 - 2*a^10 + a^9 - 2*a^8 + 2*a^7 - 3*a^6 - 3*a^4 - 2*a^3 - a^2 - 4*a + 2, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, 3*a^16 + 3*a^15 + 3*a^14 + 3*a^13 + 3*a^12 + 2*a^11 + 2*a^10 + 2*a^9 + a^8 - a^7 - 2*a^6 - 3*a^5 - 3*a^4 - 4*a^3 - 6*a^2 - 8*a - 8]
         """
         try:
             return self._unit_group
@@ -4689,6 +4622,13 @@
             -a
             sage: z.multiplicative_order()
             6
+
+            sage: x = polygen(QQ)
+            sage: F.<a,b> = NumberField([x^2 - 2, x^2 - 3])
+            sage: y = polygen(F)
+            sage: K.<c> = F.extension(y^2 - (1 + a)*(a + b)*a*b)
+            sage: K.primitive_root_of_unity()
+            -1
         """
         try:
             return self._unit_group.torsion_generator()
@@ -4702,13 +4642,7 @@
         pK = self.pari_nf()
         n, z = pK.nfrootsof1()
         n = ZZ(n)
-        if self.is_absolute():
-            z = self(z)
-        else:
-            zk = pK.getattr('zk')
-            z = z.mattranspose()
-            cc = [z[0,i] for i in range(z.ncols())]
-            z = sum([self(c*d) for d,c in zip(zk,cc)])
+        z = self(z)
 
         primitives = [z**i for i in n.coprime_integers(n)]
         primitives.sort(cmp=lambda z,w: len(str(z))-len(str(w)))
@@ -5163,19 +5097,21 @@
              x^3 - 3*x^2 + 3*x + 1,
              x^3 - 3*x^2 + 3*x - 17,
              x^6 - 3*x^5 + 6*x^4 - 11*x^3 + 12*x^2 + 3*x + 1]
-             sage: R.<t> = QQ[]
-             sage: L = NumberField(t^3 - 3*t + 1, 'c')
-             sage: [k[1] for k in L.subfields()]
-             [Ring morphism:
-               From: Number Field in c0 with defining polynomial t
-               To:   Number Field in c with defining polynomial t^3 - 3*t + 1
-               Defn: 0 |--> 0,
-              Ring morphism:
-               From: Number Field in c1 with defining polynomial t^3 - 3*t + 1
-               To:   Number Field in c with defining polynomial t^3 - 3*t + 1
-               Defn: c1 |--> c]
-            sage: L.subfields(2)
-            []
+            sage: R.<t> = QQ[]
+            sage: L = NumberField(t^3 - 3*t + 1, 'c')
+            sage: [k[1] for k in L.subfields()]
+            [Ring morphism:
+              From: Number Field in c0 with defining polynomial t
+              To:   Number Field in c with defining polynomial t^3 - 3*t + 1
+              Defn: 0 |--> 0,
+             Ring morphism:
+              From: Number Field in c1 with defining polynomial t^3 - 3*t + 1
+              To:   Number Field in c with defining polynomial t^3 - 3*t + 1
+              Defn: c1 |--> c]
+            sage: len(L.subfields(2))
+            0
+            sage: len(L.subfields(1))
+            1
         """
         return self._subfields_helper(degree=degree, name=name,
                                       both_maps=True, optimize=False)
@@ -7569,7 +7505,7 @@
 
     def hilbert_class_field_defining_polynomial(self, name='x'):
         r"""
-        Returns a polynomial over `\QQ` whose roots generate
+        Returns a polynomial over `\QQ` whose roots generate the
         Hilbert class field of this quadratic field as an extension of
         this quadratic field.
         
@@ -7582,11 +7518,10 @@
         
             sage: K.<b> = QuadraticField(-23)
             sage: K.hilbert_class_field_defining_polynomial()
-            x^3 + x^2 - 1
-        
-        Note that this polynomial is not the actual Hilbert class polynomial: see ``hilbert_class_polynomial``.
-        
-        ::
+            x^3 - x^2 + 1
+        
+        Note that this polynomial is not the actual Hilbert class
+        polynomial: see ``hilbert_class_polynomial``::
         
             sage: K.hilbert_class_polynomial()
             x^3 + 3491750*x^2 - 5151296875*x + 12771880859375
@@ -7597,9 +7532,9 @@
             sage: K.class_number()
             21
             sage: K.hilbert_class_field_defining_polynomial(name='z')
-            z^21 + z^20 - 13*z^19 - 50*z^18 + 592*z^17 - 2403*z^16 + 5969*z^15 - 10327*z^14 + 13253*z^13 - 12977*z^12 + 9066*z^11 - 2248*z^10 - 5523*z^9 + 11541*z^8 - 13570*z^7 + 11315*z^6 - 6750*z^5 + 2688*z^4 - 577*z^3 + 9*z^2 + 15*z + 1
-        """
-        f = pari('quadhilbert(%s))'%self.discriminant())
+            z^21 + 6*z^20 + 9*z^19 - 4*z^18 + 33*z^17 + 140*z^16 + 220*z^15 + 243*z^14 + 297*z^13 + 461*z^12 + 658*z^11 + 743*z^10 + 722*z^9 + 681*z^8 + 619*z^7 + 522*z^6 + 405*z^5 + 261*z^4 + 119*z^3 + 35*z^2 + 7*z + 1
+        """
+        f = pari(self.discriminant()).quadhilbert()
         return QQ[name](f)
 
     def hilbert_class_field(self, names):
@@ -7618,11 +7553,11 @@
 
             sage: K.<a> = NumberField(x^2 + 23)
             sage: L = K.hilbert_class_field('b'); L
-            Number Field in b with defining polynomial x^3 + x^2 - 1 over its base field
+            Number Field in b with defining polynomial x^3 - x^2 + 1 over its base field
             sage: L.absolute_field('c')
-            Number Field in c with defining polynomial x^6 + 2*x^5 + 70*x^4 + 90*x^3 + 1631*x^2 + 1196*x + 12743
+            Number Field in c with defining polynomial x^6 - 2*x^5 + 70*x^4 - 90*x^3 + 1631*x^2 - 1196*x + 12743
             sage: K.hilbert_class_field_defining_polynomial()
-            x^3 + x^2 - 1
+            x^3 - x^2 + 1
         """
         f = self.hilbert_class_field_defining_polynomial()
         return self.extension(f, names)
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field_element.pyx
--- a/sage/rings/number_field/number_field_element.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field_element.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -520,9 +520,7 @@
         
         Note that _pari_init_ can fail because of reserved words in
         PARI, and since it actually works by obtaining the PARI
-        representation of something.
-        
-        ::
+        representation of something::
         
             sage: K.<theta> = NumberField(x^5 - x - 1)
             sage: b = (1/2 - 2/3*theta)^3; b
@@ -530,12 +528,10 @@
             sage: b._pari_init_('theta')
             Traceback (most recent call last):
             ...
-            PariError: unexpected character (2)
+            PariError:  (26)
         
         Fortunately pari_init returns everything in terms of x by
-        default.
-        
-        ::
+        default::
         
             sage: pari(b)
             Mod(-8/27*x^3 + 2/3*x^2 - 1/2*x + 1/8, x^5 - x - 1)
@@ -2662,7 +2658,7 @@
         
             sage: P5s = F(5).support()
             sage: P5s 
-            [Fractional ideal (-t^2 - 1), Fractional ideal (t^2 - 2*t - 1)]
+            [Fractional ideal (t^2 + 1), Fractional ideal (t^2 - 2*t - 1)]
             sage: all(5 in P5 for P5 in P5s)
             True
             sage: all(P5.is_prime() for P5 in P5s)
@@ -2844,7 +2840,7 @@
             sage: I._pari_('I')
             Traceback (most recent call last):
             ...
-            PariError: forbidden (45)
+            PariError: incorrect type (11)
         
         Instead, request the variable be named different for the coercion::
         
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field_ideal.py
--- a/sage/rings/number_field/number_field_ideal.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field_ideal.py	Mon Aug 16 15:43:27 2010 +0200
@@ -110,9 +110,9 @@
         sage: K_bnf = gp(K.pari_bnf())
         sage: ideal = K_bnf.idealprimedec(3)[1]
         sage: convert_from_idealprimedec_form(K, ideal)
-        Fractional ideal (1/2*a - 3/2)
+        Fractional ideal (-a)
         sage: K.factor(3)
-        (Fractional ideal (1/2*a - 3/2))^2
+        (Fractional ideal (-a))^2
 
     """
     p = ZZ(ideal[1])
@@ -200,7 +200,7 @@
             sage: K.<a> = NumberField(x^2 + 3); K
             Number Field in a with defining polynomial x^2 + 3
             sage: f = K.factor(15); f
-            (Fractional ideal (1/2*a - 3/2))^2 * (Fractional ideal (5))
+            (Fractional ideal (-a))^2 * (Fractional ideal (5))
             sage: cmp(f[0][0], f[1][0])
             -1
             sage: cmp(f[0][0], f[0][0])
@@ -1372,8 +1372,6 @@
             sage: J = K.ideal(17+a)
             sage: I/J
             Fractional ideal (-17/1420*a + 1/284)
-            sage: (I/J) * J
-            Fractional ideal (-1/5*a)
             sage: (I/J) * J == I
             True
         """
@@ -1466,7 +1464,7 @@
             sage: K.<a> = NumberField(x^2 + 2); K
             Number Field in a with defining polynomial x^2 + 2
             sage: f = K.factor(2); f
-            (Fractional ideal (-a))^2
+            (Fractional ideal (a))^2
             sage: f[0][0].ramification_index()
             2
             sage: K.ideal(13).ramification_index()
@@ -1668,9 +1666,9 @@
             sage: ires =  K.ideal(2).invertible_residues(); ires  # random address
             <generator object at 0xa2feb6c>
             sage: list(ires)
-            [-1, -i]
+            [1, -i]
             sage: list(K.ideal(2+i).invertible_residues())
-            [1, 2, -1, -2]
+            [1, 2, 4, 3]
             sage: list(K.ideal(i).residues())
             [0]
             sage: list(K.ideal(i).invertible_residues())
@@ -1729,7 +1727,7 @@
             sage: k.<a> = NumberField(x^2 +23)
             sage: I = k.ideal(a)
             sage: list(I.invertible_residues_mod([-1]))
-            [1, 5, 2, 10, 4, -3, 8, -6, -7, 11, 9]
+            [1, 5, 2, 10, 4, 20, 8, 17, 16, 11, 9]
             sage: list(I.invertible_residues_mod([1/2]))
             [1, 5]
             sage: list(I.invertible_residues_mod([23]))
@@ -1800,9 +1798,9 @@
             sage: I = K.ideal((3+4*i)/5); I
             Fractional ideal (4/5*i + 3/5)
             sage: I.denominator()
-            Fractional ideal (2*i + 1)
+            Fractional ideal (-i + 2)
             sage: I.numerator()
-            Fractional ideal (-i - 2)
+            Fractional ideal (i + 2)
             sage: I.numerator().is_integral() and I.denominator().is_integral()
             True
             sage: I.numerator() + I.denominator() == K.unit_ideal()
@@ -1830,9 +1828,9 @@
             sage: I = K.ideal((3+4*i)/5); I
             Fractional ideal (4/5*i + 3/5)
             sage: I.denominator()
-            Fractional ideal (2*i + 1)
+            Fractional ideal (-i + 2)
             sage: I.numerator()
-            Fractional ideal (-i - 2)
+            Fractional ideal (i + 2)
             sage: I.numerator().is_integral() and I.denominator().is_integral()
             True
             sage: I.numerator() + I.denominator() == K.unit_ideal()
@@ -1969,7 +1967,7 @@
             sage: k.<a> = NumberField(x^2 + 5)
             sage: I = k.ideal(a)
             sage: I.small_residue(14)
-            -1
+            4
 
         ::
 
@@ -2148,7 +2146,7 @@
             Fractional ideal (a^2 - 4*a + 2)
             68
             sage: r = A.element_1_mod(B); r
-            a^2 + 5
+            -a^2 + 4*a - 1
             sage: r in A
             True
             sage: 1-r in B
@@ -2427,9 +2425,9 @@
             Basis matrix:
             [1 3]
             sage: quo
-            Partially defined quotient map from Number Field in i with defining polynomial x^2 + 1 to an explicit vector space representation for the quotient of the ring of integers by (p,I) for the ideal I=Fractional ideal (-i - 2).
+            Partially defined quotient map from Number Field in i with defining polynomial x^2 + 1 to an explicit vector space representation for the quotient of the ring of integers by (p,I) for the ideal I=Fractional ideal (i + 2).
             sage: lift
-            Lifting map to Maximal Order in Number Field in i with defining polynomial x^2 + 1 from quotient of integers by Fractional ideal (-i - 2)
+            Lifting map to Maximal Order in Number Field in i with defining polynomial x^2 + 1 from quotient of integers by Fractional ideal (i + 2)
         """
         return quotient_char_p(self, p)
 
@@ -2474,11 +2472,10 @@
 
             sage: K.<i> = NumberField(x^2 + 1)
             sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2)
-            (Fractional ideal (-i - 2), Fractional ideal (2*i + 1))
+            (Fractional ideal (i + 2), Fractional ideal (-i + 2))
             sage: a = 1/(1+2*i)
             sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2) 
-            (Residue field of Fractional ideal (-i - 2),
-            Residue field of Fractional ideal (2*i + 1))
+            (Residue field of Fractional ideal (i + 2), Residue field of Fractional ideal (-i + 2))
             sage: a.valuation(P1)
             0
             sage: F1(i/7)
@@ -2489,7 +2486,7 @@
             -1
             sage: F2(a)
             Traceback (most recent call last):
-            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (2*i + 1): it has negative valuation        
+            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (-i + 2): it has negative valuation
 
         An example with a relative number field::
 
@@ -2646,7 +2643,7 @@
         []
 
         sage: I = K.factor(13)[0][0]; I
-        Fractional ideal (-3*i - 2)
+        Fractional ideal (-2*i + 3)
         sage: I.residue_class_degree()
         1
         sage: quotient_char_p(I, 13)[0]
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field_ideal_rel.py
--- a/sage/rings/number_field/number_field_ideal_rel.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field_ideal_rel.py	Mon Aug 16 15:43:27 2010 +0200
@@ -11,14 +11,14 @@
 
     sage: K.<a,b> = NumberField([x^2 + 1, x^2 + 2])
     sage: A = K.absolute_field('z')
-    sage: I = A.factor(3)[0][0]
+    sage: I = A.factor(7)[0][0]
     sage: from_A, to_A = A.structure()
     sage: G = [from_A(z) for z in I.gens()]; G
-    [3, (-2*b - 1)*a + b - 1]
+    [7, -2*b*a - 1]
     sage: K.fractional_ideal(G)
-    Fractional ideal ((b - 1)*a)
+    Fractional ideal (2*b*a + 1)
     sage: K.fractional_ideal(G).absolute_norm().factor()
-    3^2
+    7^2
 """
 
 #*****************************************************************************
@@ -301,7 +301,7 @@
             sage: K.<a> = NumberField(x^2+6)
             sage: L.<b> = K.extension(K['x'].gen()^4 + a)
             sage: N = L.ideal(b).relative_norm(); N
-            Fractional ideal (-a)
+            Fractional ideal (a)
             sage: N.parent()
             Monoid of ideals of Number Field in a with defining polynomial x^2 + 6
             sage: N.ring()
@@ -592,8 +592,8 @@
             sage: I.relative_ramification_index()
             2
             sage: I.ideal_below()
-            Fractional ideal (-b)
-            sage: K.ideal(-b) == I^2
+            Fractional ideal (b)
+            sage: K.ideal(b) == I^2
             True
         """
         if self.is_prime():
@@ -772,7 +772,7 @@
         sage: is_NumberFieldFractionalIdeal_rel(I)
         True
         sage: N = I.relative_norm(); N
-        Fractional ideal (-a)
+        Fractional ideal (a)
         sage: is_NumberFieldFractionalIdeal_rel(N)
         False
         sage: is_NumberFieldFractionalIdeal(N)
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field_morphisms.pyx
--- a/sage/rings/number_field/number_field_morphisms.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field_morphisms.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -213,6 +213,10 @@
             sage: f = EmbeddedNumberFieldConversion(K, L) 
             sage: f(zeta12^4) # indirect doctest
             zeta15^5
+            sage: f(zeta12)
+            Traceback (most recent call last):
+            ...
+            ValueError: No consistent embedding of Cyclotomic Field of order 12 and degree 4 into Cyclotomic Field of order 15 and degree 8.
         """
         minpoly = x.minpoly()
         gen_image = matching_root(minpoly.change_ring(self._codomain), x, self.ambient_field, 4)
@@ -263,7 +267,6 @@
         for r in roots:
             if ambient_field(r) == target_approx:
                 return r
-    
     else:
         # since things are inexact, try and pick the closest one
         if max_prec is None:
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/number_field_rel.py
--- a/sage/rings/number_field/number_field_rel.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/number_field_rel.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1459,7 +1459,7 @@
 
             sage: k.<a> = NumberField([x^4 + 3, x^2 + 2])
             sage: k.pari_rnf()
-            [Mod(1, y^2 + 2)*x^4 + Mod(3, y^2 + 2), [], [[108, 0; 0, 108], [3, 0]~], ... 0]
+            [x^4 + 3, [], [[108, 0; 0, 108], 3], [8, 0; 0, 8], [], [], [[1, x - 1, x^2 - 1, x^3 - x^2 - x - 3], ..., 0]
         """
         return self._pari_base_nf().rnfinit(self.pari_relative_polynomial())
 
@@ -2011,7 +2011,7 @@
             sage: PF.<Y> = F[]
             sage: K.<c> = F.extension(Y^2 - (1 + a)*(a + b)*a*b)
             sage: K.relative_discriminant()
-            Fractional ideal (-4*b)
+            Fractional ideal (4*b)
         """
         nf = self._pari_base_nf()
         base = self.base_field()
@@ -2310,7 +2310,7 @@
         
             sage: K.<a, b> = NumberField([x^2 + 23, x^2 - 3])
             sage: P = K.prime_factors(5)[0]; P
-            Fractional ideal (5, (-1/2*b + 5/2)*a - 5/2*b - 11/2)
+            Fractional ideal (5, (-1/2*b - 5/2)*a + 5/2*b - 11/2)
             sage: u = K.uniformizer(P)
             sage: u.valuation(P)
             1
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/order.py
--- a/sage/rings/number_field/order.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/order.py	Mon Aug 16 15:43:27 2010 +0200
@@ -170,7 +170,7 @@
             sage: K.<a> = NumberField(x^2 + 2)
             sage: R = K.maximal_order()
             sage: R.fractional_ideal(2/3 + 7*a, a)
-            Fractional ideal (-1/3*a)        
+            Fractional ideal (1/3*a)        
         """
         return self.number_field().fractional_ideal(*args, **kwds)
 
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/small_primes_of_degree_one.py
--- a/sage/rings/number_field/small_primes_of_degree_one.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/small_primes_of_degree_one.py	Mon Aug 16 15:43:27 2010 +0200
@@ -143,7 +143,7 @@
         self._poly = ZZ['x'](self._poly.denominator() * self._poly()) # make integer polynomial
 
         # this uses that [ O_K : Z[a] ]^2 = | disc(f(x)) / disc(O_K) |
-        self._prod_of_small_primes = ZZ(pari('TEMPn = %s; TEMPps = primes(TEMPn); prod(X = 1, TEMPn, TEMPps[X]))' % num_integer_primes))
+        self._prod_of_small_primes = ZZ(pari('TEMPn = %s; TEMPps = primes(TEMPn); prod(X = 1, TEMPn, TEMPps[X])' % num_integer_primes))
         self._prod_of_small_primes //= self._prod_of_small_primes.gcd(self._poly.discriminant())
 
         self._integer_iter = iter(ZZ)
diff -r f77808909c54 -r 8a361e1b884e sage/rings/number_field/unit_group.py
--- a/sage/rings/number_field/unit_group.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/number_field/unit_group.py	Mon Aug 16 15:43:27 2010 +0200
@@ -10,8 +10,10 @@
 
 The first generator is a primitive root of unity in the field::
 
-    sage: UK.gens() # random
-    [1/12*a^3 - 1/6*a, 1/24*a^3 + 1/4*a^2 - 1/12*a - 1]
+    sage: UK.gens()  # random
+    [-1/12*a^3 + 1/6*a, 1/24*a^3 + 1/4*a^2 - 1/12*a - 1]
+    sage: UK.gens()[0]
+    -1/12*a^3 + 1/6*a
     sage: [u.multiplicative_order() for u in UK.gens()]
     [4, +Infinity]
 
@@ -28,16 +30,16 @@
     sage: UK(-1)
     u0^2
     sage: [UK(u) for u in (x^4-1).roots(K,multiplicities=False)]
-    [1, u0^2, u0, u0^3]
+    [1, u0^2, u0^3, u0]
 
     sage: UK.fundamental_units() # random
     [1/24*a^3 + 1/4*a^2 - 1/12*a - 1]
     sage: UK.torsion_generator()
-    1/12*a^3 - 1/6*a
+    -1/12*a^3 + 1/6*a
     sage: UK.zeta_order()
     4
     sage: UK.roots_of_unity()
-    [1/12*a^3 - 1/6*a, -1, -1/12*a^3 + 1/6*a, 1]
+    [-1/12*a^3 + 1/6*a, -1, 1/12*a^3 - 1/6*a, 1]
    
 Exp and log functions provide maps between units as field elements and exponent
 vectors with respect to the generators::
@@ -69,31 +71,7 @@
     sage: UL.zeta_order()
     24
     sage: UL.roots_of_unity()
-    [-b^3*a - b^3,
-    -b^2*a,
-    b,
-    a + 1,
-    -b^3*a,
-    b^2,
-    b*a + b,
-    a,
-    b^3,
-    b^2*a + b^2,
-    b*a,
-    -1,
-    b^3*a + b^3,
-    b^2*a,
-    -b,
-    -a - 1,
-    b^3*a,
-    -b^2,
-    -b*a - b,
-    -a,
-    -b^3,
-    -b^2*a - b^2,
-    -b*a,
-    1]
-
+    [b*a, -b^2*a - b^2, b^3, -a, b*a + b, -b^2, -b^3*a, -a - 1, b, b^2*a, -b^3*a - b^3, -1, -b*a, b^2*a + b^2, -b^3, a, -b*a - b, b^2, b^3*a, a + 1, -b, -b^2*a, b^3*a + b^3, 1]
 
 A relative extension example, which worked thanks to the code review by F.W.Clarke::
 
@@ -190,16 +168,7 @@
         n, z = pK.nfrootsof1()
         n = ZZ(n)
         self.__ntu = n
-
-        # For an absolute field we can now set z = K(z), but this
-        # does not work for relative fields, so we work harder:
-        if K.is_absolute():
-            z = K(z)
-        else:
-            zk = pK.getattr('zk')
-            z = z.mattranspose()
-            cc = [z[0,i] for i in range(z.ncols())]
-            z = sum([K(c*d) for d,c in zip(zk,cc)])
+        z = K(z)
 
         # If we replaced z by another torsion generator we would need
         # to allow for this in the dlog function!  So we do not.
@@ -385,7 +354,7 @@
             sage: K.<b> = NumberField(x^2+1)
             sage: U = UnitGroup(K)
             sage: zs = U.roots_of_unity(); zs
-            [b, -1, -b, 1]
+            [-b, -1, b, 1]
             sage: [ z**U.zeta_order() for z in zs ]
             [1, 1, 1, 1]
         """
@@ -449,9 +418,9 @@
             sage: K.<b> = NumberField(x^2+1)
             sage: U = UnitGroup(K)
             sage: U.zeta(4)
-            b
+            -b
             sage: U.zeta(4,all=True)
-            [b, -b]
+            [-b, b]
             sage: U.zeta(3)
             Traceback (most recent call last):
             ...
@@ -529,7 +498,7 @@
             [0, 0, 0, 0, 1, 0],
             [0, 0, 0, 0, 0, 1]]
             sage: vec = [65,6,7,8,9,10]
-            sage: unit = UK.exp(vec); unit
+            sage: unit = UK.exp(vec); unit  # random
             -253576*z^11 + 7003*z^10 - 395532*z^9 - 35275*z^8 - 500326*z^7 - 35275*z^6 - 395532*z^5 + 7003*z^4 - 253576*z^3 - 59925*z - 59925
             sage: UK.log(unit)
             [13, 6, 7, 8, 9, 10]
diff -r f77808909c54 -r 8a361e1b884e sage/rings/polynomial/multi_polynomial_element.py
--- a/sage/rings/polynomial/multi_polynomial_element.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/polynomial/multi_polynomial_element.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1424,14 +1424,13 @@
         ALGORITHM: Use univariate factorization code.
         
         If a polynomial is univariate, the appropriate univariate
-        factorization code is called.
-        
-        ::
+        factorization code is called::
         
             sage: R.<z> = PolynomialRing(CC,1)
             sage: f = z^4 - 6*z + 3
             sage: f.factor()
-            (z - 1.60443920904349) * (z - 0.511399619393097) * (z + 1.05791941421830 - 1.59281852704435*I) * (z + 1.05791941421830 + 1.59281852704435*I)
+            (z - 1.60443920904349 - 2.91339356278998e-26*I) * (z - 0.511399619393097 + 6.96082630860956e-26*I) * (z + 1.05791941421830 - 1.59281852704435*I) * (z + 1.05791941421830 + 1.59281852704435*I)  # 32-bit
+            (z - 1.60443920904349) * (z - 0.511399619393097) * (z + 1.05791941421830 - 1.59281852704435*I) * (z + 1.05791941421830 + 1.59281852704435*I)  # 64-bit
 
         TESTS:
 
diff -r f77808909c54 -r 8a361e1b884e sage/rings/polynomial/polynomial_element.pyx
--- a/sage/rings/polynomial/polynomial_element.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/polynomial/polynomial_element.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -2397,19 +2397,15 @@
         
         EXAMPLES:
 
-        We factor some polynomials over `\QQ`.
-        
-        ::
+        We factor some polynomials over `\QQ`::
         
             sage: x = QQ['x'].0
             sage: f = (x^3 - 1)^2
             sage: f.factor()
             (x - 1)^2 * (x^2 + x + 1)^2
         
-        Notice that over the field `\QQ` the irreducible
-        factors are monic.
-        
-        ::
+        Notice that over the field `\QQ` the irreducible factors are
+        monic::
         
             sage: f = 10*x^5 - 1
             sage: f.factor()
@@ -2418,8 +2414,7 @@
             sage: f.factor()
             (10) * (x - 1) * (x^4 + x^3 + x^2 + x + 1)
         
-        Over `\ZZ` the irreducible factors need not be
-        monic::
+        Over `\ZZ` the irreducible factors need not be monic::
         
             sage: x = ZZ['x'].0
             sage: f = 10*x^5 - 1
@@ -2427,9 +2422,7 @@
             10*x^5 - 1
         
         We factor a non-monic polynomial over the finite field
-        `F_{25}`.
-        
-        ::
+        `F_{25}`::
         
             sage: k.<a> = GF(25)
             sage: R.<x> = k[]
@@ -2437,51 +2430,12 @@
             sage: F = f.factor(); F
             (2) * (x + a + 2) * (x^2 + 3*x + 4*a + 4) * (x^2 + (a + 1)*x + a + 2) * (x^5 + (3*a + 4)*x^4 + (3*a + 3)*x^3 + 2*a*x^2 + (3*a + 1)*x + 3*a + 1)
         
-        Notice that the unit factor is included when we multiply
-        `F` back out.
-        
-        ::
+        Notice that the unit factor is included when we multiply `F`
+        back out::
         
             sage: expand(F)
             2*x^10 + 2*x + 2*a
         
-        Factorization also works even if the variable of the finite field
-        is nefariously labeled "x".
-        
-        ::
-        
-            sage: x = GF(3^2, 'a')['x'].0
-            sage: f = x^10 +7*x -13
-            sage: G = f.factor(); G
-            (x + a) * (x + 2*a + 1) * (x^4 + (a + 2)*x^3 + (2*a + 2)*x + 2) * (x^4 + 2*a*x^3 + (a + 1)*x + 2)
-            sage: prod(G) == f
-            True
-        
-        ::
-        
-            sage: f.parent().base_ring()._assign_names(['a'])
-            sage: f.factor()
-            (x + a) * (x + 2*a + 1) * (x^4 + (a + 2)*x^3 + (2*a + 2)*x + 2) * (x^4 + 2*a*x^3 + (a + 1)*x + 2)
-        
-        ::
-        
-            sage: k = GF(9,'x')    # purposely calling it x to test robustness
-            sage: x = PolynomialRing(k,'x0').gen()
-            sage: f = x^3 + x + 1
-            sage: f.factor()
-            (x0 + 2) * (x0 + x) * (x0 + 2*x + 1)
-            sage: f = 0*x
-            sage: f.factor()
-            Traceback (most recent call last):
-            ...
-            ValueError: factorization of 0 not defined
-        
-        ::
-        
-            sage: f = x^0
-            sage: f.factor()
-            1
-        
         Arbitrary precision real and complex factorization::
         
             sage: R.<x> = RealField(100)[]
@@ -2506,6 +2460,155 @@
             sage: expand(F)
             I*x^2 + I
         
+        Over a number field::
+        
+            sage: K.<z> = CyclotomicField(15)
+            sage: x = polygen(K)
+            sage: f = (x^3 + z*x + 1)^3*(x - z); f.factor()
+            (x - z) * (x^3 + z*x + 1)^3
+            sage: cyclotomic_polynomial(12).change_ring(K).factor()
+            (x^2 - z^5 - 1) * (x^2 + z^5)
+            sage: f = (x^3 + z*x + 1)^3*(x/(z+2) - 1/3); f.factor()
+            (-1/331*z^7 + 3/331*z^6 - 6/331*z^5 + 11/331*z^4 - 21/331*z^3 + 41/331*z^2 - 82/331*z + 165/331) * (x - 1/3*z - 2/3) * (x^3 + z*x + 1)^3
+            
+        Over a relative number field::
+        
+            sage: x = polygen(QQ)
+            sage: K.<z> = CyclotomicField(3)
+            sage: L.<a> = K.extension(x^3 - 2)
+            sage: x = polygen(L)
+            sage: f = (x^3 + x + a)*(x^5 + x + z); f
+            x^8 + x^6 + a*x^5 + x^4 + z*x^3 + x^2 + (a + z)*x + z*a
+            sage: f.factor()
+            (x^3 + x + a) * (x^5 + x + z)
+        
+        Over the real double field::
+        
+            sage: x = polygen(RDF)
+            sage: f = (x-1)^3
+            sage: f.factor() # random output (unfortunately)
+            (1.0*x - 1.00000859959) * (1.0*x^2 - 1.99999140041*x + 0.999991400484)
+            sage: (-2*x^2 - 1).factor() 
+            (-2.0) * (x^2 + 0.5)
+            sage: (-2*x^2 - 1).factor().expand() 
+            -2.0*x^2 - 1.0             
+        
+        Note that this factorization suffers from the roots function::
+        
+            sage: f.roots() # random output (unfortunately)
+            [1.00000859959, 0.999995700205 + 7.44736245561e-06*I, 0.999995700205 - 7.44736245561e-06*I]
+        
+        Over the complex double field. Because this is approximate, all
+        factors will occur with multiplicity 1::
+        
+            sage: x = CDF['x'].0; i = CDF.0
+            sage: f = (x^2 + 2*i)^3
+            sage: f.factor()    # random low order bits
+            (1.0*x + -0.999994409957 + 1.00001040378*I) * (1.0*x + -0.999993785062 + 0.999989956987*I) * (1.0*x + -1.00001180498 + 0.999999639235*I) * (1.0*x + 0.999995530902 - 0.999987780431*I) * (1.0*x + 1.00001281704 - 1.00000223945*I) * (1.0*x + 0.999991652054 - 1.00000998012*I)
+            sage: f(-f.factor()[0][0][0])   # random low order bits
+            -2.38358052913e-14 - 2.57571741713e-14*I
+        
+        Factoring polynomials over `\ZZ/n\ZZ` for
+        composite `n` is not implemented::
+        
+            sage: R.<x> = PolynomialRing(Integers(35))
+            sage: f = (x^2+2*x+2)*(x^2+3*x+9)
+            sage: f.factor()
+            Traceback (most recent call last):
+            ...
+            NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
+        
+        Factoring polynomials over QQbar and AA is implemented (see #8544)::
+
+            sage: x = polygen(QQbar)
+            sage: (x^8-1).factor()
+            (x - 1) * (x - 0.7071067811865475? - 0.7071067811865475?*I) * (x - 0.7071067811865475? + 0.7071067811865475?*I) * (x - I) * (x + I) * (x + 0.7071067811865475? - 0.7071067811865475?*I) * (x + 0.7071067811865475? + 0.7071067811865475?*I) * (x + 1)
+            sage: (12*x^2-4).factor()
+            (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?)
+            sage: x.parent()(-1).factor()
+            -1
+            sage: EllipticCurve('11a1').change_ring(QQbar).division_polynomial(5).factor()
+            (5) * (x - 16) * (x - 5) * (x - 1.959674775249769?) * (x - 1.427050983124843? - 3.665468789467727?*I) * (x - 1.427050983124843? + 3.665468789467727?*I) * (x + 0.9549150281252629? - 0.8652998037182486?*I) * (x + 0.9549150281252629? + 0.8652998037182486?*I) * (x + 1.927050983124843? - 1.677599044300515?*I) * (x + 1.927050983124843? + 1.677599044300515?*I) * (x + 2.959674775249769?) * (x + 6.545084971874737? - 7.106423590645660?*I) * (x + 6.545084971874737? + 7.106423590645660?*I)
+
+        ::
+
+            sage: x = polygen(AA)
+            sage: (x^8+1).factor()
+            (x^2 - 1.847759065022574?*x + 1.000000000000000?) * (x^2 - 0.7653668647301795?*x + 1.000000000000000?) * (x^2 + 0.7653668647301795?*x + 1.000000000000000?) * (x^2 + 1.847759065022574?*x + 1.000000000000000?)
+            sage: x.parent()(3).factor()
+            3
+            sage: (12*x^2-4).factor()
+            (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?)
+            sage: (12*x^2+4).factor()
+            (12) * (x^2 + 0.3333333333333334?)
+            sage: EllipticCurve('11a1').change_ring(AA).division_polynomial(5).factor()
+            (5) * (x - 16.00000000000000?) * (x - 5.000000000000000?) * (x - 1.959674775249769?) * (x + 2.959674775249769?) * (x^2 - 2.854101966249685?*x + 15.47213595499958?) * (x^2 + 1.909830056250526?*x + 1.660606461254312?) * (x^2 + 3.854101966249685?*x + 6.527864045000421?) * (x^2 + 13.09016994374948?*x + 93.33939353874569?)
+
+        TESTS:
+        
+        This came up in ticket #7088::
+        
+            sage: R.<x>=PolynomialRing(ZZ)
+            sage: f = 12*x^10 + x^9 + 432*x^3 + 9011
+            sage: g = 13*x^11 + 89*x^3 + 1
+            sage: F = f^2 * g^3
+            sage: F = f^2 * g^3; F.factor()
+            (12*x^10 + x^9 + 432*x^3 + 9011)^2 * (13*x^11 + 89*x^3 + 1)^3
+            sage: F = f^2 * g^3 * 7; F.factor()
+            7 * (12*x^10 + x^9 + 432*x^3 + 9011)^2 * (13*x^11 + 89*x^3 + 1)^3
+
+        This example came up in ticket #7097::
+
+            sage: x = polygen(QQ)
+            sage: f = 8*x^9 + 42*x^6 + 6*x^3 - 1
+            sage: g = x^24 - 12*x^23 + 72*x^22 - 286*x^21 + 849*x^20 - 2022*x^19 + 4034*x^18 - 6894*x^17 + 10182*x^16 - 13048*x^15 + 14532*x^14 - 13974*x^13 + 11365*x^12 - 7578*x^11 + 4038*x^10 - 1766*x^9 + 762*x^8 - 408*x^7 + 236*x^6 - 126*x^5 + 69*x^4 - 38*x^3 + 18*x^2 - 6*x + 1
+            sage: assert g.is_irreducible()
+            sage: K.<a> = NumberField(g)
+            sage: len(f.roots(K))
+            9
+            sage: f.factor()
+            (8) * (x^3 + 1/4) * (x^6 + 5*x^3 - 1/2)
+            sage: f.change_ring(K).factor()
+            (8) * (x - 3260097/3158212*a^22 + 35861067/3158212*a^21 - 197810817/3158212*a^20 + 722970825/3158212*a^19 - 1980508347/3158212*a^18 + 4374189477/3158212*a^17 - 4059860553/1579106*a^16 + 6442403031/1579106*a^15 - 17542341771/3158212*a^14 + 20537782665/3158212*a^13 - 20658463789/3158212*a^12 + 17502836649/3158212*a^11 - 11908953451/3158212*a^10 + 6086953981/3158212*a^9 - 559822335/789553*a^8 + 194545353/789553*a^7 - 505969453/3158212*a^6 + 338959407/3158212*a^5 - 155204647/3158212*a^4 + 79628015/3158212*a^3 - 57339525/3158212*a^2 + 26692783/3158212*a - 1636338/789553) * ...
+            sage: f = QQbar['x'](1)
+            sage: f.factor()
+            1
+
+        Factorization also works even if the variable of the finite
+        field is nefariously labeled "x"::
+        
+            sage: x = GF(3^2, 'a')['x'].0
+            sage: f = x^10 +7*x -13
+            sage: G = f.factor(); G
+            (x + a) * (x + 2*a + 1) * (x^4 + (a + 2)*x^3 + (2*a + 2)*x + 2) * (x^4 + 2*a*x^3 + (a + 1)*x + 2)
+            sage: prod(G) == f
+            True
+        
+        ::
+        
+            sage: f.parent().base_ring()._assign_names(['a'])
+            sage: f.factor()
+            (x + a) * (x + 2*a + 1) * (x^4 + (a + 2)*x^3 + (2*a + 2)*x + 2) * (x^4 + 2*a*x^3 + (a + 1)*x + 2)
+        
+        ::
+        
+            sage: k = GF(9,'x')    # purposely calling it x to test robustness
+            sage: x = PolynomialRing(k,'x0').gen()
+            sage: f = x^3 + x + 1
+            sage: f.factor()
+            (x0 + 2) * (x0 + x) * (x0 + 2*x + 1)
+            sage: f = 0*x
+            sage: f.factor()
+            Traceback (most recent call last):
+            ...
+            ValueError: factorization of 0 not defined
+        
+        ::
+        
+            sage: f = x^0
+            sage: f.factor()
+            1
+        
         Over a complicated number field::
         
             sage: x = polygen(QQ, 'x')
@@ -2538,109 +2641,6 @@
             sage: h = A(x^2-1/3) ; h.factor()
             (T - a) * (T + a)
         
-        Over the real double field::
-        
-            sage: x = polygen(RDF)
-            sage: f = (x-1)^3
-            sage: f.factor() # random output (unfortunately)
-            (1.0*x - 1.00000859959) * (1.0*x^2 - 1.99999140041*x + 0.999991400484)
-            sage: (-2*x^2 - 1).factor() 
-            (-2.0) * (x^2 + 0.5)
-            sage: (-2*x^2 - 1).factor().expand() 
-            -2.0*x^2 - 1.0             
-        
-        Note that this factorization suffers from the roots function::
-        
-            sage: f.roots() # random output (unfortunately)
-            [1.00000859959, 0.999995700205 + 7.44736245561e-06*I, 0.999995700205 - 7.44736245561e-06*I]
-        
-        Over the complex double field. Because this is approximate, all
-        factors will occur with multiplicity 1.
-        
-        ::
-        
-            sage: x = CDF['x'].0; i = CDF.0
-            sage: f = (x^2 + 2*i)^3
-            sage: f.factor()    # random low order bits
-            (1.0*x + -0.999994409957 + 1.00001040378*I) * (1.0*x + -0.999993785062 + 0.999989956987*I) * (1.0*x + -1.00001180498 + 0.999999639235*I) * (1.0*x + 0.999995530902 - 0.999987780431*I) * (1.0*x + 1.00001281704 - 1.00000223945*I) * (1.0*x + 0.999991652054 - 1.00000998012*I)
-            sage: f(-f.factor()[0][0][0])   # random low order bits
-            -2.38358052913e-14 - 2.57571741713e-14*I
-        
-        Over a relative number field::
-        
-            sage: x = QQ['x'].0
-            sage: L.<a> = CyclotomicField(3).extension(x^3 - 2)
-            sage: x = L['x'].0
-            sage: f = (x^3 + x + a)*(x^5 + x + L.1); f
-            x^8 + x^6 + a*x^5 + x^4 + zeta3*x^3 + x^2 + (a + zeta3)*x + zeta3*a
-            sage: f.factor()
-            (x^3 + x + a) * (x^5 + x + zeta3)
-        
-        Factoring polynomials over `\ZZ/n\ZZ` for
-        composite `n` is not implemented::
-        
-            sage: R.<x> = PolynomialRing(Integers(35))
-            sage: f = (x^2+2*x+2)*(x^2+3*x+9)
-            sage: f.factor()
-            Traceback (most recent call last):
-            ...
-            NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented
-        
-        Factoring polynomials over QQbar and AA is implemented (see #8544)::
-
-            sage: x = polygen(QQbar)
-            sage: (x^8-1).factor()
-            (x - 1) * (x - 0.7071067811865475? - 0.7071067811865475?*I) * (x - 0.7071067811865475? + 0.7071067811865475?*I) * (x - I) * (x + I) * (x + 0.7071067811865475? - 0.7071067811865475?*I) * (x + 0.7071067811865475? + 0.7071067811865475?*I) * (x + 1)
-            sage: (12*x^2-4).factor()
-            (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?)
-            sage: x.parent()(-1).factor()
-            -1
-            sage: EllipticCurve('11a1').change_ring(QQbar).division_polynomial(5).factor()
-            (5) * (x - 16) * (x - 5) * (x - 1.959674775249769?) * (x - 1.427050983124843? - 3.665468789467727?*I) * (x - 1.427050983124843? + 3.665468789467727?*I) * (x + 0.9549150281252629? - 0.8652998037182486?*I) * (x + 0.9549150281252629? + 0.8652998037182486?*I) * (x + 1.927050983124843? - 1.677599044300515?*I) * (x + 1.927050983124843? + 1.677599044300515?*I) * (x + 2.959674775249769?) * (x + 6.545084971874737? - 7.106423590645660?*I) * (x + 6.545084971874737? + 7.106423590645660?*I)
-
-        ::
-
-            sage: x = polygen(AA)
-            sage: (x^8+1).factor()
-            (x^2 - 1.847759065022574?*x + 1.000000000000000?) * (x^2 - 0.7653668647301795?*x + 1.000000000000000?) * (x^2 + 0.7653668647301795?*x + 1.000000000000000?) * (x^2 + 1.847759065022574?*x + 1.000000000000000?)
-            sage: x.parent()(3).factor()
-            3
-            sage: (12*x^2-4).factor()
-            (12) * (x - 0.5773502691896258?) * (x + 0.5773502691896258?)
-            sage: (12*x^2+4).factor()
-            (12) * (x^2 + 0.3333333333333334?)
-            sage: EllipticCurve('11a1').change_ring(AA).division_polynomial(5).factor()
-            (5) * (x - 16.00000000000000?) * (x - 5.000000000000000?) * (x - 1.959674775249769?) * (x + 2.959674775249769?) * (x^2 - 2.854101966249685?*x + 15.47213595499958?) * (x^2 + 1.909830056250526?*x + 1.660606461254312?) * (x^2 + 3.854101966249685?*x + 6.527864045000421?) * (x^2 + 13.09016994374948?*x + 93.33939353874569?)
-
-        TESTS:
-        
-        This came up in ticket #7088::
-        
-            sage: R.<x>=PolynomialRing(ZZ)
-            sage: f = 12*x^10 + x^9 + 432*x^3 + 9011
-            sage: g = 13*x^11 + 89*x^3 + 1
-            sage: F = f^2 * g^3
-            sage: F = f^2 * g^3; F.factor()
-            (12*x^10 + x^9 + 432*x^3 + 9011)^2 * (13*x^11 + 89*x^3 + 1)^3
-            sage: F = f^2 * g^3 * 7; F.factor()
-            7 * (12*x^10 + x^9 + 432*x^3 + 9011)^2 * (13*x^11 + 89*x^3 + 1)^3
-
-        This example came up in ticket #7097:
-
-            sage: x = polygen(QQ)
-            sage: f = 8*x^9 + 42*x^6 + 6*x^3 - 1
-            sage: g = x^24 - 12*x^23 + 72*x^22 - 286*x^21 + 849*x^20 - 2022*x^19 + 4034*x^18 - 6894*x^17 + 10182*x^16 - 13048*x^15 + 14532*x^14 - 13974*x^13 + 11365*x^12 - 7578*x^11 + 4038*x^10 - 1766*x^9 + 762*x^8 - 408*x^7 + 236*x^6 - 126*x^5 + 69*x^4 - 38*x^3 + 18*x^2 - 6*x + 1
-            sage: assert g.is_irreducible()
-            sage: K.<a> = NumberField(g)
-            sage: len(f.roots(K))
-            9
-            sage: f.factor()
-            (8) * (x^3 + 1/4) * (x^6 + 5*x^3 - 1/2)
-            sage: f.change_ring(K).factor()
-            (8) * (x - 3260097/3158212*a^22 + 35861067/3158212*a^21 - 197810817/3158212*a^20 + 722970825/3158212*a^19 - 1980508347/3158212*a^18 + 4374189477/3158212*a^17 - 4059860553/1579106*a^16 + 6442403031/1579106*a^15 - 17542341771/3158212*a^14 + 20537782665/3158212*a^13 - 20658463789/3158212*a^12 + 17502836649/3158212*a^11 - 11908953451/3158212*a^10 + 6086953981/3158212*a^9 - 559822335/789553*a^8 + 194545353/789553*a^7 - 505969453/3158212*a^6 + 338959407/3158212*a^5 - 155204647/3158212*a^4 + 79628015/3158212*a^3 - 57339525/3158212*a^2 + 26692783/3158212*a - 1636338/789553) * ...
-            sage: f = QQbar['x'](1)
-            sage: f.factor()
-            1
         """
         # PERFORMANCE NOTE:
         #     In many tests with SMALL degree PARI is substantially
@@ -3692,7 +3692,7 @@
             sage: pari(f)
             Traceback (most recent call last):
             ...
-            PariError: (8)
+            PariError: (5)
         
         Stacked polynomial rings, first with a univariate ring on the
         bottom::
@@ -3730,7 +3730,7 @@
             sage: pari(x^2 + 2*x)
             Mod(1, 8)*x^2 + Mod(2, 8)*x
             sage: pari(a*x + 10*x^3)
-            Mod(2, 8)*x^3 + (Mod(1, 8)*a)*x
+            Mod(2, 8)*x^3 + Mod(1, 8)*a*x
         """
         return self._pari_with_name(self.parent().variable_name())
         
@@ -3887,7 +3887,7 @@
             sage: f.resultant(g)
             Traceback (most recent call last):
             ...
-            PariError: (8)
+            PariError: (5)
         """
         variable = self.parent().gen()._pari_()
         # The 0 flag tells PARI to use exact arithmetic        
@@ -3972,7 +3972,7 @@
             sage: f.discriminant()
             Traceback (most recent call last):
             ...
-            PariError: (8)
+            PariError: (5)
         """
         n = self.degree()
         d = self.derivative()
@@ -4305,6 +4305,13 @@
             sage: p.roots(ring=CIF)
             [(-1.414213562373095?, 1), (1.414213562373095?, 1), (-1.214638932244183? - 0.141425052582394?*I, 2), (-0.141425052582394? + 1.214638932244183?*I, 2), (0.141425052582394? - 1.214638932244183?*I, 2), (1.214638932244183? + 0.141425052582394?*I, 2)]
         
+        We can also find roots over number fields:
+
+            sage: K.<z> = CyclotomicField(15)
+            sage: R.<x> = PolynomialRing(K)
+            sage: (x^2 + x + 1).roots()
+            [(z^5, 1), (-z^5 - 1, 1)]
+
         There are many combinations of floating-point input and output
         types that work. (Note that some of them are quite pointless...
         there's no reason to use high-precision input and output, and still
diff -r f77808909c54 -r 8a361e1b884e sage/rings/polynomial/polynomial_integer_dense_flint.pyx
--- a/sage/rings/polynomial/polynomial_integer_dense_flint.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/polynomial/polynomial_integer_dense_flint.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -1166,9 +1166,9 @@
         p = Integer(p)
         if not p.is_prime():
             raise ValueError, "p must be prime"
+        if all([c%p==0 for c in self.coefficients()]):
+            raise ValueError, "factorization of 0 not defined"
         f = self._pari_()
-        if f * pari('Mod(1,%s)'%p) == pari(0):
-            raise ValueError, "factorization of 0 not defined"
         G = f.factormod(p)
         k = FiniteField(p)
         R = k[self.parent().variable_name()]
diff -r f77808909c54 -r 8a361e1b884e sage/rings/polynomial/polynomial_integer_dense_ntl.pyx
--- a/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/polynomial/polynomial_integer_dense_ntl.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -980,9 +980,9 @@
         p = Integer(p)
         if not p.is_prime():
             raise ValueError, "p must be prime"
+        if all([c%p==0 for c in self.coefficients()]):
+            raise ValueError, "factorization of 0 not defined"
         f = self._pari_()
-        if f * pari('Mod(1,%s)'%p) == pari(0):
-            raise ValueError, "factorization of 0 not defined"
         G = f.factormod(p)
         k = FiniteField(p)
         R = k[self.parent().variable_name()]
diff -r f77808909c54 -r 8a361e1b884e sage/rings/polynomial/polynomial_quotient_ring.py
--- a/sage/rings/polynomial/polynomial_quotient_ring.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/polynomial/polynomial_quotient_ring.py	Mon Aug 16 15:43:27 2010 +0200
@@ -668,17 +668,13 @@
             sage: R.<x> = K[]
             sage: S.<xbar> = R.quotient(x^2 + 23)
             sage: S.S_class_group([])
-            [((3, -3*a, 3/2*xbar - 3/2, (-1/2*a + 1)*xbar - 1/2*a + 1),
-              6,
-              (1/2*a - 101/2)*xbar + 187/2*a + 67/2)]
+            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
             sage: S.S_class_group([K.ideal(3, a-1)])
             []
             sage: S.S_class_group([K.ideal(2, a+1)])
             []
             sage: S.S_class_group([K.ideal(a)])
-            [((3, -3*a, 3/2*xbar - 3/2, (-1/2*a + 1)*xbar - 1/2*a + 1),
-              6,
-              (1/2*a - 101/2)*xbar + 187/2*a + 67/2)]
+            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
 
         Now we take an example over a nontrivial base with two factors, each
         contributing to the class group::
@@ -687,40 +683,13 @@
             sage: R.<x> = K[]
             sage: S.<xbar> = R.quotient((x^2 + 23)*(x^2 + 31))
             sage: S.S_class_group([])
-            [((3/8*xbar^2 + 93/8,
-               -3/8*a*xbar^2 - 93/8*a, 3/16*xbar^3 - 3/16*xbar^2 + 93/16*xbar - 93/16,
-               (-1/16*a + 1/8)*xbar^3 + (-1/16*a + 1/8)*xbar^2 + (-31/16*a + 31/8)*xbar - 31/16*a + 31/8),
-              6,
-              (1/16*a - 101/16)*xbar^3 + (187/16*a + 65/16)*xbar^2 + (31/16*a - 3131/16)*xbar + 5797/16*a + 2031/16),
-             ((-1/4*xbar^2 - 23/4,
-               (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
-               -1/16*xbar^3 ...xbar^2 - 23/16*xbar ...,
-               1/16*a*xbar^3 ...xbar^2 + 23/16*a*xbar ...),
-              6,
-              1/16*xbar^3 + 1/16*xbar^2 + 23/16*xbar + 39/16),
-             ((-5/4*xbar^2 - 115/4,
-               5/4*a*xbar^2 + 115/4*a,
-               -5/16*xbar^3 - 5/16*xbar^2 - 115/16*xbar - 115/16,   
-               1/16*a*xbar^3 + 13/16*a*xbar^2 + 23/16*a*xbar + 299/16*a),
-              2,
-              5/16*xbar^3 - 33/16*xbar^2 + 115/16*xbar - 743/16)]   
+            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, 1/16*xbar^3 - 5/16*xbar^2 + 31/16*xbar - 139/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 6, -1/16*xbar^3 + 1/16*xbar^2 - 23/16*xbar + 39/16), ((-5/4*xbar^2 - 115/4, 5/4*a*xbar^2 + 115/4*a, -5/16*xbar^3 + 5/16*xbar^2 - 115/16*xbar + 115/16, 1/16*a*xbar^3 + 7/16*a*xbar^2 + 23/16*a*xbar + 161/16*a), 2, -5/16*xbar^3 - 33/16*xbar^2 - 115/16*xbar - 743/16)]
 
         By using the ideal `(a)`, we cut the part of the class group coming from
         `x^2 + 31` from 12 to 2, i.e. we lose a generator of order 6::
         
             sage: S.S_class_group([K.ideal(a)])
-            [((3/8*xbar^2 + 93/8,
-               -3/8*a*xbar^2 - 93/8*a,
-               3/16*xbar^3 - 3/16*xbar^2 + 93/16*xbar - 93/16,
-               (-1/16*a + 1/8)*xbar^3 + (-1/16*a + 1/8)*xbar^2 + (-31/16*a + 31/8)*xbar - 31/16*a + 31/8),
-              6,
-              (...1/16*a ... 101/16)*xbar^3 + (...187/16*a ...)*xbar^2 + (...31/16*a ... 3131/16)*xbar ... 5797/16*a ...),
-             ((-1/4*xbar^2 - 23/4,
-               (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
-               -1/16*xbar^3 ...,
-               1/16*a*xbar^3 ...),
-              2,
-              -1/8*xbar^2 - 15/8)]
+            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, 1/16*xbar^3 - 5/16*xbar^2 + 31/16*xbar - 139/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 2, -1/8*xbar^2 - 15/8)]
 
         Note that all the returned values live where we expect them to::
         
@@ -788,9 +757,7 @@
             sage: R.<x> = K[]
             sage: S.<xbar> = R.quotient(x^2 + 23)
             sage: S.class_group()
-            [((3, -3*a, 3/2*xbar - 3/2, (-1/2*a + 1)*xbar - 1/2*a + 1),
-              6,
-              (1/2*a - 101/2)*xbar + 187/2*a + 67/2)]
+            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
         
         Here is an example of a product of number fields, both of which
         contribute to the class group::
@@ -798,14 +765,7 @@
             sage: R.<x> = QQ[]
             sage: S.<xbar> = R.quotient((x^2 + 23)*(x^2 + 47))
             sage: S.class_group()
-            [((1/12*xbar^2 + 47/12,
-               1/48*xbar^3 - 1/48*xbar^2 + 47/48*xbar - 47/48),
-              3,
-              -1/48*xbar^3 - 5/48*xbar^2 - 47/48*xbar - 187/48),
-             ((-1/12*xbar^2 - 23/12,
-               -1/48*xbar^3 - ...xbar^2 - 23/48*xbar - ...),
-              5,
-              -1/48*xbar^3 ...xbar^2 - 23/48*xbar ...)]
+            [((1/12*xbar^2 + 47/12, 1/48*xbar^3 - 1/48*xbar^2 + 47/48*xbar - 47/48), 3, -1/48*xbar^3 - 5/48*xbar^2 - 47/48*xbar - 187/48), ((-1/12*xbar^2 - 23/12, -1/48*xbar^3 - 1/48*xbar^2 - 23/48*xbar - 23/48), 5, 1/48*xbar^3 + 11/48*xbar^2 + 23/48*xbar + 301/48)]
 
         Now we take an example over a nontrivial base with two factors, each
         contributing to the class group::
@@ -814,23 +774,7 @@
             sage: R.<x> = K[]
             sage: S.<xbar> = R.quotient((x^2 + 23)*(x^2 + 31))
             sage: S.class_group()
-            [((3/8*xbar^2 + 93/8,
-               -3/8*a*xbar^2 - 93/8*a, 3/16*xbar^3 - 3/16*xbar^2 + 93/16*xbar - 93/16,
-               (-1/16*a + 1/8)*xbar^3 + (-1/16*a + 1/8)*xbar^2 + (-31/16*a + 31/8)*xbar - 31/16*a + 31/8),
-              6,
-              (1/16*a - 101/16)*xbar^3 + (187/16*a + 65/16)*xbar^2 + (31/16*a - 3131/16)*xbar + 5797/16*a + 2031/16),
-             ((-1/4*xbar^2 - 23/4,
-               (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8,
-               -1/16*xbar^3 ...,
-               1/16*a*xbar^3 ...),
-              6,
-              1/16*xbar^3 + 1/16*xbar^2 + 23/16*xbar + 39/16),
-             ((-5/4*xbar^2 - 115/4,
-               5/4*a*xbar^2 + 115/4*a,
-               -5/16*xbar^3 - 5/16*xbar^2 - 115/16*xbar - 115/16,  
-               1/16*a*xbar^3 + 13/16*a*xbar^2 + 23/16*a*xbar + 299/16*a),
-              2,
-              5/16*xbar^3 - 33/16*xbar^2 + 115/16*xbar - 743/16)]
+            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6, 1/16*xbar^3 - 5/16*xbar^2 + 31/16*xbar - 139/16), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 6, -1/16*xbar^3 + 1/16*xbar^2 - 23/16*xbar + 39/16), ((-5/4*xbar^2 - 115/4, 5/4*a*xbar^2 + 115/4*a, -5/16*xbar^3 + 5/16*xbar^2 - 115/16*xbar + 115/16, 1/16*a*xbar^3 + 7/16*a*xbar^2 + 23/16*a*xbar + 161/16*a), 2, -5/16*xbar^3 - 33/16*xbar^2 - 115/16*xbar - 743/16)]
 
         Note that all the returned values live where we expect them to::
         
@@ -884,21 +828,11 @@
             sage: L.<b> = K['y'].quotient(y^3 + 5); L
             Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5
             sage: L.S_units([])
-            [(-1/2*a + 1/2, 6),
-             ((...1/3*a - 1)*b^2 + ...*b + ...*a + ..., +Infinity),
-             ((...1/3*a + 1)*b^2 ...*b ...*a ..., +Infinity)]
+            [(-1/2*a + 1/2, 6), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a - 1/2, +Infinity)]
             sage: L.S_units([K.ideal(1/2*a - 3/2)])
-            [((...1/6*a - 1/2)*b^2 + (...1/3*a + 1)*b ... 2/3*a - 2, +Infinity),
-             (-1/2*a + 1/2, 6),
-             ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity),
-             ((...1/3*a ... 1)*b^2 + (...2/3*a - 2)*b + ...*a + ..., +Infinity)]
+            [(-1/3*a*b^2 + 2/3*a*b - 4/3*a, +Infinity), (-1/2*a + 1/2, 6), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a - 1/2, +Infinity)]
             sage: L.S_units([K.ideal(2)])
-            [((...*a ... 1/2)*b^2 + (...a ... 1)*b + ...*a ... 3/2, +Infinity),
-             ((1/6*a + 1/2)*b^2 + (-1/3*a - 1)*b + 1/6*a + 3/2, +Infinity),
-             ((...*a + 1/2)*b^2 + (...a - 1)*b ...*a + ..., +Infinity),
-             (-1/2*a + 1/2, 6),
-             ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity),
-             ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity)]   
+            [((1/6*a - 1/2)*b^2 + (-1/3*a + 1)*b + 1/6*a - 3/2, +Infinity), ((-1/6*a + 1/2)*b^2 + (1/3*a - 1)*b - 2/3*a + 1, +Infinity), ((1/2*a + 1/2)*b^2 + (-a - 1)*b + 3/2*a + 3/2, +Infinity), (-1/2*a + 1/2, 6), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a - 1/2, +Infinity)]
 
         Note that all the returned values live where we expect them to::
         
@@ -948,16 +882,12 @@
             sage: L.<b> = K['y'].quotient(y^3 + 5); L
             Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5
             sage: L.units()
-            [(-1/2*a + 1/2, 6),
-             ((...1/3*a - 1)*b^2 + ...*b + ...*a + ..., +Infinity),
-             ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)]
+            [(-1/2*a + 1/2, 6), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, +Infinity), ((-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a - 1/2, +Infinity)]
             sage: L.<b> = K.extension(y^3 + 5)
             sage: L.unit_group()
             Unit group with structure C6 x Z x Z of Number Field in b with defining polynomial x^3 + 5 over its base field
             sage: L.unit_group().gens()
-            [-1/2*a + 1/2,
-             (...1/3*a - 1)*b^2 + ...*b + ...*a + ...,
-             (-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2]
+            [-1/2*a + 1/2, (-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a + 1/2, (-1/3*a - 1)*b^2 + (2/3*a - 2)*b + 13/6*a - 1/2]
 
         Note that all the returned values live where we expect them to::
         
@@ -1139,7 +1069,8 @@
             sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
             [2, -a - 1]
             sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
-            [2, -a - 1, -a]
+            [2, -a - 1, a]   # 32-bit
+            [2, -a - 1, -a]  # 64-bit
 
         """
         units, clgp_gens = self._S_class_group_and_units(tuple(S), proof=proof)
@@ -1350,8 +1281,7 @@
             [2.9757207403766761469671194565, -2.4088994371613850098316292196 + 1.9025410530350528612407363802*I, -2.4088994371613850098316292196 - 1.9025410530350528612407363802*I, 0.92103906697304693634806949137 - 3.0755331188457794473265418086*I, 0.92103906697304693634806949137 + 3.0755331188457794473265418086*I]
         """
         CC = sage.rings.complex_field.ComplexField(prec)
-        f = self.modulus().base_extend(CC)
-        v = f.roots(multiplicities=False)
+        v = self.modulus().roots(multiplicities=False, ring=CC)
         return [self.hom([a], check=False) for a in v]
     
     
diff -r f77808909c54 -r 8a361e1b884e sage/rings/qqbar.py
--- a/sage/rings/qqbar.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/qqbar.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1046,7 +1046,7 @@
         sage: do_polred(x^2-5)
         (-1/2*x + 1/2, -2*x + 1, x^2 - x - 1)
         sage: do_polred(x^2-x-11)
-        (-1/3*x + 2/3, -3*x + 2, x^2 - x - 1)
+        (1/3*x + 1/3, 3*x - 1, x^2 - x - 1)
         sage: do_polred(x^3 + 123456)
         (-1/4*x, -4*x, x^3 - 1929)
     """
@@ -1315,10 +1315,10 @@
 
         sage: (fld,nums,hom) = number_field_elements_from_algebraics((rt2, rt3, qqI, z3))
         sage: fld,nums,hom
-        (Number Field in a with defining polynomial y^8 - y^4 + 1, [-a^5 + a^3 + a, a^6 - 2*a^2, a^6, -a^4], Ring morphism:
-            From: Number Field in a with defining polynomial y^8 - y^4 + 1
-            To:   Algebraic Field
-            Defn: a |--> -0.2588190451025208? - 0.9659258262890683?*I)
+        (Number Field in a with defining polynomial y^8 - y^4 + 1, [-a^5 + a^3 + a, a^6 - 2*a^2, -a^6, a^4 - 1], Ring morphism:
+        From: Number Field in a with defining polynomial y^8 - y^4 + 1
+        To:   Algebraic Field
+        Defn: a |--> -0.2588190451025208? + 0.9659258262890683?*I)
         sage: (nfrt2, nfrt3, nfI, nfz3) = nums
         sage: hom(nfrt2)
         1.414213562373095? + 0.?e-18*I
@@ -1331,7 +1331,7 @@
         sage: nfI^2
         -1
         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
-        2*a^6 - a^5 - a^4 + a^3 - 2*a^2 + a
+        -a^5 + a^4 + a^3 - 2*a^2 + a - 1
         sage: hom(sum)
         2.646264369941973? + 1.866025403784439?*I
         sage: hom(sum) == rt2 + rt3 + qqI + z3
@@ -1362,8 +1362,7 @@
         (Number Field in a with defining polynomial y^4 + 2*y^2 + 4, 1/2*a^3, Ring morphism:
             From: Number Field in a with defining polynomial y^4 + 2*y^2 + 4
             To:   Algebraic Field
-            Defn: a |--> -0.7071067811865475? + 1.224744871391589?*I) # 32-bit
-            Defn: a |--> -0.7071067811865475? - 1.224744871391589?*I) # 64-bit
+            Defn: a |--> -0.7071067811865475? - 1.224744871391589?*I)
         sage: number_field_elements_from_algebraics(rt2c, minimal=True)
         (Number Field in a with defining polynomial y^2 - 2, a, Ring morphism:
             From: Number Field in a with defining polynomial y^2 - 2
@@ -1650,9 +1649,6 @@
         # XXX need more caching here
         newpol, self_pol, k = pari_nf.rnfequation(my_factor, 1)
         k = int(k)
-        # print newpol
-        # print self_pol
-        # print k
 
         newpol_sage = QQx(newpol)
         newpol_sage_y = QQy(newpol_sage)
@@ -2665,7 +2661,7 @@
             sage: QQbar(2)._exact_field()
             Trivial generator
             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 3.789313782671036?
+            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
             sage: (QQbar(7)^(3/5))._exact_field()
             Number Field in a with defining polynomial y^5 - 7 with a in 1.475773161594552?
         """
@@ -2686,7 +2682,7 @@
             sage: QQbar(2)._exact_value()
             2
             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
-            1/9*a^3 + a^2 - 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in 3.789313782671036?
+            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
             sage: (QQbar(7)^(3/5))._exact_value()
             a^3 where a^5 - 7 = 0 and a in 1.475773161594552?
         """
@@ -5674,7 +5670,10 @@
 
     def exactify(self):
         """
-        TESTS:
+        TESTS::
+
+            sage: rt2c = QQbar.zeta(3) + AA(sqrt(2)) - QQbar.zeta(3)
+            sage: rt2c.exactify()
         
         We check to make sure that this method still works even.  We
         do this by increasing the recursion level at each step and
diff -r f77808909c54 -r 8a361e1b884e sage/rings/real_mpfr.pyx
--- a/sage/rings/real_mpfr.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/real_mpfr.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -2569,9 +2569,7 @@
         
         The current Pari precision affects the printing of this number, but
         Pari does maintain the same 250-bit number on both 32-bit and
-        64-bit platforms.
-        
-        ::
+        64-bit platforms::
         
             sage: RealField(250).pi()._pari_()
             3.14159265358979
@@ -2590,9 +2588,16 @@
             128                                        # 64-bit
             sage: for i in xrange(1, 1000):
             ...       assert(RR(i).sqrt() == RR(i).sqrt()._pari_().python())
-        """
-        # return sage.libs.pari.all.pari.new_with_bits_prec(str(self), (<RealField_class>self._parent).__prec)
-
+
+        TESTS:
+
+        Check that we create real zeros without mantissa::
+
+            sage: RDF(0)._pari_().sizeword()
+            2
+            sage: RealField(100)(0.0)._pari_().sizeword()
+            2
+        """
         # This uses interfaces of MPFR and Pari which are documented
         # (and not marked subject-to-change).  It could be faster
         # by using internal interfaces of MPFR, which are documented
@@ -2601,12 +2606,8 @@
         if mpfr_nan_p(self.value) or mpfr_inf_p(self.value):
             raise ValueError, 'Cannot convert NaN or infinity to Pari float'
 
-        cdef int wordsize
-
-        if sage.misc.misc.is_64_bit:
-            wordsize = 64
-        else:
-            wordsize = 32
+        # wordsize for PARI
+        cdef unsigned long wordsize = sizeof(long)*8
 
         cdef int prec
         prec = (<RealField_class>self._parent).__prec
@@ -2619,33 +2620,28 @@
         if rounded_prec > prec:
             self = RealField(rounded_prec)(self)
 
-        # Now we can extract the mantissa, and it will be normalized
-        # (the most significant bit of the most significant word will be 1).
         cdef mpz_t mantissa
         cdef mp_exp_t exponent
-        mpz_init(mantissa)
-
-        exponent = mpfr_get_z_exp(mantissa, self.value)
-
         cdef GEN pari_float
-        pari_float = cgetr(2 + rounded_prec / wordsize)
-
-        mpz_export(&pari_float[2], NULL, 1, wordsize/8, 0, 0, mantissa)
 
         if mpfr_zero_p(self.value):
-            setexpo(pari_float, -rounded_prec)
-        else:
+            pari_float = real_0_bit(-rounded_prec)
+        else:
+            # Now we can extract the mantissa, and it will be normalized
+            # (the most significant bit of the most significant word will be 1).
+            mpz_init(mantissa)
+            exponent = mpfr_get_z_exp(mantissa, self.value)
+            
+            # Create a PARI REAL
+            pari_float = cgetr(2 + rounded_prec / wordsize)
+            mpz_export(&pari_float[2], NULL, 1, wordsize/8, 0, 0, mantissa)
+            mpz_clear(mantissa)
             setexpo(pari_float, exponent + rounded_prec - 1)
-        setsigne(pari_float, mpfr_sgn(self.value))
-
+            setsigne(pari_float, mpfr_sgn(self.value))
+        
         cdef PariInstance P
         P = sage.libs.pari.all.pari
-        
-        gen = P.new_gen(pari_float)
-
-        mpz_clear(mantissa)
-
-        return gen
+        return P.new_gen(pari_float)
 
     def _mpmath_(self, prec=None, rounding=None):
         """
diff -r f77808909c54 -r 8a361e1b884e sage/rings/residue_field.pyx
--- a/sage/rings/residue_field.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/rings/residue_field.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -408,15 +408,15 @@
 
         EXAMPLES:
             sage: I = QQ[2^(1/3)].factor(2)[0][0]; I
-            Fractional ideal (-a)
+            Fractional ideal (a)
             sage: k = I.residue_field(); k
-            Residue field of Fractional ideal (-a)
+            Residue field of Fractional ideal (a)
             sage: pi = k.reduction_map(); pi 
-            Partially defined reduction map from Number Field in a with defining polynomial x^3 - 2 to Residue field of Fractional ideal (-a)
+            Partially defined reduction map from Number Field in a with defining polynomial x^3 - 2 to Residue field of Fractional ideal (a)
             sage: pi.domain()
             Number Field in a with defining polynomial x^3 - 2
             sage: pi.codomain()
-            Residue field of Fractional ideal (-a)
+            Residue field of Fractional ideal (a)
         """
         return self._structure[0]
 
@@ -424,13 +424,13 @@
         """
         EXAMPLES:
             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
-            Fractional ideal (-a + 2)
+            Fractional ideal (a - 2)
             sage: k = I.residue_field(); k
-            Residue field of Fractional ideal (-a + 2)
+            Residue field of Fractional ideal (a - 2)
             sage: f = k.lift_map(); f
-            Lifting map from Residue field of Fractional ideal (-a + 2) to Number Field in a with defining polynomial x^3 - 3
+            Lifting map from Residue field of Fractional ideal (a - 2) to Number Field in a with defining polynomial x^3 - 3
             sage: f.domain()
-            Residue field of Fractional ideal (-a + 2)
+            Residue field of Fractional ideal (a - 2)
             sage: f.codomain()
             Number Field in a with defining polynomial x^3 - 3
             sage: f(k.0)
@@ -446,9 +446,10 @@
         EXAMPLES:
             sage: K.<a> = NumberField(x^3-11)
             sage: F = K.ideal(37).factor(); F
-            (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9))
-            sage: k =K.residue_field(F[0][0])
-            sage: l =K.residue_field(F[1][0])
+            (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9))  # 32-bit
+            (Fractional ideal (37, a + 12)) * (Fractional ideal  (2*a - 5)) * (Fractional ideal (37, a + 9))  # 64-bit
+            sage: k = K.residue_field(F[0][0])
+            sage: l = K.residue_field(F[1][0])
             sage: k == l
             False
         """
@@ -520,7 +521,7 @@
             sage: K.<a> = NumberField(x^3 + 128)
             sage: F = K.factor(2)[0][0].residue_field()
             sage: F.reduction_map().codomain()
-            Residue field of Fractional ideal (-1/4*a)        
+            Residue field of Fractional ideal (1/4*a)        
         """
         return self.__F
 
@@ -547,11 +548,10 @@
         has been fixed.
             sage: K.<i> = NumberField(x^2 + 1)
             sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2)
-            (Fractional ideal (-i - 2), Fractional ideal (2*i + 1))
+            (Fractional ideal (i + 2), Fractional ideal (-i + 2))
             sage: a = 1/(1+2*i)
             sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2) 
-            (Residue field of Fractional ideal (-i - 2),
-            Residue field of Fractional ideal (2*i + 1))
+            (Residue field of Fractional ideal (i + 2), Residue field of Fractional ideal (-i + 2))
             sage: a.valuation(P1)
             0
             sage: F1(i/7)
@@ -562,7 +562,7 @@
             -1
             sage: F2(a)
             Traceback (most recent call last):
-            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (2*i + 1): it has negative valuation        
+            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (-i + 2): it has negative valuation
 
         """
         # The reduction map is just x |--> F(to_vs(x) * (PB**(-1))) if
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/cm.py
--- a/sage/schemes/elliptic_curves/cm.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/cm.py	Mon Aug 16 15:43:27 2010 +0200
@@ -128,7 +128,6 @@
     prec =  c2*RR(3.142)*RR(D).abs().sqrt() + h*c1  # bound on log
     prec = prec * 1.45   # bound on log_2 (1/log(2) = 1.44..)
     prec = 10 + prec.ceil()  # allow for rounding error
-#    print "prec = ",prec
 
     # set appropriate precision for further computing 
 
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_finite_field.py
--- a/sage/schemes/elliptic_curves/ell_finite_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_finite_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -37,8 +37,6 @@
 import sage.rings.ring as ring
 from sage.rings.all import Integer, ZZ, PolynomialRing, ComplexField, FiniteField, GF, polygen
 from sage.rings.finite_rings.all import is_FiniteFieldElement
-import gp_cremona
-import sea
 from sage.groups.all import AdditiveAbelianGroup
 import sage.groups.generic as generic
 import ell_point
@@ -120,29 +118,6 @@
         self.__pari = pari('ellinit(Mod(1,%s)*%s)'%(F.characteristic(), [b._pari_() for b in self.ainvs()]))
         return self.__pari
 
-    def _gp(self):
-        """
-        Return an elliptic curve in a GP/PARI interpreter with all
-        Cremona's code for finite fields preloaded. This includes
-        generators, which will vary from run to run.
-        
-        The base field must have prime order.
-        
-        EXAMPLES::
-        
-            sage: EllipticCurve(GF(41),[2,5])._gp()
-            [Mod(0, 41), Mod(0, 41), Mod(0, 41), Mod(2, 41), Mod(5, 41), Mod(0, 41), Mod(4, 41), Mod(20, 41), Mod(37, 41), Mod(27, 41), Mod(26, 41), Mod(4, 41), Mod(11, 41), 44, [2, 2; 11, 1], [22, 2], ...
-        """
-        try:
-            return self.__gp
-        except AttributeError:
-            pass
-        F = self.base_ring()
-        if not F.is_prime_field():
-            raise NotImplementedError
-        self.__gp = gp_cremona.ellinit(list(self.a_invariants()), F.characteristic())
-        return self.__gp
-
     def plot(self, *args, **kwds):
         """
         Draw a graph of this elliptic curve over a prime finite field.
@@ -796,27 +771,18 @@
            only for point counting over prime fields
         
             -  ``'heuristic'`` - use a heuristic to choose between
-               pari, bsgs and sea.
+               pari and bsgs.
 
-            -  ``'pari'`` - use the baby step giant step method as
-               implemented in PARI via the C-library function ellap.
-
-            -  ``'sea'`` - use sea.gp as implemented in PARI by
-               Christophe Doche and Sylvain Duquesne.  ('sea' stands
-               for 'Schoof-Elkies-Atkin'.)
+            - ``'pari'`` - use the baby step giant step or SEA methods
+               as implemented in PARI via the C-library function ellap.
 
             -  ``bsgs`` - use the baby step giant step method as
                implemented in Sage, with the Cremona -
                Sutherland version of Mestre's trick.
 
-            - ``all`` - (over prime fields only) compute
-              cardinality with all of pari, sea and
-              bsgs; return result if they agree or raise
-              a RuntimeError if they do not.
-        
-        -  ``early_abort`` - bool (default: False); this is
-           used only by sea. if True, stop early if a small factor of the
-           order is found.
+            - ``all`` - (over prime fields only) compute cardinality
+              with all of pari and bsgs; return result if they agree
+              or raise a RuntimeError if they do not.
         
         -  ``extension_degree`` - int (default: 1); if the
            base field is `k=GF(p^n)` and extension_degree=d, returns
@@ -860,23 +826,28 @@
         
             sage: EllipticCurve(GF(10007),[1,2,3,4,5]).cardinality()
             10076
-            sage: EllipticCurve(GF(10007),[1,2,3,4,5]).cardinality(algorithm='sea')
-            10076
             sage: EllipticCurve(GF(10007),[1,2,3,4,5]).cardinality(algorithm='pari')
             10076
-            sage: EllipticCurve(GF(next_prime(10**20)),[1,2,3,4,5]).cardinality(algorithm='sea')
+            sage: EllipticCurve(GF(next_prime(10**20)),[1,2,3,4,5]).cardinality()
             100000000011093199520
         
         The cardinality is cached::
         
             sage: E = EllipticCurve(GF(3^100,'a'),[1,2,3,4,5])
             sage: E.cardinality() is E.cardinality()
-            True        
+            True
             sage: E=EllipticCurve(GF(11^2,'a'),[3,3])
             sage: E.cardinality()
             128
             sage: EllipticCurve(GF(11^100,'a'),[3,3]).cardinality()
             137806123398222701841183371720896367762643312000384671846835266941791510341065565176497846502742959856128
+
+        TESTS::
+
+            sage: EllipticCurve(GF(10007),[1,2,3,4,5]).cardinality(algorithm='foobar')
+            Traceback (most recent call last):
+            ...
+            ValueError: Algorithm is not known
         """
         if extension_degree>1:
             # A recursive call to cardinality() with
@@ -916,24 +887,23 @@
 
         if d == 1:
             if algorithm == 'heuristic':
-                algorithm = 'sea' if p > 10**18 else 'pari'
+                algorithm = 'pari'
             if algorithm == 'pari':
                 N = self.cardinality_pari()
             elif algorithm == 'sea':
-                N = self.cardinality_sea()
+                N = self.cardinality_pari()  # purely for backwards compatibility
             elif algorithm == 'bsgs':
                 N = self.cardinality_bsgs()
             elif algorithm == 'all':
                 N1 = self.cardinality_pari()
-                N2 = self.cardinality_sea()
-                N3 = self.cardinality_bsgs()
-                if N1 == N2 and N2 == N3:
+                N2 = self.cardinality_bsgs()
+                if N1 == N2:
                     N = N1
                 else:
                     if N1!=N2:
-                        raise RuntimeError, "BUG! Cardinality with pari=%s but with sea=%s"%(N1, N2)
-                    if N1!=N3:
-                        raise RuntimeError, "BUG! Cardinality with pari=%s but with bsgs=%s"%(N1, N3)
+                        raise RuntimeError, "BUG! Cardinality with pari=%s but with bsgs=%s"%(N1, N2)
+            else:
+                raise ValueError, "Algorithm is not known"
             self._order = Integer(N)
             return self._order
 
@@ -1114,50 +1084,6 @@
         else:
             raise ValueError, "cardinality_pari() only works over prime fields."
 
-    def cardinality_sea(self, early_abort=False):
-        r"""
-        Return the cardinality of self over the (prime) base field using sea.
-
-        INPUT:
-
-        - ``early_abort`` - bool (default: False).  if True, an early
-          abort technique is used and the computation is interrupted
-          as soon as a small divisor of the order is detected.  The
-          function then returns 0.  This is useful for ruling out
-          curves whose cardinality is divisible by a small prime.
-
-        The result is not cached.
-        
-        EXAMPLES::
-        
-            sage: p=next_prime(10^3)
-            sage: E=EllipticCurve(GF(p),[3,4])
-            sage: E.cardinality_sea()
-            1020
-            sage: K=GF(next_prime(10^6))
-            sage: E=EllipticCurve(K,[1,0,0,1,1])
-            sage: E.cardinality_sea()
-            999945
-            
-        TESTS::
-        
-            sage: K.<a>=GF(3^20)
-            sage: E=EllipticCurve(K,[1,0,0,1,a])
-            sage: E.cardinality_sea()
-            Traceback (most recent call last):
-            ...
-            ValueError: cardinality_sea() only works over prime fields.
-            sage: E.cardinality()
-            3486794310
-
-        """
-        k = self.base_ring()
-        p = k.characteristic()
-        if k.degree()==1:
-            return sea.ellsea(list(self.a_invariants()), p, early_abort=early_abort)
-        else:
-            raise ValueError, "cardinality_sea() only works over prime fields."
-
     def cardinality_bsgs(self, verbose=False):
         r"""
         Return the cardinality of self over the base field. Will be called
@@ -1520,8 +1446,8 @@
                 N=self.cardinality_exhaustive()
             elif d==1:
                 if debug:
-                    print "Computing group order using SEA"
-                N=self.cardinality(algorithm='sea')
+                    print "Computing group order using PARI"
+                N=self.cardinality()
             else:
                 if debug:
                     print "Computing group order using bsgs"
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_local_data.py
--- a/sage/schemes/elliptic_curves/ell_local_data.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_local_data.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1005,7 +1005,7 @@
         sage: check_prime(K,a+1)
         Fractional ideal (a + 1)
         sage: [check_prime(K,P) for P in K.primes_above(31)]
-        [Fractional ideal (-5/2*a - 1/2), Fractional ideal (-5/2*a + 1/2)]
+        [Fractional ideal (5/2*a + 1/2), Fractional ideal (5/2*a - 1/2)]
     """
     if K is QQ:
         if isinstance(P, (int,long,Integer)):
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_number_field.py
--- a/sage/schemes/elliptic_curves/ell_number_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_number_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -237,19 +237,12 @@
             A = 0
             B = Mod(1, y^2 + 7)
             C = Mod(y, y^2 + 7)
-            LS2gen = [Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y - 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
+            LS2gen = [Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
             #LS2gen = 2
-            Recherche de points triviaux sur la courbe 
+            Recherche de points triviaux sur la courbe
             points triviaux sur la courbe = [[1, 1, 0], [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]]
             zc = Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
             symbole de Hilbert (Mod(2, y^2 + 7),Mod(-5, y^2 + 7)) = -1
-            zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y - 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
-            symbole de Hilbert (Mod(-2*y + 2, y^2 + 7),Mod(1, y^2 + 7)) = 0
-            sol de Legendre = [1, 0, 1]~
-            zc*z1^2 = Mod(Mod(2*y - 2, y^2 + 7)*x + Mod(2*y + 10, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
-            quartique : (-1/2*y + 1/2)*Y^2 = x^4 + (-3*y - 15)*x^2 + (-8*y - 16)*x + (-11/2*y - 15/2)
-            reduite: Y^2 = (-1/2*y + 1/2)*x^4 - 4*x^3 + (-3*y + 3)*x^2 + (2*y - 2)*x + (1/2*y + 3/2)
-            non ELS en [2, [0, 1]~, 1, 1, [1, 1]~]
             zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
             vient du point trivial [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]
             m1 = 1
@@ -336,22 +329,13 @@
 
             sage: K.<i> = QuadraticField(-1)
             sage: E = EllipticCurve([0,0,0,i,i])
-            sage: P, Q = E.simon_two_descent()[2]
+            sage: P = E(-9+4*i,-18-25*i)
+            sage: Q = E(i,-i)
             sage: E.height_pairing_matrix([P,Q])
-            [0.770335599645036 0.440758796326832]
-            [0.440758796326832  2.16941934493768]
+            [  2.16941934493768 -0.870059380421505]
+            [-0.870059380421505  0.424585837470709]
             sage: E.regulator_of_points([P,Q])
-            1.47691263542463
-
-        ::
-
-            sage: K.<i> = QuadraticField(-1)
-            sage: E = EllipticCurve([0,0,0,i,i])
-            sage: P, Q = E.simon_two_descent()[2]
-            sage: E.height_pairing_matrix([P,Q])
-            [0.770335599645036 0.440758796326832]
-            [0.440758796326832  2.16941934493768]
-
+            0.164101403936070
         """
         if points is None:
             points = self.gens()
@@ -461,9 +445,13 @@
 
             sage: K.<i> = QuadraticField(-1)
             sage: E = EllipticCurve([0,0,0,i,i])
-            sage: P, Q = E.simon_two_descent()[2]
+            sage: P = E(-9+4*i,-18-25*i)
+            sage: Q = E(i,-i)
+            sage: E.height_pairing_matrix([P,Q])
+            [  2.16941934493768 -0.870059380421505]
+            [-0.870059380421505  0.424585837470709]
             sage: E.regulator_of_points([P,Q])
-            1.47691263542463
+            0.164101403936070
 
         """
         if points is None:
@@ -679,14 +667,14 @@
             sage: K.<i> = NumberField(x^2+1)
             sage: E = EllipticCurve([1 + i, 0, 1, 0, 0])
             sage: E.local_data()
-            [Local data at Fractional ideal (2*i + 1):
+            [Local data at Fractional ideal (-i + 2):
             Reduction type: bad non-split multiplicative
             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
             Minimal discriminant valuation: 1
             Conductor exponent: 1
             Kodaira Symbol: I1
             Tamagawa Number: 1, 
-            Local data at Fractional ideal (-3*i - 2):
+            Local data at Fractional ideal (-2*i + 3):
             Reduction type: bad split multiplicative
             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
             Minimal discriminant valuation: 2
@@ -1171,10 +1159,8 @@
             sage: K.<a>=NumberField(x^2-5)
             sage: E=EllipticCurve([20, 225, 750, 625*a + 6875, 31250*a + 46875])
             sage: bad_primes = E.discriminant().support(); bad_primes
-            [Fractional ideal (-a),
-            Fractional ideal (7/2*a - 81/2),
-            Fractional ideal (a + 52),
-            Fractional ideal (2)]
+            [Fractional ideal  (a), Fractional ideal (7/2*a - 81/2), Fractional ideal (-a - 52), Fractional ideal (2)]  # 32-bit
+            [Fractional ideal (-a), Fractional ideal (7/2*a - 81/2), Fractional ideal (-a - 52), Fractional ideal (2)]  # 64-bit
             sage: [E.kodaira_symbol(P) for P in bad_primes]
             [I0, I1, I1, II]
             sage: K.<a> = QuadraticField(-11)
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_padic_field.py
--- a/sage/schemes/elliptic_curves/ell_padic_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_padic_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -85,7 +85,7 @@
         sage: E._pari_()
         Traceback (most recent call last):
         ...
-        PariError:  (8)
+        PariError:  (5)
         """
         try:
             return self.__pari
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_point.py
--- a/sage/schemes/elliptic_curves/ell_point.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_point.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1540,8 +1540,8 @@
             sage: P = E(26,-120)
             sage: E.discriminant().support()
             [Fractional ideal (i + 1),
-            Fractional ideal (-i - 2),
-            Fractional ideal (2*i + 1),
+            Fractional ideal (i + 2),
+            Fractional ideal (-i + 2),
             Fractional ideal (3)]
             sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()]
             [1, 4, 4, 4]
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/ell_rational_field.py
--- a/sage/schemes/elliptic_curves/ell_rational_field.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/ell_rational_field.py	Mon Aug 16 15:43:27 2010 +0200
@@ -56,14 +56,12 @@
 import ell_torsion
 import formal_group
 import heegner
-import gp_cremona
 from   gp_simon import simon_two_descent
 from   lseries_ell import Lseries_ell
 import mod5family
 from   modular_parametrization import ModularParameterization
 import padic_lseries
 import padics
-import sea
 
 import sage.modular.modform.constructor
 import sage.modular.modform.element
@@ -788,45 +786,16 @@
             11
             sage: E.Np(11)
             11
+
+        This even works when the prime is large::
+        
+            sage: E = EllipticCurve('37a')
+            sage: E.Np(next_prime(10^30))
+            1000000000000001426441464441649
         """
         if self.conductor() % p == 0:
             return p + 1 - self.ap(p)
-        #raise ArithmeticError, "p (=%s) must be a prime of good reduction"%p
-        if p < 1125899906842624:   # TODO: choose more wisely?
-            return p+1 - self.ap(p)
-        else:
-            return self.sea(p)
-
-    def sea(self, p, early_abort=False):
-        r"""
-        Return the number of points on `E` over
-        `\GF{p}` computed using the SEA algorithm, as
-        implemented in PARI by Christophe Doche and Sylvain Duquesne.
-        
-        INPUT:
-        
-        
-        -  ``p`` - a prime number
-        
-        -  ``early_abort`` - bool (default: False); if True an
-           early abort technique is used and the computation is interrupted as
-           soon as a small divisor of the order is detected.
-        
-        
-        .. note::
-
-           As of 2006-02-02 this function does not work on Microsoft
-           Windows under Cygwin (though it works under VMWare of
-           course).
-        
-        EXAMPLES::
-        
-            sage: E = EllipticCurve('37a')
-            sage: E.sea(next_prime(10^30))
-            1000000000000001426441464441649
-        """
-        p = rings.Integer(p)
-        return sea.ellsea(list(self.minimal_model().a_invariants()), p, early_abort=early_abort)
+        return p+1 - self.ap(p)
 
     #def __pari_double_prec(self):
     #    EllipticCurve_number_field._EllipticCurve__pari_double_prec(self)
@@ -1303,19 +1272,19 @@
         """
         return self.q_expansion(prec)
     
-    def analytic_rank(self, algorithm="cremona"):
+    def analytic_rank(self, algorithm="pari", leading_coefficient=False):
         r"""
         Return an integer that is *probably* the analytic rank of this
-        elliptic curve.
-        
-        INPUT:
-
+        elliptic curve.  If leading_coefficient is ``True`` (only implemented
+        for pari), return a tuple `(rank, lead)` where `lead` is the value of
+        the first non-zero derivative of the L-function of the elliptic
+        curve.
+        
+        INPUT:
+        
         - algorithm -
         
-          - 'cremona' (default) - Use the Buhler-Gross algorithm as
-            implemented in GP by Tom Womack and John Cremona, who note
-            that their implementation is practical for any rank and
-            conductor `\leq 10^{10}` in 10 minutes.
+          - 'pari' (default) - use the pari library function.
         
           - 'sympow' -use Watkins's program sympow
         
@@ -1342,7 +1311,7 @@
         EXAMPLES::
         
             sage: E = EllipticCurve('389a')
-            sage: E.analytic_rank(algorithm='cremona')
+            sage: E.analytic_rank(algorithm='pari')
             2
             sage: E.analytic_rank(algorithm='rubinstein')
             2
@@ -1353,6 +1322,21 @@
             sage: E.analytic_rank(algorithm='all')
             2
 
+        With the optional parameter leading_coefficient set to ``True``, a
+        tuple of both the analytic rank and the leading term of the
+        L-series at `s = 1` is returned::
+
+            sage: EllipticCurve([0,-1,1,-10,-20]).analytic_rank(leading_coefficient=True)
+            (0, 0.25384186085591068...)
+            sage: EllipticCurve([0,0,1,-1,0]).analytic_rank(leading_coefficient=True)
+            (1, 0.30599977383405230...)
+            sage: EllipticCurve([0,1,1,-2,0]).analytic_rank(leading_coefficient=True)
+            (2, 1.518633000576853...)
+            sage: EllipticCurve([0,0,1,-7,6]).analytic_rank(leading_coefficient=True)
+            (3, 10.39109940071580...)
+            sage: EllipticCurve([0,0,1,-7,36]).analytic_rank(leading_coefficient=True)
+            (4, 196.170903794579...)
+
         TESTS:
 
         When the input is horrendous, some of the algorithms just bomb out with a RuntimeError::
@@ -1366,84 +1350,42 @@
             ...
             RuntimeError: failed to compute analytic rank
         """
-        if algorithm == 'cremona':
-            return rings.Integer(gp_cremona.ellanalyticrank(list(self.minimal_model().a_invariants())))
+        if algorithm == 'pari':
+            rank_lead = self.pari_curve().ellanalyticrank()
+            if leading_coefficient:
+                return (rings.Integer(rank_lead[0]), rank_lead[1].python())
+            else:
+                return rings.Integer(self.pari_curve().ellanalyticrank()[0])
         elif algorithm == 'rubinstein':
+            if leading_coefficient:
+                raise NotImplementedError, "Cannot compute leading coefficient using rubinstein algorithm"
             try:
                 from sage.lfunctions.lcalc import lcalc
                 return lcalc.analytic_rank(L=self)
             except TypeError,msg:
                 raise RuntimeError, "unable to compute analytic rank using rubinstein algorithm ('%s')"%msg
         elif algorithm == 'sympow':
+            if leading_coefficient:
+                raise NotImplementedError, "Cannot compute leading coefficient using sympow"
             from sage.lfunctions.sympow import sympow
             return sympow.analytic_rank(self)[0]
         elif algorithm == 'magma':
+            if leading_coefficient:
+                raise NotImplementedError, "Cannot compute leading coefficient using magma"
             from sage.interfaces.all import magma
             return rings.Integer(magma(self).AnalyticRank())
         elif algorithm == 'all':
-            S = list(set([self.analytic_rank('cremona'), 
-                     self.analytic_rank('rubinstein'), self.analytic_rank('sympow')]))
+            if leading_coefficient:
+                S = set([self.analytic_rank('pari', True)])
+            else:
+                S = set([self.analytic_rank('pari'),
+                    self.analytic_rank('rubinstein'), self.analytic_rank('sympow')])
             if len(S) != 1:
-                raise RuntimeError, "Bug in analytic rank; algorithms don't agree! (E=%s)"%E
-            return S[0]
+                raise RuntimeError, "Bug in analytic_rank; algorithms don't agree! (E=%s)"%E
+            return list(S)[0]
         else:
             raise ValueError, "algorithm %s not defined"%algorithm
-            
-    def p_isogenous_curves(self, p=None):
-        r"""
-        Return a list of pairs `(p, L)` where `p` is a
-        prime and `L` is a list of the elliptic curves over
-        `\QQ` that are `p`-isogenous to this
-        elliptic curve.
-        
-        INPUT:
-        
-        
-        -  ``p`` - prime or None (default: None); if a prime,
-           returns a list of the p-isogenous curves. Otherwise, returns a list
-           of all prime-degree isogenous curves sorted by isogeny degree.
-        
-        
-        This is implemented using Cremona's GP script
-        ``allisog.gp``.
-        
-        EXAMPLES::
-        
-            sage: E = EllipticCurve([0,-1,0,-24649,1355209])   
-            sage: E.p_isogenous_curves()
-            [(2, [Elliptic Curve defined by y^2  = x^3 - x^2 - 91809*x - 9215775 over Rational Field, Elliptic Curve defined by y^2  = x^3 - x^2 - 383809*x + 91648033 over Rational Field, Elliptic Curve defined by y^2  = x^3 - x^2 + 1996*x + 102894 over Rational Field])]
-        
-        The isogeny class of the curve 11a2 has three curves in it. But
-        ``p_isogenous_curves`` only returns one curves, since
-        there is only one curve `5`-isogenous to 11a2.
-        
-        ::
-        
-            sage: E = EllipticCurve('11a2')
-            sage: E.p_isogenous_curves()
-            [(5, [Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field])]
-            sage: E.p_isogenous_curves(5)
-            [Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field]
-            sage: E.p_isogenous_curves(3)
-            []
-        
-        In contrast, the curve 11a1 admits two `5`-isogenies::
-        
-            sage: E = EllipticCurve('11a1')
-            sage: E.p_isogenous_curves(5)
-            [Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field,
-             Elliptic Curve defined by y^2 + y = x^3 - x^2 over Rational Field]
-        """
-        if p is None:
-            X = eval(gp_cremona.allisog(list(self.minimal_model().a_invariants())))
-            Y = [(p, [constructor.EllipticCurve(ainvs) for ainvs in L]) for p, L in X]
-            Y.sort()
-            return Y
-        else:
-            X = eval(gp_cremona.p_isog(list(self.minimal_model().a_invariants()), p))
-            Y = [constructor.EllipticCurve(ainvs) for ainvs in X]
-            Y.sort()
-            return Y
+
 
     def simon_two_descent(self, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30):
         r"""
@@ -1535,7 +1477,7 @@
             sage: E = EllipticCurve([0, 0, 1, -79, 342])
             sage: set_random_seed(0)
             sage: E.simon_two_descent()
-            (5, 5, [(5 : 8 : 1), (3 : 11 : 1), (17/4 : 69/8 : 1), (33/4 : -131/8 : 1), (33 : 183 : 1)])
+            (5, 5, [(5 : 8 : 1), (4 : 9 : 1), (3 : 11 : 1), (-1 : 20 : 1), (-6 : -25 : 1)])
             sage: E = EllipticCurve([1, 1, 0, -2582, 48720])
             sage: set_random_seed(0)
             sage: r, s, G = E.simon_two_descent(); r,s
@@ -2903,10 +2845,10 @@
             sage: P = E([0,2])
             sage: z = P.elliptic_logarithm() # default precision is 100 here
             sage: E.elliptic_exponential(z)
-            (-7.4445166...e-30 : 2.0000000000000000000000000000 : 1.0000000000000000000000000000)
+            (...e-30 : 2.0000000000000000000000000000 : 1.0000000000000000000000000000)
             sage: z = E([0,2]).elliptic_logarithm(precision=200)
             sage: E.elliptic_exponential(z)
-            (-1.07731...e-60 : 2.0000000000000000000000000000000000000000000000000000000000 : 1.0000000000000000000000000000000000000000000000000000000000)
+            (...e-60 : 2.0000000000000000000000000000000000000000000000000000000000 : 1.0000000000000000000000000000000000000000000000000000000000)
 
         ::
 
@@ -2918,7 +2860,7 @@
             sage: P.elliptic_logarithm()
             0.47934825019021931612953301006 + 0.98586885077582410221120384908*I
             sage: E.elliptic_exponential(P.elliptic_logarithm())
-            (-1.0000000000000000000000000000 + 4.3761255...e-31*I : 1.0000000000000000000000000000 - 1.4587084969798853407242847702e-31*I : 1.0000000000000000000000000000)
+            (-1.0000000000000000000000000000 + ...e-31*I : 1.0000000000000000000000000000 - ...e-31*I : 1.0000000000000000000000000000)
 
 
         Some torsion examples::
@@ -5071,8 +5013,8 @@
             sage: Pi = E.gens(); Pi
             [(-4 : 1 : 1), (-3 : 5 : 1), (-11/4 : 43/8 : 1), (-2 : 6 : 1)]
             sage: Qi, U = E.lll_reduce(Pi)
-            sage: Qi
-            [(0 : 6 : 1), (1 : -7 : 1), (-4 : 1 : 1), (-3 : 5 : 1)]
+            sage: sorted(Qi)
+            [(-4 : 1 : 1), (-3 : 5 : 1), (-2 : 6 : 1), (0 : 6 : 1)]
             sage: U.det()
             1
             sage: E.regulator_of_points(Pi)
@@ -5110,7 +5052,7 @@
             sage: points = [E.lift_x(x) for x in xi]
             sage: newpoints, U = E.lll_reduce(points) # long time (2m)
             sage: [P[0] for P in newpoints]           # long time
-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
         """
         r = len(points)
         if height_matrix is None:
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/gp_cremona.py
--- a/sage/schemes/elliptic_curves/gp_cremona.py	Sat Aug 14 18:53:26 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-"""
-Cremona PARI Scripts
-
-Access to Cremona's PARI scripts via Sage.
-"""
-
-#*****************************************************************************
-#       Copyright (C) 2005 William Stein <wstein@gmail.com>
-#
-#  Distributed under the terms of the GNU General Public License (GPL)
-#
-#    This code is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#    General Public License for more details.
-#
-#  The full text of the GPL is available at:
-#
-#                  http://www.gnu.org/licenses/
-#*****************************************************************************
-
-from sage.interfaces.gp import Gp
-from sage.rings.all import Integer, RealField
-from sage.misc.randstate import current_randstate
-from sage.misc.misc import verbose
-R = RealField()
-
-gp = None
-def init():
-    """
-    Function to initialize the gp process
-    """
-    global gp
-    if gp is None:
-        gp = Gp(script_subdirectory='cremona')
-        gp.read("bgc.gp")
-        gp.read("ell_baby.gp")
-        gp.read("ell_ff.gp")
-        gp.read("ell_weil.gp")
-        gp.read("ell_zp.gp")
-        gp.eval('debug_group=0;')
-
-def ellanalyticrank_prec(e,prec=None):
-    """
-    Try to compute analytic rank with precision set to prec.
-    
-    INPUT:
-        e -- five-tuple of integers that define a minimal Weierstrass equation
-    OUTPUT:
-        integer -- the ("computed") analytic rank r of E
-
-    ALGORITHM:
-        Uses Cremona's gp script
-
-    NOTE:
-        Users are commended to use EllipticCurve(ai).analytic_rank() instead.
-
-    EXAMPLES:
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank_prec([0,-1,1,-10,-20])
-        0
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank_prec([0,0,1,-1,0])
-        1
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank_prec([0,1,1,-2,0])
-        2
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank_prec([0,0,1,-7,6])
-        3
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank_prec([0,0,1,-7,36])
-        4
-    """
-    init()
-    if prec: old_prec = gp.set_real_precision(prec)
-    cmd = "ellanalyticrank(ellinit(%s),0)"%e
-    x = gp.eval(cmd)
-    if prec: gp.set_real_precision(old_prec)
-    if x.find("***") != -1:
-        raise RuntimeError, "error '%s' running '%s'"%(x,cmd)
-    return Integer(x)
-
-def ellanalyticrank(e):
-    """
-    Try to compute analytic rank.
-    
-    INPUT:
-        e -- five-tuple of integers that define a minimal Weierstrass equation
-
-    OUTPUT:
-        integer -- the ("computed") analytic rank r of E
-
-    ALGORITHM:
-        Uses Cremona's gp script
-
-    NOTE:
-        Users are commended to use EllipticCurve(ai).analytic_rank() instead.
-
-    EXAMPLES:
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellanalyticrank([0,-1,1,-10,-20])
-        0
-    """
-    prec = 16
-    while True: 
-        try:
-            return ellanalyticrank_prec(e, prec)
-        except RuntimeError,msg:
-            if 'precision too low' in str(msg):
-                prec *= 2
-            else:
-                raise    
-
-def ellzp(e, p):
-    """
-    INPUT:
-        e -- five-tuple of integers that define an elliptic curve over Z/pZ
-        p -- prime
-    OUTPUT:
-        A string containing information about the elliptic curve
-        modulo p: group structure and generators.
-
-    NOTE: This is an internal function used in the function
-    _abelian_group_data() for curves over finite (prime) field.  Users
-    should instead use higher-level functions -- see examples.
-
-    WARNING: The algorithm uses random points, so the generators in
-    the second part of the output will vary from run to run.
-
-    EXAMPLES:
-        sage: import sage.schemes.elliptic_curves.gp_cremona
-        sage: sage.schemes.elliptic_curves.gp_cremona.ellzp([0,0,1,-7,6],97) #random
-        '[[46, 2], [[58, 45], [45, 48]]]
-        sage: EllipticCurve(GF(97),[0,0,1,-7,6]).abelian_group() #random
-        (Multiplicative Abelian Group isomorphic to C46 x C2,
-        ((52 : 13 : 1), (45 : 48 : 1)))
-    """
-    init()
-    cmd = "e=ellzpinit(%s,%s); [e.isotype, lift(e.generators)]"%(e,p)
-    x = gp.eval(cmd)
-    if x.find("***") != -1:
-        raise RuntimeError, "Error: '%s'"%x
-    return x
-
-def ellinit(e, p):
-    """
-    INPUT:
-        e -- five-tuple of integers that define an elliptic curve over Z/pZ
-        p -- prime
-    OUTPUT:
-        GP/PARI object representing the elliptic curve modulo p,
-        including the following fields:
-
-        E[14] : the group order n = #E(Fp)
-        E[15] : factorization of the group order n (as a matrix)
-        E[16] : the group structure: [n] if cyclic, or
-                                     [n1,n2] with n=n1*n2 and n2|n1
-        E[17] : the group generators: [P] is cyclic, or
-                                      [P1,P2] with order(Pi)=ni
-
-
-    EXAMPLES:
-        sage: import sage.schemes.elliptic_curves.gp_cremona
-        sage: E = sage.schemes.elliptic_curves.gp_cremona.ellinit([0,0,1,-7,6],97)
-        sage: E # random generators
-        [Mod(0, 97), Mod(0, 97), Mod(1, 97), Mod(90, 97), Mod(6, 97), Mod(0, 97), Mod(83, 97), Mod(25, 97), Mod(48, 97), Mod(45, 97), Mod(32, 97), Mod(33, 97), Mod(63, 97), 92, [2, 2; 23, 1], [46, 2], [[Mod(96, 97), Mod(3, 97)], [Mod(30, 97), Mod(48, 97)]], 0, 0]
-        sage: type(E)
-        <class 'sage.interfaces.gp.GpElement'>
-    """
-    init()
-    current_randstate().set_seed_gp(gp)
-    return gp("e=ellzpinit(%s,%s);"%(e,p))
-
-
-################
-# allisog.gp
-################
-gp_allisog = None
-def p_isog(e, p):
-    """
-    Return a list of the elliptic curves p-isogenous to e.
-
-    ALGORITHM:
-        Uses Cremona's gp script
-    
-    EXAMPLES:
-        sage: import sage.schemes.elliptic_curves.gp_cremona
-        sage: E=EllipticCurve('11a1')
-        sage: sage.schemes.elliptic_curves.gp_cremona.p_isog(E.pari_curve(),5)
-        '[[0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]]'
-    """
-    global gp_allisog
-    if gp_allisog is None:
-        gp_allisog = Gp(script_subdirectory='cremona')
-        gp_allisog.read("allisog.gp")
-    
-    x = gp_allisog.eval('lisogs(ellinit(%s),%s)'%(e,p))
-    if x.find("***") != -1:
-        raise RuntimeError, "Error: '%s'"%x
-    return x
-
-def allisog(e):
-    """
-    Return a list of the curves p-isogenous to e for some prime p.
-
-    OUTPUT: A list of lists [p,curves] where curves is a list of
-        elliptic curves p-isogenous to e.
-
-    ALGORITHM:
-        Uses Cremona's gp script
-    
-    EXAMPLES:
-        sage: import sage.schemes.elliptic_curves.gp_cremona
-        sage: E=EllipticCurve('14a1')
-        sage: sage.schemes.elliptic_curves.gp_cremona.allisog(E.pari_curve())
-        '[[2, [[1, 0, 1, -36, -70]]], [3, [[1, 0, 1, -171, -874], [1, 0, 1, -1, 0]]]]'
-    """
-    global gp_allisog
-    if gp_allisog is None:
-        gp_allisog = Gp(script_subdirectory='cremona')
-        gp_allisog.read("allisog.gp")
-
-    x = gp_allisog.eval('allisog(ellinit(%s))'%e)
-    if x.find("***") != -1:
-        raise RuntimeError, "Error: '%s'"%x
-    return x
-    
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/heegner.py
--- a/sage/schemes/elliptic_curves/heegner.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/heegner.py	Mon Aug 16 15:43:27 2010 +0200
@@ -22,7 +22,7 @@
     1
     sage: K.<a> = QuadraticField(-8)
     sage: K.factor(3)
-    (Fractional ideal (1/2*a + 1)) * (Fractional ideal (-1/2*a + 1))
+    (Fractional ideal (-1/2*a - 1)) * (Fractional ideal (1/2*a - 1))
 
 Next try an inert prime::
 
@@ -3021,7 +3021,7 @@
             sage: P = y.kolyvagin_point(); P
             Kolyvagin point of discriminant -7 on elliptic curve of conductor 37
             sage: P.numerical_approx()
-            (-3.4...e-16 - 2.00...e-16*I : 3.4...e-16 + 2.000...e-16*I : 1.00000000000000)
+            (-3.4...e-16 - 2.00...e-16*I : 3.4...e-16 + 2.00...e-16*I : 1.00000000000000)
         """
         return KolyvaginPoint(self)
 
@@ -3124,7 +3124,7 @@
             sage: P.numerical_approx(10)
             (0.0030 - 0.0028*I : -0.0030 + 0.0028*I : 1.0)
             sage: P.numerical_approx(100)[0]
-            8.4419827889841225189186778139e-31 + 6.0876...e-31*I
+            8.4...e-31 + 6.0...e-31*I
             sage: E = EllipticCurve('37a'); P = E.heegner_point(-40); P
             Heegner point of discriminant -40 on elliptic curve of conductor 37
             sage: P.numerical_approx()
@@ -3137,7 +3137,7 @@
             sage: P = E.heegner_point(-7); P
             Heegner point of discriminant -7 on elliptic curve of conductor 389
             sage: P.numerical_approx()
-            (4.08580183114324e28 + 1.50348132882460e28*I : -7.84283601876376e42 - 4.58366020722762e42*I : 1.00000000000000)   # 64-bit
+            (4.085...e28 + 1.503...e28*I : -7.842...e42 - 4.583...e42*I : 1.00000000000000)   # 64-bit
             (0 : 1.00000000000000 : 0)   # 32-bit
             sage: P.numerical_approx(70)
             (0 : 1.0000000000000000000 : 0)
@@ -3969,7 +3969,7 @@
             sage: P.numerical_approx(10)
             (0.0030 - 0.0028*I : -0.0030 + 0.0028*I : 1.0)
             sage: P.numerical_approx(100)[0]
-            8.4419827889841225189186778139e-31 + 6.087647...e-31*I
+            8.441982...e-31 + 6.087647...e-31*I
 
             sage: P = EllipticCurve('389a1').kolyvagin_point(-7, 5); P
             Kolyvagin point of discriminant -7 and conductor 5 on elliptic curve of conductor 389
@@ -4109,7 +4109,7 @@
 
             sage: E = EllipticCurve('37a1'); P = E.kolyvagin_point(-67)
             sage: P.numerical_approx()
-            (6.00000000000000 + 8.0...e-16*I : -15.0000000000000 - 2.96897922913431e-15*I : 1.00000000000000)
+            (6.00000000000000 + 8.0...e-16*I : -15.0000000000000 - 2.96...e-15*I : 1.00000000000000)
             sage: P.trace_to_real_numerical()
             (1.61355529131986 : -2.18446840788880 : 1.00000000000000)
             sage: P.trace_to_real_numerical(prec=80)
@@ -5216,7 +5216,7 @@
             sage: [b.dot_product(k118.element().change_ring(GF(3))) for b in V.basis()]
             [1, 0]
             sage: [b.dot_product(k104.element().change_ring(GF(3))) for b in V.basis()]
-            [1, 0]
+            [2, 0]
 
         By the way, the above is the first ever provable verification
         of Kolyvagin's conjecture for any curve of rank at least 2.
@@ -5247,7 +5247,7 @@
             sage: V = H.modp_dual_elliptic_curve_factor(EllipticCurve('389a'), q, 5)
             sage: k = H.kolyvagin_sigma_operator(D, 17*41, 104)     # long time
             sage: k                                                 # long time
-            (990, 656, 219, ..., 246, 534, 1254)
+            (494, 472, 1923, 1067, ..., 102, 926)
             sage: [b.dot_product(k.element().change_ring(GF(3))) for b in V.basis()]   # long time (but only because depends on something slow)
             [0, 0]
         """
@@ -5364,13 +5364,13 @@
             sage: N = 389; D = -7; ell = 5; c = 17; q = 3
             sage: H = heegner_points(N).reduce_mod(ell)
             sage: k = H.rational_kolyvagin_divisor(D, c); k
-            (2, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 4, 0, 0, 9, 11, 0, 6, 0, 0, 7, 0, 0, 0, 0, 14, 12, 13, 15, 17, 0, 0, 0, 0, 8, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+            (14, 16, 0, 0, ... 0, 0, 0)
             sage: V = H.modp_dual_elliptic_curve_factor(EllipticCurve('389a'), q, 2)
             sage: [b.dot_product(k.element().change_ring(GF(q))) for b in V.basis()]
             [0, 0]
             sage: k = H.rational_kolyvagin_divisor(D, 59)
             sage: [b.dot_product(k.element().change_ring(GF(q))) for b in V.basis()]
-            [2, 0]
+            [1, 0]
         """
         if not self.satisfies_heegner_hypothesis(D, c):
             raise ValueError, "D and c must be coprime to N and ell"
@@ -6217,7 +6217,7 @@
         sage: P = E.kolyvagin_point(-67); P
         Kolyvagin point of discriminant -67 on elliptic curve of conductor 37
         sage: P.numerical_approx()
-        (6.00000000000000 + 8.0...e-16*I : -15.0000000000000 - 2.96897922913431e-15*I : 1.00000000000000)
+        (6.00000000000000 + 8.0...e-16*I : -15.0000000000000 - 2.96...e-15*I : 1.00000000000000)
         sage: P.index()
         6
         sage: g = E((0,-1,1)) # a generator
@@ -6795,22 +6795,22 @@
     An example where E has conductor 11::
 
         sage: E = EllipticCurve('11a')
-        sage: E.heegner_sha_an(-7)                                  # long
+        sage: E.heegner_sha_an(-7)                                  # long time
         1.00000000000000
 
     The cache works::
 
-        sage: E.heegner_sha_an(-7) is E.heegner_sha_an(-7)          # long
+        sage: E.heegner_sha_an(-7) is E.heegner_sha_an(-7)          # long time
         True
 
     Lower precision::
 
-        sage: E.heegner_sha_an(-7,10)                               # long
+        sage: E.heegner_sha_an(-7,10)                               # long time
         1.0
 
     Checking that the cache works for any precision::
 
-        sage: E.heegner_sha_an(-7,10) is E.heegner_sha_an(-7,10)    # long
+        sage: E.heegner_sha_an(-7,10) is E.heegner_sha_an(-7,10)    # long time
         True
 
     Next we consider a rank 1 curve with nontrivial Sha over the
@@ -6818,31 +6818,31 @@
     over `\QQ` or for the quadratic twist of `E`::
 
         sage: E = EllipticCurve('37a')
-        sage: E.heegner_sha_an(-40)                                 # long
+        sage: E.heegner_sha_an(-40)                                 # long time
         4.00000000000000
-        sage: E.quadratic_twist(-40).sha().an()                     # long
+        sage: E.quadratic_twist(-40).sha().an()                     # long time
         1
-        sage: E.sha().an()                                          # long
+        sage: E.sha().an()                                          # long time
         1
 
     A rank 2 curve::
 
-        sage: E = EllipticCurve('389a')                             # long
-        sage: E.heegner_sha_an(-7)                                  # long
+        sage: E = EllipticCurve('389a')                             # long time
+        sage: E.heegner_sha_an(-7)                                  # long time
         1.00000000000000
 
     If we remove the hypothesis that `E(K)` has rank 1 in Conjecture
     2.3 in [Gross-Zagier, 1986, page 311], then that conjecture is
     false, as the following example shows::
 
-        sage: E = EllipticCurve('65a')                              # long
-        sage: E.heegner_sha_an(-56)                                 # long
+        sage: E = EllipticCurve('65a')                              # long time
+        sage: E.heegner_sha_an(-56)                                 # long time
         1.00000000000000
-        sage: E.torsion_order()                                     # long
+        sage: E.torsion_order()                                     # long time
         2
-        sage: E.tamagawa_product()                                  # long
+        sage: E.tamagawa_product()                                  # long time
         1
-        sage: E.quadratic_twist(-56).rank()                         # long
+        sage: E.quadratic_twist(-56).rank()                         # long time
         2
     """
     # check conditions, then return from cache if possible.
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/lseries_ell.py
--- a/sage/schemes/elliptic_curves/lseries_ell.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/lseries_ell.py	Mon Aug 16 15:43:27 2010 +0200
@@ -164,7 +164,7 @@
             sage: a = E.lseries().sympow(2,16)   # optional - requires precomputing "sympow('-new_data 2')"
             sage: a      # optional
             '2.492262044273650E+00'
-            sage: RR(a)                      # optional 
+            sage: RR(a)                      # optional
             2.49226204427365
         """
         from sage.lfunctions.sympow import sympow
@@ -189,7 +189,7 @@
         commands have to be run.}
 
         EXAMPLES:
-            sage: E = EllipticCurve('37a')    
+            sage: E = EllipticCurve('37a')
             sage: print E.lseries().sympow_derivs(1,16,2)      # optional -- requires precomputing "sympow('-new_data 2')"
             sympow 1.018 RELEASE  (c) Mark Watkins --- see README and COPYING for details
             Minimal model of curve  is [0,0,1,-1,0]
@@ -223,7 +223,7 @@
         
         EXAMPLES:
             sage: E = EllipticCurve('37a')
-            sage: E.lseries().zeros(2)                  
+            sage: E.lseries().zeros(2)
             [0.000000000, 5.00317001]
 
             sage: a = E.lseries().zeros(20)             # long time
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/modular_parametrization.py
--- a/sage/schemes/elliptic_curves/modular_parametrization.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/modular_parametrization.py	Mon Aug 16 15:43:27 2010 +0200
@@ -18,7 +18,7 @@
         sage: phi
         Modular parameterization from the upper half plane to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
         sage: phi(0.5+CDF(I))
-        (285684.320516... + 7.01033491...e-11*I : 1.526964169...e8 + 5.6214048527...e-8*I : 1.00000000000000)
+        (285684.320516... + 7.0...e-11*I : 1.526964169...e8 + 5.6...e-8*I : 1.00000000000000)
         sage: phi.power_series(prec = 7)
         (q^-2 + 2*q^-1 + 4 + 5*q + 8*q^2 + q^3 + 7*q^4 + O(q^5), -q^-3 - 3*q^-2 - 7*q^-1 - 13 - 17*q - 26*q^2 - 19*q^3 + O(q^4))
 
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/period_lattice.py
--- a/sage/schemes/elliptic_curves/period_lattice.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/period_lattice.py	Mon Aug 16 15:43:27 2010 +0200
@@ -520,7 +520,7 @@
             1.9072648860892725468182549468 + 1.3404778596244020196600112394*I)
             sage: Ls[2]._compute_periods_real(100, algorithm='pari')
             (3.8145297721785450936365098936,
-            -1.9072648860892725468182549468 + 1.3404778596244020196600112394*I)
+            1.9072648860892725468182549468 - 1.3404778596244020196600112394*I)
         """
         if prec is None:
             prec = RealField().precision()
diff -r f77808909c54 -r 8a361e1b884e sage/schemes/elliptic_curves/sha_tate.py
--- a/sage/schemes/elliptic_curves/sha_tate.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/schemes/elliptic_curves/sha_tate.py	Mon Aug 16 15:43:27 2010 +0200
@@ -214,7 +214,7 @@
 
             sage: EllipticCurve('11a').sha().an_numerical()
             1.00000000000000
-            sage: EllipticCurve('37a').sha().an_numerical() # long time
+            sage: EllipticCurve('37a').sha().an_numerical()
             1.00000000000000
             sage: EllipticCurve('389a').sha().an_numerical() # long time
             1.00000000000000
diff -r f77808909c54 -r 8a361e1b884e sage/structure/factorization.py
--- a/sage/structure/factorization.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/structure/factorization.py	Mon Aug 16 15:43:27 2010 +0200
@@ -142,17 +142,17 @@
     sage: K.<a> = NumberField(x^2 + 3); K
     Number Field in a with defining polynomial x^2 + 3
     sage: f = K.factor(15); f                                  
-    (Fractional ideal (1/2*a - 3/2))^2 * (Fractional ideal (5))
+    (Fractional ideal (-a))^2 * (Fractional ideal (5))
     sage: f.universe()
     Monoid of ideals of Number Field in a with defining polynomial x^2 + 3
     sage: f.unit()
     Fractional ideal (1)
     sage: g=K.factor(9); g
-    (Fractional ideal (1/2*a - 3/2))^4
+    (Fractional ideal (-a))^4
     sage: f.lcm(g)
-    (Fractional ideal (1/2*a - 3/2))^4 * (Fractional ideal (5))
+    (Fractional ideal (-a))^4 * (Fractional ideal (5))
     sage: f.gcd(g)
-    (Fractional ideal (1/2*a - 3/2))^2
+    (Fractional ideal (-a))^2
     sage: f.is_integral()
     True
 
diff -r f77808909c54 -r 8a361e1b884e sage/symbolic/constants.py
--- a/sage/symbolic/constants.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/symbolic/constants.py	Mon Aug 16 15:43:27 2010 +0200
@@ -838,7 +838,9 @@
         .6931471805599453
         sage: gp(log2)
         0.6931471805599453094172321215             # 32-bit
-        0.69314718055994530941723212145817656807   # 64-bit
+        0.69314718055994530941723212145817656808   # 64-bit
+        sage: RealField(150)(2).log()
+        0.69314718055994530941723212145817656807550013
     """
     def __init__(self, name='log2'):
         """
diff -r f77808909c54 -r 8a361e1b884e sage/symbolic/expression.pyx
--- a/sage/symbolic/expression.pyx	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/symbolic/expression.pyx	Mon Aug 16 15:43:27 2010 +0200
@@ -864,7 +864,7 @@
             sage: zeta(x).subs(x=I)._complex_mpfr_field_(ComplexField(70))
             0.0033002236853241028742 - 0.41815544914132167669*I
             sage: gamma(x).subs(x=I)._complex_mpfr_field_(ComplexField(60))
-            -0.15494982830181069 - 0.49801566811835604*I
+            -0.1549498283018106... - 0.49801566811835604*I
             sage: log(x).subs(x=I)._complex_mpfr_field_(ComplexField(50))
             1.5707963267949*I
 
diff -r f77808909c54 -r 8a361e1b884e sage/tests/benchmark.py
--- a/sage/tests/benchmark.py	Sat Aug 14 18:53:26 2010 -0700
+++ b/sage/tests/benchmark.py	Mon Aug 16 15:43:27 2010 +0200
@@ -1248,7 +1248,11 @@
         """
         E = EllipticCurve([1,2,3,4,5])
         t = walltime()
-        n = E.sea(self.__p)
+        # Note that from pari 2.4.3, the SEA algorithm is used by the
+        # pari library, but only for large primes, so for a better
+        # test a prime > 2^30 should be used and not 5.  In fact
+        # next_prime(2^100) works fine (<<1s).
+        n = E.change_ring(GF(self.__p)).cardinality_pari()
         return False, walltime(t)
 
     def magma(self):

