Ticket #11130: 11130_sagelib.patch

File 11130_sagelib.patch, 53.4 KB (added by jdemeyer, 8 years ago)
  • sage/libs/pari/decl.pxi

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1303287482 -7200
    # Node ID 53c903189fc34b1abee880e2f27f6a7e34ebf844
    # Parent  a48af224839e4eb2555175d15d703ecd81d0b4c1
    Update PARI to version 2.5.0
    
    diff --git a/sage/libs/pari/decl.pxi b/sage/libs/pari/decl.pxi
    a b  
    776776    long    ellrootno(GEN e, GEN p)
    777777    GEN     ellsigma(GEN om, GEN z, long flag, long prec)
    778778    GEN     elltors0(GEN e, long flag)
    779     GEN     ellwp0(GEN e, GEN z, long flag, long prec, long PREC)
     779    GEN     ellwp0(GEN e, GEN z, long flag, long precdl, long prec)
    780780    GEN     ellzeta(GEN om, GEN z, long prec)
    781781    GEN     ghell(GEN e, GEN a, long prec)
    782782    GEN     ellglobalred(GEN e1)
     
    969969    GEN     gtocol(GEN x)
    970970    GEN     gtopoly(GEN x, long v)
    971971    GEN     gtopolyrev(GEN x, long v)
    972     GEN     gtoser(GEN x, long v)
     972    GEN     gtoser(GEN x, long v, long precdl)
    973973    GEN     gtovec(GEN x)
    974974    GEN     gtovecsmall(GEN x)
    975975    GEN     gtrunc(GEN x)
  • sage/libs/pari/gen.pyx

    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    24502450       
    24512451       
    24522452        The optional D is 0 by default and initializes Shank's distance if
    2453         `b^2 - 4ac > 0`.
     2453        `b^2 - 4ac > 0`.  The discriminant of the quadratic form must not
     2454        be a perfect square.
    24542455       
    24552456        .. note::
    24562457
     
    24792480       
    24802481        EXAMPLES::
    24812482       
    2482             sage: pari(3).Qfb(7, 2)
    2483             Qfb(3, 7, 2, 0.E-19)
     2483            sage: pari(3).Qfb(7, 1)
     2484            Qfb(3, 7, 1, 0.E-19)
     2485            sage: pari(3).Qfb(7, 2)  # discriminant is 25
     2486            Traceback (most recent call last):
     2487            ...
     2488            PariError:  (5)
    24842489        """
    24852490        t0GEN(b); t1GEN(c); t2GEN(D)
    24862491        sig_on()       
    24872492        return P.new_gen(Qfb0(a.g, t0, t1, t2, prec))
    24882493       
    24892494   
    2490     def Ser(gen x, v=-1):
     2495    def Ser(gen x, v=-1, long seriesprecision = 16):
    24912496        """
    24922497        Ser(x,v=x): Create a power series from x with main variable v and
    24932498        return the result.
     
    25352540            1 + 2*v + 3*v^2 + 4*v^3 + 5*v^4 + O(v^5)
    25362541            sage: pari(1)/f
    25372542            1 - 2*v + v^2 + O(v^5)
    2538             sage: pari(1).Ser()
    2539             1 + O(x^16)
    2540         """
    2541         sig_on()
    2542         return P.new_gen(gtoser(x.g, P.get_var(v)))
     2543            sage: pari('x^5').Ser(seriesprecision = 20)
     2544            x^5 + O(x^25)
     2545            sage: pari('1/x').Ser(seriesprecision = 1)
     2546            x^-1 + O(x^0)
     2547        """
     2548        sig_on()
     2549        return P.new_gen(gtoser(x.g, P.get_var(v), seriesprecision))
    25432550       
    25442551   
    25452552    def Set(gen x):
     
    85668573        # the argument prec has no effect
    85678574        return self.new_gen(elleisnum(self.g, k, flag, prec))
    85688575
    8569     def ellwp(self, z='z', long n=20, long flag=0):
    8570         """
    8571         ellwp(E, z,flag=0): Return the complex value of the Weierstrass
    8572         P-function at z on the lattice defined by e.
     8576    def ellwp(gen self, z='z', long n=20, long flag=0):
     8577        """
     8578        Return the value or the series expansion of the Weierstrass
     8579        `P`-function at `z` on the lattice `self` (or the lattice
     8580        defined by the elliptic curve `self`).
    85738581       
    85748582        INPUT:
    85758583       
    8576        
    8577         -  ``E`` - list OR elliptic curve
    8578        
    8579         -  ``list`` - [om1, om2], which are Z-generators for a
    8580            lattice
    8581        
    8582         -  ``elliptic curve`` - created using ellinit
    8583        
    8584         -  ``z`` - (optional) complex number OR string (default
    8585            = "z")
    8586        
    8587         -  ``complex number`` - any number in the complex
    8588            plane
    8589        
    8590         -  ``string (or PARI variable)`` - name of a variable.
    8591        
    8592         -  ``n`` - int (optional: default 20) if z is a
    8593            variable, compute up to at least `o(z^n)`.
    8594        
    8595         -  ``flag`` - int: 0 (default): compute only P(z) 1
    8596            compute [P(z),P'(z)] 2 consider om or E as an elliptic curve and
    8597            use P-function to compute the point on E (with the Weierstrass
    8598            equation for E) P(z) for that curve (identical to ellztopoint in
    8599            this case).
    8600        
     8584        -  ``self`` -- an elliptic curve created using ``ellinit`` or a
     8585           list ``[om1, om2]`` representing generators for a lattice.
     8586       
     8587        -  ``z`` -- (default: 'z') a complex number or a variable name
     8588           (as string or PARI variable).
     8589       
     8590        -  ``n`` -- (default: 20) if 'z' is a variable, compute the
     8591           series expansion up to at least `O(z^n)`.
     8592       
     8593        -  ``flag`` -- (default = 0): If ``flag`` is 0, compute only
     8594           `P(z)`.  If ``flag`` is 1, compute `[P(z), P'(z)]`.
    86018595       
    86028596        OUTPUT:
    86038597       
    8604        
    8605         -  ``gen`` - complex number or list of two complex
     8598        - `P(z)` (if ``flag`` is 0) or `[P(z), P'(z)]` (if ``flag`` is 1).
    86068599           numbers
    86078600       
    8608        
    86098601        EXAMPLES:
    86108602       
    86118603        We first define the elliptic curve X_0(11)::
    86128604       
    86138605            sage: E = pari([0,-1,1,-10,-20]).ellinit()
    86148606       
    8615         Compute P(1).
    8616        
    8617         ::
     8607        Compute P(1)::
    86188608       
    86198609            sage: E.ellwp(1)
    86208610            13.9658695257485 + 0.E-18*I
    86218611       
    8622         Compute P(1+i), where i = sqrt(-1).
    8623        
    8624         ::
     8612        Compute P(1+i), where i = sqrt(-1)::
    86258613       
    86268614            sage: C.<i> = ComplexField()
    86278615            sage: E.ellwp(pari(1+i))
     
    86298617            sage: E.ellwp(1+i)
    86308618            -1.11510682565555 + 2.33419052307470*I
    86318619       
    8632         The series expansion, to the default 20 precision::
     8620        The series expansion, to the default `O(z^20)` precision::
    86338621       
    86348622            sage: E.ellwp()
    86358623            z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + 77531/41580*z^8 + 1202285717/928746000*z^10 + 2403461/2806650*z^12 + 30211462703/43418875500*z^14 + 3539374016033/7723451736000*z^16 + 413306031683977/1289540602350000*z^18 + O(z^20)
     
    86458633            sage: pari([1.2692, 0.63 + 1.45*i]).ellwp(1)
    86468634            13.9656146936689 + 0.000644829272810...*I
    86478635       
    8648         With flag 1 compute the pair P(z) and P'(z)::
     8636        With flag=1, compute the pair P(z) and P'(z)::
    86498637       
    86508638            sage: E.ellwp(1, flag=1)
    86518639            [13.9658695257485 + 0.E-18*I, 50.5619300880073 ... E-18*I]
    8652 
    8653         With flag=2, the computed pair is (x,y) on the curve instead of
    8654         [P(z),P'(z)]::
    8655        
    8656             sage: E.ellwp(1, flag=2)
    8657             [14.2992028590818 + 0.E-18*I, 50.0619300880073 ... E-18*I]
    86588640        """
    86598641        t0GEN(z)
    8660         if n < 0:
    8661             n = 0
    8662         if n%2 == 1:
    8663             n = n + 1
    8664         sig_on()
    8665         try:
    8666             dprec = prec_words_to_dec(z.precision())
    8667         except AttributeError:
     8642        sig_on()
     8643        cdef long dprec
     8644        dprec = gprecision(t0)
     8645        if dprec:
     8646            dprec = prec_words_to_dec(dprec)
     8647        else:
    86688648            dprec = prec
    8669         return self.new_gen(ellwp0(self.g, t0, flag, dprec, (n+2)/2))
     8649        return self.new_gen(ellwp0(self.g, t0, flag, n+2, dprec))
    86708650
    86718651    def ellchangepoint(self, y):
    86728652        """
  • sage/matrix/matrix2.pyx

    diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
    a b  
    1 
    2 """
     1r"""
    32Base class for matrices, part 2
    43
     4For design documentation see matrix/docs.py.
     5
    56AUTHORS:
    67
    7     - William Stein: initial version
    8     - Miguel Marco (2010-06-19): modified eigenvalues and eigenvectors functions to
    9       allow the option extend=False
    10     - Rob Beezer (2011-02-05): refactored all of the matrix kernel routines
     8- William Stein: initial version
     9
     10- Miguel Marco (2010-06-19): modified eigenvalues and eigenvectors functions to
     11  allow the option extend=False
     12
     13- Rob Beezer (2011-02-05): refactored all of the matrix kernel routines
    1114
    1215TESTS::
    1316
     
    1518    sage: TestSuite(m).run()
    1619"""
    1720
    18 # For design documentation see matrix/docs.py.
    19 
    20 ################################################################################
     21#*****************************************************************************
    2122#       Copyright (C) 2005, 2006 William Stein <wstein@gmail.com>
    2223#
    23 #  Distributed under the terms of the GNU General Public License (GPL).
    24 The full text of the GPL is available at:
    25 #
     24#  Distributed under the terms of the GNU General Public License (GPL)
     25as published by the Free Software Foundation; either version 2 of
     26#  the License, or (at your option) any later version.
    2627#                  http://www.gnu.org/licenses/
    27 ################################################################################
     28#*****************************************************************************
    2829
    2930include "../ext/stdsage.pxi"
    3031include "../ext/python.pxi"
     
    93589359            ...     -2*a^2 + 4*a - 2, -2*a^2 + 1, 2*a, a^2 - 6, 3*a^2 - a ])
    93599360            sage: r,s,p = m._echelon_form_PID()
    93609361            sage: s[2]
    9361             (0, 0, 3*a^2 + 18*a - 34, 68*a^2 - 134*a + 53, 111*a^2 - 275*a + 90)
     9362            (0, 0, -3*a^2 - 18*a + 34, -68*a^2 + 134*a - 53, -111*a^2 + 275*a - 90)
    93629363            sage: r * m == s and r.det() == 1
    93639364            True
    93649365
  • sage/rings/arith.py

    diff --git a/sage/rings/arith.py b/sage/rings/arith.py
    a b  
    12421242   
    12431243        sage: K.<a> = QuadraticField(7)
    12441244        sage: divisors(K.ideal(7))
    1245         [Fractional ideal (1), Fractional ideal (-a), Fractional ideal (7)]
     1245        [Fractional ideal (1), Fractional ideal (a), Fractional ideal (7)]
    12461246        sage: divisors(K.ideal(3))
    1247         [Fractional ideal (1), Fractional ideal (3), Fractional ideal (a - 2), Fractional ideal (a + 2)]
     1247        [Fractional ideal (1), Fractional ideal (3), Fractional ideal (-a + 2), Fractional ideal (-a - 2)]
    12481248        sage: divisors(K.ideal(35))
    1249         [Fractional ideal (1), Fractional ideal (35), Fractional ideal (-5*a), Fractional ideal (5), Fractional ideal (-a), Fractional ideal (7)]
     1249        [Fractional ideal (1), Fractional ideal (35), Fractional ideal (5*a), Fractional ideal (5), Fractional ideal (a), Fractional ideal (7)]
    12501250   
    12511251    TESTS::
    12521252   
     
    23012301   
    23022302    ::
    23032303   
    2304         sage: factor(2^197 + 1)  # long time
     2304        sage: factor(2^197 + 1)  # long time (2s)
    23052305        3 * 197002597249 * 1348959352853811313 * 251951573867253012259144010843
    23062306   
    23072307    Any object which has a factor method can be factored like this::
    23082308
    23092309        sage: K.<i> = QuadraticField(-1)
    2310         sage: factor(122+454*i)
    2311         (-1) * (-2*i - 3) * (-i + 4) * (i + 1)^3 * (-i + 2)^3
     2310        sage: factor(122 - 454*i)
     2311        (-1) * (-3*i - 2) * (-i - 4) * (i + 1)^3 * (-i - 2)^3
    23122312
    23132313    To access the data in a factorization::
    23142314   
  • sage/rings/integer.pyx

    diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
    a b  
    42394239       
    42404240        EXAMPLES::
    42414241
    4242             sage: K = NumberField(x**2 - 2, 'beta')
     4242            sage: K = NumberField(x^2 - 2, 'beta')
    42434243            sage: n = 4
    42444244            sage: n.is_norm(K)
    42454245            True
     
    42484248            sage: 7.is_norm(QQ)
    42494249            True
    42504250            sage: n.is_norm(K, element=True)
    4251             (True, 4*beta + 6)
     4251            (True, -4*beta + 6)
    42524252            sage: n.is_norm(K, element=True)[1].norm()
    42534253            4
    42544254            sage: n = 5
     
    42714271            sage: 3._bnfisnorm(QuadraticField(-1, 'i'))
    42724272            (1, 3)
    42734273            sage: 7._bnfisnorm(CyclotomicField(7))
    4274             (-zeta7^2 + zeta7, 1)
     4274            (-zeta7 + 1, 1)            # 64-bit
     4275            (-zeta7^5 + zeta7^4, 1)    # 32-bit
    42754276        """
    42764277        from sage.rings.rational_field import QQ
    42774278        return QQ(self)._bnfisnorm(K, certify=certify, extra_primes=extra_primes)
  • sage/rings/number_field/class_group.py

    diff --git a/sage/rings/number_field/class_group.py b/sage/rings/number_field/class_group.py
    a b  
    360360
    361361            sage: k.<a> = NumberField(x^2 + 20072); G = k.class_group(); G
    362362            Class group of order 76 with structure C38 x C2 of Number Field in a with defining polynomial x^2 + 20072
    363             sage: I = G.0; I
     363            sage: I = (G.0)^35; I
    364364            Fractional ideal class (41, 1/2*a + 5)
    365365            sage: J = G(I.ideal()^5); J
    366366            Fractional ideal class (115856201, 1/2*a + 40407883)
    367367            sage: J.reduce()
    368368            Fractional ideal class (57, 1/2*a + 44)
     369            sage: J == I^5
     370            True
    369371        """
    370372        return self.parent()(self.__ideal.reduce_equiv())
    371373
  • sage/rings/number_field/number_field.py

    diff --git a/sage/rings/number_field/number_field.py b/sage/rings/number_field/number_field.py
    a b  
    1414
    1515- Simon King (2010-05): Improve coercion from GAP
    1616
    17 - Jeroen Demeyer (2010-07): Upgrade to PARI 2.4.3
     17- Jeroen Demeyer (2010-07, 2011-04): Upgrade PARI (#9343, #10430, #11130)
    1818
    1919.. note::
    2020
     
    25042504       
    25052505            sage: K.<z> = CyclotomicField(10)
    25062506            sage: Ps = K.primes_of_degree_one_list(3)
    2507             sage: Ps
    2508             [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
    2509             [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
     2507            sage: Ps  # random output
     2508            [Fractional ideal (-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)]
    25102509            sage: [ P.norm() for P in Ps ]
    25112510            [11, 31, 41]
    25122511            sage: [ P.residue_class_degree() for P in Ps ]
     
    36503649        r"""
    36513650        Ideal factorization of the principal ideal generated by `n`.
    36523651       
    3653         EXAMPLE: Here we show how to factor Gaussian integers (up to units).
     3652        EXAMPLES:
     3653       
     3654        Here we show how to factor Gaussian integers (up to units).
    36543655        First we form a number field defined by `x^2 + 1`::
    36553656       
    36563657            sage: K.<I> = NumberField(x^2 + 1); K
     
    36583659       
    36593660        Here are the factors::
    36603661       
    3661             sage: fi, fj = K.factor(13); fi,fj
    3662             ((Fractional ideal (-2*I + 3), 1), (Fractional ideal (-2*I - 3), 1))
     3662            sage: fi, fj = K.factor(17); fi,fj
     3663            ((Fractional ideal (4*I + 1), 1), (Fractional ideal (-I - 4), 1))
    36633664       
    36643665        Now we extract the reduced form of the generators::
    36653666       
    36663667            sage: zi = fi[0].gens_reduced()[0]; zi
    3667             -2*I + 3
     3668            4*I + 1
    36683669            sage: zj = fj[0].gens_reduced()[0]; zj
    3669             -2*I - 3
    3670        
    3671         We recover the integer that was factored in `\ZZ[i]` up to a unit::
     3670            -I - 4
     3671
     3672        We recover the integer that was factored in `\ZZ[i]` (up to a unit)::
    36723673       
    36733674            sage: zi*zj
    3674             -13
     3675            -17*I
    36753676
    36763677        One can also factor elements or ideals of the number field::
    36773678       
     
    36813682            sage: K.factor(1+a)
    36823683            Fractional ideal (a + 1)
    36833684            sage: K.factor(1+a/5)
    3684             (Fractional ideal (-2*a + 3)) * (Fractional ideal (a + 1)) * (Fractional ideal (a + 2))^-1 * (Fractional ideal (-a + 2))^-1
     3685            (Fractional ideal (-3*a - 2)) * (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (a - 2))^-1
    36853686
    36863687        An example over a relative number field::
    36873688
     3689            sage: pari('setrand(2)')
    36883690            sage: L.<b> = K.extension(x^2 - 7)
    3689             sage: L.factor(a + 1)
    3690             (Fractional ideal (1/2*a*b + a + 1/2)) * (Fractional ideal (-1/2*a*b + a + 1/2))
     3691            sage: f = L.factor(a + 1); f
     3692            (Fractional ideal (-1/2*a*b - a - 1/2)) * (Fractional ideal (1/2*b + 1/2*a - 1)) # 32-bit
     3693            (Fractional ideal (1/2*a*b + a + 1/2)) * (Fractional ideal (-1/2*b - 1/2*a + 1)) # 64-bit
     3694            sage: f.value() == a+1
     3695            True
    36913696           
    36923697        It doesn't make sense to factor the ideal (0), so this raises an error::
    36933698       
     
    47064711       
    47074712        EXAMPLES::
    47084713       
    4709             sage: x = QQ['x'].0
     4714            sage: x = polygen(QQ)
    47104715            sage: A = x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3
    47114716            sage: K = NumberField(A, 'a')
    47124717            sage: K.units()
    4713             [1/275*a^3 + 4/55*a^2 - 5/11*a + 3]
     4718            [6/275*a^3 - 9/55*a^2 + 14/11*a - 2]
    47144719       
    47154720        For big number fields, provably computing the unit group can
    47164721        take a very long time.  In this case, one can ask for the
     
    47204725            sage: K = NumberField(x^17 + 3, 'a')
    47214726            sage: K.units(proof=True)  # takes forever, not tested
    47224727            ...
    4723             sage: K.units(proof=False)
    4724             [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]
     4728            sage: K.units(proof=False)  # result not independently verified
     4729            [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, 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, a^16 + a^15 + a^14 + a^13 + a^12 + a^11 + a^10 + a^9 + a^8 + a^7 + a^6 + a^5 + a^4 + a^3 + a^2 - 2, 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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
    47254730        """
    47264731        proof = proof_flag(proof)
    47274732
     
    47714776            sage: U = K.unit_group(); U
    47724777            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
    47734778            sage: U.gens()
    4774             [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3]
     4779            [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2]
    47754780            sage: U.invariants()
    47764781            [10, 0]
    47774782            sage: [u.multiplicative_order() for u in U.gens()]
     
    47854790            sage: K = NumberField(x^17 + 3, 'a')
    47864791            sage: K.unit_group(proof=True)  # takes forever, not tested
    47874792            ...
    4788             sage: U = K.unit_group(proof=False); U; U.gens()
     4793            sage: U = K.unit_group(proof=False)
     4794            sage: U
    47894795            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
    4790             [-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]
     4796            sage: U.gens()  # result not independently verified
     4797            [-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, 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, a^16 + a^15 + a^14 + a^13 + a^12 + a^11 + a^10 + a^9 + a^8 + a^7 + a^6 + a^5 + a^4 + a^3 + a^2 - 2, 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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
    47914798        """
    47924799        try:
    47934800            return self._unit_group
     
    58155822        For medium-sized galois groups of fields with small discriminants,
    58165823        this computation is feasible::
    58175824
    5818             sage: K.<a> = NumberField(x^6 + 4*x^2 + 2, 'a')
     5825            sage: K.<a> = NumberField(x^6 + 4*x^2 + 2)
    58195826            sage: K.galois_group(type='pari').order()
    58205827            48
    58215828            sage: L, phi = K._galois_closure_and_embedding('c')  # long time (25s on sage.math, 2011)
  • sage/rings/number_field/number_field_element.pyx

    diff --git a/sage/rings/number_field/number_field_element.pyx b/sage/rings/number_field/number_field_element.pyx
    a b  
    10261026            sage: Q.<X> = K[]
    10271027            sage: L.<b> = NumberField(X^4 + a)
    10281028            sage: t = (-a).is_norm(L, element=True); t
    1029             (True, b^3 + 1)
     1029            (True, -b^3 + 1)
    10301030            sage: t[1].norm(K)
    10311031            -a
    10321032
     
    11271127            sage: Q.<X> = K[]
    11281128            sage: L.<b> = NumberField(X^4 + a)
    11291129            sage: t = (-a)._rnfisnorm(L); t
    1130             (b^3 + 1, 1)
     1130            (-b^3 + 1, 1)
    11311131            sage: t[0].norm(K)
    11321132            -a
    11331133            sage: t = K(3)._rnfisnorm(L); t
    1134             ((-a^2 - 1)*b^3 + b^2 + a*b + a^2 + 1, -3*a)
     1134            ((a^2 + 1)*b^3 + b^2 - a*b + a^2 + 1, -3*a)
    11351135            sage: t[0].norm(K)*t[1]
    11361136            3
    11371137
     
    11391139
    11401140            sage: K.<a, b> = NumberField([x^2 - 2, x^2 - 3])
    11411141            sage: L.<c> = K.extension(x^3 + 2)
    1142             sage: t = (2*a + b)._rnfisnorm(L); t[1]
    1143             (b - 2)*a + 2*b - 3
    1144             sage: t[0].norm(K)*t[1]
    1145             2*a + b
     1142            sage: s = 2*a + b
     1143            sage: t = s._rnfisnorm(L)
     1144            sage: t[1] == 1 # True iff s is a norm
     1145            False
     1146            sage: s == t[0].norm(K)*t[1]
     1147            True
    11461148
    11471149        AUTHORS:
    11481150
     
    30223024       
    30233025            sage: P5s = F(5).support()
    30243026            sage: P5s
    3025             [Fractional ideal (t^2 + 1), Fractional ideal (t^2 - 2*t - 1)]
     3027            [Fractional ideal (-t^2 - 1), Fractional ideal (t^2 - 2*t - 1)]
    30263028            sage: all(5 in P5 for P5 in P5s)
    30273029            True
    30283030            sage: all(P5.is_prime() for P5 in P5s)
  • sage/rings/number_field/number_field_ideal.py

    diff --git a/sage/rings/number_field/number_field_ideal.py b/sage/rings/number_field/number_field_ideal.py
    a b  
    164164            Fractional ideal (3)
    165165            sage: F = pari(K).idealprimedec(5)
    166166            sage: K.ideal(F[0])
    167             Fractional ideal (-i + 2)
     167            Fractional ideal (i - 2)
    168168       
    169169        TESTS:
    170170       
     
    470470            sage: K.<a> = NumberField(x^2 + 17); K
    471471            Number Field in a with defining polynomial x^2 + 17
    472472            sage: I = K.factor(17)[0][0]; I
    473             Fractional ideal (-a)
     473            Fractional ideal (a)
    474474
    475475        Here the discriminant is 'large', so the gens aren't reduced::
    476476
     
    480480            Number Field in a with defining polynomial x^2 + 902384094
    481481            sage: I = K.factor(19)[0][0]; I
    482482            Fractional ideal (19, a + 14)
    483             sage: I.gens_reduced()                 # long time
     483            sage: I.gens_reduced()
    484484            (19, a + 14)
    485485        """
    486486        return '(%s)'%(', '.join(map(str, self._gens_repr())))
     
    10481048
    10491049    def _ideal_class_log(self, proof=None):
    10501050        r"""
    1051         Return the output of Pari's 'bnfisprincipal' for this ideal,
     1051        Return the output of PARI's ``bnfisprincipal`` for this ideal,
    10521052        i.e. a vector expressing the class of this ideal in terms of a
    10531053        set of generators for the class group.
    10541054         
     
    18301830            sage: reps=I.residues()
    18311831            sage: len(list(reps)) == I.norm()
    18321832            True
    1833             sage: all([r==s or not (r-s) in I for r in reps for s in reps])  # long time (3s)
     1833            sage: all([r==s or not (r-s) in I for r in reps for s in reps])  # long time (6s on sage.math, 2011)
    18341834            True
    18351835
    18361836            sage: K.<a> = NumberField(x^3-10)
     
    18391839            True
    18401840
    18411841            sage: K.<z> = CyclotomicField(11)
    1842             sage: len(list(K.primes_above(3)[0].residues())) == 3**5  # long time (4s)
     1842            sage: len(list(K.primes_above(3)[0].residues())) == 3**5  # long time (5s on sage.math, 2011)
    18431843            True
    18441844        """
    18451845        if not self.is_integral():
     
    20162016            sage: I = K.ideal((3+4*i)/5); I
    20172017            Fractional ideal (4/5*i + 3/5)
    20182018            sage: I.denominator()
    2019             Fractional ideal (-i + 2)
     2019            Fractional ideal (i - 2)
    20202020            sage: I.numerator()
    2021             Fractional ideal (i + 2)
     2021            Fractional ideal (-i - 2)
    20222022            sage: I.numerator().is_integral() and I.denominator().is_integral()
    20232023            True
    20242024            sage: I.numerator() + I.denominator() == K.unit_ideal()
     
    20462046            sage: I = K.ideal((3+4*i)/5); I
    20472047            Fractional ideal (4/5*i + 3/5)
    20482048            sage: I.denominator()
    2049             Fractional ideal (-i + 2)
     2049            Fractional ideal (i - 2)
    20502050            sage: I.numerator()
    2051             Fractional ideal (i + 2)
     2051            Fractional ideal (-i - 2)
    20522052            sage: I.numerator().is_integral() and I.denominator().is_integral()
    20532053            True
    20542054            sage: I.numerator() + I.denominator() == K.unit_ideal()
     
    27212721            Basis matrix:
    27222722            [1 3]
    27232723            sage: quo
    2724             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).
     2724            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).
    27252725            sage: lift
    2726             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)
     2726            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)
    27272727        """
    27282728        return quotient_char_p(self, p)
    27292729
     
    27682768
    27692769            sage: K.<i> = NumberField(x^2 + 1)
    27702770            sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2)
    2771             (Fractional ideal (i + 2), Fractional ideal (-i + 2))
     2771            (Fractional ideal (-i - 2), Fractional ideal (i - 2))
    27722772            sage: a = 1/(1+2*i)
    27732773            sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2)
    2774             (Residue field of Fractional ideal (i + 2), Residue field of Fractional ideal (-i + 2))
     2774            (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (i - 2))
    27752775            sage: a.valuation(P1)
    27762776            0
    27772777            sage: F1(i/7)
     
    27822782            -1
    27832783            sage: F2(a)
    27842784            Traceback (most recent call last):
    2785             ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (-i + 2): it has negative valuation
     2785            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (i - 2): it has negative valuation
    27862786
    27872787        An example with a relative number field::
    27882788
     
    28222822            sage: K.<a> = NumberField(x^5 + 2); K
    28232823            Number Field in a with defining polynomial x^5 + 2
    28242824            sage: f = K.factor(19); f
    2825             (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (-2*a^4 - a^2 + 2*a - 1)) * (Fractional ideal (a^2 + a - 1))
     2825            (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (-2*a^4 - a^2 + 2*a - 1)) * (Fractional ideal (-a^2 - a + 1))
    28262826            sage: [i.residue_class_degree() for i, _ in f]   
    28272827            [2, 2, 1]       
    28282828        """
     
    29992999        []
    30003000
    30013001        sage: I = K.factor(13)[0][0]; I
    3002         Fractional ideal (-2*i + 3)
     3002        Fractional ideal (-3*i - 2)
    30033003        sage: I.residue_class_degree()
    30043004        1
    30053005        sage: quotient_char_p(I, 13)[0]
  • sage/rings/number_field/number_field_ideal_rel.py

    diff --git a/sage/rings/number_field/number_field_ideal_rel.py b/sage/rings/number_field/number_field_ideal_rel.py
    a b  
    44AUTHORS:
    55
    66- Steven Sivek (2005-05-16)
     7
    78- William Stein (2007-09-06)
     9
    810- Nick Alexander (2009-01)
    911
    1012EXAMPLES::
     
    2527#       Copyright (C) 2007 William Stein <wstein@gmail.com>
    2628#
    2729#  Distributed under the terms of the GNU General Public License (GPL)
    28 #
    29 #    This code is distributed in the hope that it will be useful,
    30 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
    31 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    32 #    General Public License for more details.
    33 #
    34 #  The full text of the GPL is available at:
    35 #
     30#  as published by the Free Software Foundation; either version 2 of
     31#  the License, or (at your option) any later version.
    3632#                  http://www.gnu.org/licenses/
    3733#*****************************************************************************
    3834
     35
    3936from number_field_ideal import NumberFieldFractionalIdeal
    4037from sage.structure.factorization import Factorization
    4138from sage.structure.proof.proof import get_flag
     
    351348            sage: K.<a> = NumberField(x^2+6)
    352349            sage: L.<b> = K.extension(K['x'].gen()^4 + a)
    353350            sage: N = L.ideal(b).relative_norm(); N
    354             Fractional ideal (a)
     351            Fractional ideal (-a)
    355352            sage: N.parent()
    356353            Monoid of ideals of Number Field in a with defining polynomial x^2 + 6
    357354            sage: N.ring()
     
    472469            sage: K.<c> = F.extension(Y^2 - (1 + a)*(a + b)*a*b)
    473470            sage: I = K.ideal(3, c)
    474471            sage: J = I.ideal_below(); J
    475             Fractional ideal (b)
     472            Fractional ideal (-b)
    476473            sage: J.number_field() == F
    477474            True
    478475        """
     
    840837        sage: is_NumberFieldFractionalIdeal_rel(I)
    841838        True
    842839        sage: N = I.relative_norm(); N
    843         Fractional ideal (a)
     840        Fractional ideal (-a)
    844841        sage: is_NumberFieldFractionalIdeal_rel(N)
    845842        False
    846843        sage: is_NumberFieldFractionalIdeal(N)
  • sage/rings/polynomial/polynomial_quotient_ring.py

    diff --git a/sage/rings/polynomial/polynomial_quotient_ring.py b/sage/rings/polynomial/polynomial_quotient_ring.py
    a b  
    735735            sage: R.<x> = K[]
    736736            sage: S.<xbar> = R.quotient(x^2 + 23)
    737737            sage: S.S_class_group([])
    738             [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
     738            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, -1/2*xbar + 3/2)] # 32-bit
     739            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)] # 64-bit
    739740            sage: S.S_class_group([K.ideal(3, a-1)])
    740741            []
    741742            sage: S.S_class_group([K.ideal(2, a+1)])
    742743            []
    743744            sage: S.S_class_group([K.ideal(a)])
    744             [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
     745            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)] # 32-bit
     746            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, -1/2*xbar + 3/2)] # 64-bit
    745747
    746748        Now we take an example over a nontrivial base with two factors, each
    747749        contributing to the class group::
     
    750752            sage: R.<x> = K[]
    751753            sage: S.<xbar> = R.quotient((x^2 + 23)*(x^2 + 31))
    752754            sage: S.S_class_group([])
    753             [((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)]
     755            [((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 + 1/16*xbar^2 - 31/16*xbar + 47/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 + 3/16*xbar^2 + 23/16*xbar + 85/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 + 37/16*xbar^2 + 115/16*xbar + 867/16)]
    754756
    755757        By using the ideal `(a)`, we cut the part of the class group coming from
    756758        `x^2 + 31` from 12 to 2, i.e. we lose a generator of order 6::
     
    800802        of `gen^{order}`.
    801803
    802804        EXAMPLES::
     805
    803806            sage: K.<a> = QuadraticField(-3)
    804807            sage: K.class_group()
    805808            Class group of order 1 of Number Field in a with defining polynomial x^2 + 3
     
    825828            sage: R.<x> = K[]
    826829            sage: S.<xbar> = R.quotient(x^2 + 23)
    827830            sage: S.class_group()
    828             [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, 1/2*xbar - 3/2)]
     831            [((2, -a + 1, 1/2*xbar + 1/2, -1/2*a*xbar + 1/2*a + 1), 6, -1/2*xbar + 3/2)]
    829832       
    830833        Here is an example of a product of number fields, both of which
    831834        contribute to the class group::
     
    842845            sage: R.<x> = K[]
    843846            sage: S.<xbar> = R.quotient((x^2 + 23)*(x^2 + 31))
    844847            sage: S.class_group()
    845             [((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)]
     848            [((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 + 1/16*xbar^2 - 31/16*xbar + 47/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 + 3/16*xbar^2 + 23/16*xbar + 85/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 + 37/16*xbar^2 + 115/16*xbar + 867/16)]
    846849
    847850        Note that all the returned values live where we expect them to::
    848851       
     
    896899            sage: L.<b> = K['y'].quotient(y^3 + 5); L
    897900            Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5
    898901            sage: L.S_units([])
    899             [(-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)]
     902            [(-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)]
    900903            sage: L.S_units([K.ideal(1/2*a - 3/2)])
    901             [(-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)]
     904            [((-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 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)]
    902905            sage: L.S_units([K.ideal(2)])
    903             [((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)]
     906            [((1/6*a + 1/2)*b^2 + (-1/3*a - 1)*b + 2/3*a + 1, +Infinity), ((-1/6*a - 1/2)*b^2 + (1/3*a + 1)*b - 1/6*a - 3/2, +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 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)]
    904907
    905908        Note that all the returned values live where we expect them to::
    906909       
     
    930933        where ``gen`` is a unit of order ``order``.
    931934
    932935        EXAMPLES::
     936
    933937            sage: K.<a> = QuadraticField(-3)
    934938            sage: K.unit_group()
    935939            Unit group with structure C6 of Number Field in a with defining polynomial x^2 + 3
     
    950954            sage: L.<b> = K['y'].quotient(y^3 + 5); L
    951955            Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5
    952956            sage: L.units()
    953             [(-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)]
     957            [(-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)]
    954958            sage: L.<b> = K.extension(y^3 + 5)
    955959            sage: L.unit_group()
    956960            Unit group with structure C6 x Z x Z of Number Field in b with defining polynomial x^3 + 5 over its base field
    957961            sage: L.unit_group().gens()
    958             [-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]
     962            [-1/2*a + 1/2, (-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, 2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3]
    959963
    960964        Note that all the returned values live where we expect them to::
    961965       
     
    11341138            sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
    11351139            [2, -a - 1]
    11361140            sage: D.selmer_group([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
    1137             [2, -a - 1, -a]  # 32-bit
    1138             [2, -a - 1, a]   # 64-bit
     1141            [2, -a - 1, a]
    11391142
    11401143        """
    11411144        units, clgp_gens = self._S_class_group_and_units(tuple(S), proof=proof)
  • sage/rings/power_series_ring_element.pyx

    diff --git a/sage/rings/power_series_ring_element.pyx b/sage/rings/power_series_ring_element.pyx
    a b  
    17451745            sage: pari(O(x^1))
    17461746            O(x)
    17471747            sage: pari(O(x^0))
    1748             O(1)
     1748            O(x^0)
    17491749        """
    17501750        n = self.prec()
    17511751        if n is infinity:
  • sage/rings/rational.pyx

    diff --git a/sage/rings/rational.pyx b/sage/rings/rational.pyx
    a b  
    2929    True
    3030"""
    3131
    32 
    33 ###########################################################################
     32#*****************************************************************************
    3433#       Copyright (C) 2004, 2006 William Stein <wstein@gmail.com>
    3534#
    3635#  Distributed under the terms of the GNU General Public License (GPL)
     
    3938#                  http://www.gnu.org/licenses/
    4039#*****************************************************************************
    4140
     41
    4242include "../ext/interrupt.pxi"  # ctrl-c interrupt block support
    4343include "../ext/gmp.pxi"
    4444include "../ext/stdsage.pxi"
     
    12111211            sage: 0.is_norm(K)
    12121212            True
    12131213            sage: (1/7).is_norm(K, element=True)
    1214             (True, -3/7*beta + 5/7)
     1214            (True, -1/7*beta - 3/7)
    12151215            sage: (1/10).is_norm(K, element=True)
    12161216            (False, None)
    12171217            sage: (1/691).is_norm(QQ, element=True)
  • sage/rings/residue_field.pyx

    diff --git a/sage/rings/residue_field.pyx b/sage/rings/residue_field.pyx
    a b  
    1818
    1919    sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
    2020    sage: F = K.factor(2); F
    21     (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (a^2 - 2*a + 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
     21    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
    2222    sage: F[0][0].residue_field()
    23     Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
     23    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
    2424    sage: F[1][0].residue_field()
    25     Residue field of Fractional ideal (a^2 - 2*a + 3)
     25    Residue field of Fractional ideal (-a^2 + 2*a - 3)
    2626    sage: F[2][0].residue_field()
    2727    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
    2828
     
    235235    the index of ZZ[a] in the maximal order for all a::
    236236   
    237237        sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
    238         Fractional ideal (1/2*a^2 - 1/2*a + 1)
     238        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
    239239        sage: F = K.residue_field(P); F
    240         Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
     240        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
    241241        sage: F(a)
    242242        0
    243243        sage: B = K.maximal_order().basis(); B
     
    247247        sage: F(B[2])
    248248        0
    249249        sage: F
    250         Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
     250        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
    251251        sage: F.degree()
    252252        1
    253253   
     
    704704       
    705705            sage: K.<a> = NumberField(x^3-11)
    706706            sage: F = K.ideal(37).factor(); F
    707             (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5)) * (Fractional ideal (37, a + 9))
     707            (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9))
    708708            sage: k = K.residue_field(F[0][0])
    709709            sage: l = K.residue_field(F[1][0])
    710710            sage: k == l
     
    780780            sage: F.reduction_map()
    781781            Partially defined reduction map:
    782782              From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
    783               To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
     783              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
    784784
    785785            sage: K.<theta_5> = CyclotomicField(5)
    786786            sage: F = K.factor(7)[0][0].residue_field()
     
    846846       
    847847            sage: K.<i> = NumberField(x^2 + 1)
    848848            sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2)
    849             (Fractional ideal (i + 2), Fractional ideal (-i + 2))
     849            (Fractional ideal (-i - 2), Fractional ideal (i - 2))
    850850            sage: a = 1/(1+2*i)
    851851            sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2)
    852             (Residue field of Fractional ideal (i + 2), Residue field of Fractional ideal (-i + 2))
     852            (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (i - 2))
    853853            sage: a.valuation(P1)
    854854            0
    855855            sage: F1(i/7)
     
    861861            sage: F2(a)
    862862            Traceback (most recent call last):
    863863            ...
    864             ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (-i + 2): it has negative valuation
     864            ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (i - 2): it has negative valuation
    865865        """
    866866        # The reduction map is just x |--> F(to_vs(x) * (PB**(-1))) if
    867867        # either x is integral or the denominator of x is coprime to
     
    923923            sage: f = k.convert_map_from(K)
    924924            sage: s = f.section(); s
    925925            Lifting map:
    926               From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15)
     926              From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15)
    927927              To:   Number Field in a with defining polynomial x^5 - 5*x + 2
    928928            sage: s(k.gen())
    929929            a
     
    10671067            sage: f = k.coerce_map_from(K.ring_of_integers())
    10681068            sage: s = f.section(); s
    10691069            Lifting map:
    1070               From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15)
     1070              From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15)
    10711071              To:   Maximal Order in Number Field in a with defining polynomial x^5 - 5*x + 2
    10721072            sage: s(k.gen())
    10731073            a
  • sage/schemes/elliptic_curves/ell_number_field.py

    diff --git a/sage/schemes/elliptic_curves/ell_number_field.py b/sage/schemes/elliptic_curves/ell_number_field.py
    a b  
    255255            v =  [1, 1, [[Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)]]]
    256256            (1, 1, [(1/2*a + 3/2 : -a - 2 : 1)])
    257257
     258
    258259        A curve with 2-torsion::
    259260
    260261            sage: K.<a> = NumberField(x^2 + 7, 'a')
     
    673674            sage: K.<i> = NumberField(x^2+1)
    674675            sage: E = EllipticCurve([1 + i, 0, 1, 0, 0])
    675676            sage: E.local_data()
    676             [Local data at Fractional ideal (-i + 2):
     677            [Local data at Fractional ideal (i - 2):
    677678            Reduction type: bad non-split multiplicative
    678679            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
    679680            Minimal discriminant valuation: 1
    680681            Conductor exponent: 1
    681682            Kodaira Symbol: I1
    682683            Tamagawa Number: 1,
    683             Local data at Fractional ideal (-2*i + 3):
     684            Local data at Fractional ideal (-3*i - 2):
    684685            Reduction type: bad split multiplicative
    685686            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
    686687            Minimal discriminant valuation: 2
     
    12271228            Fractional ideal (21*i - 3)
    12281229            sage: K.<a>=NumberField(x^2-x+3)
    12291230            sage: EllipticCurve([1 + a , -1 + a , 1 + a , -11 + a , 5 -9*a  ]).conductor()
    1230             Fractional ideal (-6*a)
     1231            Fractional ideal (6*a)
    12311232
    12321233        A not so well known curve with everywhere good reduction::
    12331234
     
    19341935            sage: K.<i> = QuadraticField(-1)
    19351936            sage: E1 = EllipticCurve([i + 1, 0, 1, -240*i - 400, -2869*i - 2627])
    19361937            sage: E1.conductor()
    1937             Fractional ideal (-7*i + 4)
     1938            Fractional ideal (4*i + 7)
    19381939            sage: E2 = EllipticCurve([1+i,0,1,0,0])
    19391940            sage: E2.conductor()
    1940             Fractional ideal (-7*i + 4)
     1941            Fractional ideal (4*i + 7)
    19411942            sage: E1.is_isogenous(E2)
    19421943            Traceback (most recent call last):
    19431944            ...
  • sage/schemes/elliptic_curves/ell_point.py

    diff --git a/sage/schemes/elliptic_curves/ell_point.py b/sage/schemes/elliptic_curves/ell_point.py
    a b  
    22492249            sage: P = E(26,-120)
    22502250            sage: E.discriminant().support()
    22512251            [Fractional ideal (i + 1),
    2252             Fractional ideal (i + 2),
    2253             Fractional ideal (-i + 2),
     2252            Fractional ideal (-i - 2),
     2253            Fractional ideal (i - 2),
    22542254            Fractional ideal (3)]
    22552255            sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()]
    22562256            [1, 4, 4, 4]
  • sage/schemes/elliptic_curves/heegner.py

    diff --git a/sage/schemes/elliptic_curves/heegner.py b/sage/schemes/elliptic_curves/heegner.py
    a b  
    2222    1
    2323    sage: K.<a> = QuadraticField(-8)
    2424    sage: K.factor(3)
    25     (Fractional ideal (-1/2*a - 1)) * (Fractional ideal (1/2*a - 1))
     25    (Fractional ideal (1/2*a + 1)) * (Fractional ideal (1/2*a - 1))
    2626
    2727Next try an inert prime::
    2828
     
    30673067
    30683068            sage: E = EllipticCurve('77a1')
    30693069            sage: P = E.heegner_point(-19); y = P._trace_numerical_conductor_1(); [c.real() for c in y]
    3070             [-1.261...e-16, -1.00000000000000, 1.00000000000000]
     3070            [-1.2...e-16, -1.00000000000000, 1.00000000000000]
    30713071            sage: -2*E.gens()[0]
    30723072            (0 : -1 : 1)
    30733073            sage: P._trace_index()
  • sage/tests/parigp.py

    diff --git a/sage/tests/parigp.py b/sage/tests/parigp.py
    a b  
    66Check that ticket #9876 has been fixed, this test comes from PARI's
    77self-test "rnfkummer"::
    88
    9     sage: pari('setrand(1); lift(rnfkummer(bnrinit(bnfinit(y^4-52*y^2+26,1),3,1),Mat(5)))')  # long time (20s)
    10     x^5 + (271904041183967733994046247238451220821090509512*y^3 - 1951185705041181642436424569854379731092185884540*y^2 - 137284994097565694729325775891384389028612513206*y + 985158395339963027005392830702972831792997887634)*x^3 + (-1103348115575813134375303837074506934430420942163005575523338936017803350*y^3 + 7917635423226514263778516726505738810442291519011310881850697392530203395*y^2 + 557083146937342089069054713241427216069850057095235301045152439974193510*y - 3997633381162543999426766308119561385414529640616720334415746560814376180)*x^2 + (-2850954023243036096630991092337514676958719924107222861736180364972638480781931160479612414374726*y^3 + 20458470219654296770142821681578729154287092012368195294232388680084456467634834922261450405421440*y^2 + 1439453619958444032900155401589975194411198855527240989192600353061458313354165698293801750226548*y - 10329531369641085332335285499139041562885370528717265413271645980864343547065554613697543061718337)*x + (7969009544373922452879653474581210819181907572954425670591507532481862891961593320966986222048464793309407015919174791292*y^3 - 57185679991520706558201587884474878754793973249055306464210264229366167363021184981020031604487306119075033280549751964931*y^2 - 4023572299873094155685487487735877157131590929317029881918122301944985482705502807478956480052756681286034433588202047464*y + 28873188905355566125046596578847210322680564479166267499825484829967336324999953758226330432543865379229039340859680880978)
     9    sage: pari('setrand(1); lift(rnfkummer(bnrinit(bnfinit(y^4-52*y^2+26,1),3,1),Mat(5)))')  # long time (4s on sage.math, 2011)
     10    x^5 + (-12490585381661544359255403301035053110061910*y^3 + 8875378520404561472503422910872004290197460*y^2 + 643203912732761873050292808675549433737179610*y - 457038484130159980782436350930533714409061170)*x^3 + (-134027514281645340620300162483056350640850689292892267066826165512*y^3 + 95235243030030469814112992330493778292557062830362488860799262053*y^2 + 6901759924725033375901003506523314713919218011682438894990413482822*y - 4904148131739972327284545793455166015180538153351582525198684659988)*x^2 + (-47397957557570888155708856849994683849365520972511563824369572802678417823703951003630*y^3 + 33679323468496441220407209890566679520252152888549909181980050360738580514765560899830*y^2 + 2440762448949326006691055037485233408803108189791110990339027554592708168372793653934980*y - 1734320048033240933678067521047553381449799255523887315704756124974424249211251806055445)*x + (88847913213212543643724914281374137431466584547137800780754135469698376356168903046151157223082894732483818/5*y^3 - 63132205749445286461822170095386361952302057584137825393349862937480952856334509099209369622841067534904427/5*y^2 - 4575231959624371057665356018310756876851369587901000773265750996233180145132238920504044583057371848969400608/5*y + 3250999094748458040342075570309205473235256099747294466325048378505864671503910959921397017511503388596960342/5)
    1111
     12Check that ticket #10195 (PARI bug 1153) has been fixed::
     13
     14    sage: print gp.eval("mathnf([0,0,0,0,0,0,0,0,0,13;0,0,0,0,0,0,0,0,23,6;0,0,0,0,0,0,0,23,-4,-7;0,0,0,0,0,0,17,-3,5,-5;0,0,0,0,0,56,16,-16,-15,-17;0,0,0,0,57,24,-16,-25,2,-21;0,0,0,114,9,56,51,-52,25,-55;0,0,113,-31,-11,24,0,28,34,-16;0,50,3,2,16,-6,-2,7,-19,-21;118,43,51,23,37,-52,18,38,51,28],0)")
     15    [787850171872400 32189386376004 356588299060422 742392731867995 282253457851430 665185047494955 664535243562463 744564809133574 113975061998590 527459013372200]
     16    [0 12 6 11 5 3 7 6 6 0]
     17    [0 0 3 1 2 1 1 0 0 0]
     18    [0 0 0 1 0 0 0 0 0 0]
     19    [0 0 0 0 1 0 0 0 0 0]
     20    [0 0 0 0 0 1 0 0 0 0]
     21    [0 0 0 0 0 0 1 0 0 0]
     22    [0 0 0 0 0 0 0 1 0 0]
     23    [0 0 0 0 0 0 0 0 1 0]
     24    [0 0 0 0 0 0 0 0 0 1]
    1225
    1326"""
    14