diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index 2d68e3080ca..3b7a4725582 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -202,9 +202,9 @@ cpdef factor_aurifeuillian(n, check=True): def factor_cunningham(m, proof=None): r""" - Return factorization of self obtained using trial division + Return factorization of ``self`` obtained using trial division for all primes in the so called Cunningham table. This is - efficient if self has some factors of type `b^n+1` or `b^n-1`, + efficient if ``self`` has some factors of type `b^n+1` or `b^n-1`, with `b` in `\{2,3,5,6,7,10,11,12\}`. You need to install an optional package to use this method, @@ -245,12 +245,12 @@ def factor_cunningham(m, proof=None): cpdef factor_trial_division(m, long limit=LONG_MAX): r""" - Return partial factorization of self obtained using trial division - for all primes up to limit, where limit must fit in a C signed long. + Return partial factorization of ``self`` obtained using trial division + for all primes up to ``limit``, where ``limit`` must fit in a C ``signed long``. INPUT: - - ``limit`` -- integer (default: ``LONG_MAX``) that fits in a C signed long + - ``limit`` -- integer (default: ``LONG_MAX``) that fits in a C ``signed long`` EXAMPLES:: @@ -294,7 +294,7 @@ def factor_using_pari(n, int_=False, debug_level=0, proof=None): r""" Factor this integer using PARI. - This function returns a list of pairs, not a ``Factorization`` + This function returns a list of pairs, not a :class:`Factorization` object. The first element of each pair is the factor, of type ``Integer`` if ``int_`` is ``False`` or ``int`` otherwise, the second element is the positive exponent, of type ``int``. diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx index 88f2ca583e4..dfaa7782962 100644 --- a/src/sage/rings/fast_arith.pyx +++ b/src/sage/rings/fast_arith.pyx @@ -59,16 +59,16 @@ cpdef prime_range(start, stop=None, algorithm=None, bint py_ints=False): - ``algorithm`` -- optional string (default: ``None``), one of: - - ``None``: Use algorithm ``"pari_primes"`` if ``stop`` <= 436273009 - (approximately 4.36E8). Otherwise use algorithm ``"pari_isprime"``. + - ``None``: Use algorithm ``"pari_primes"`` if ``stop`` <= 436273009 + (approximately 4.36E8). Otherwise use algorithm ``"pari_isprime"``. - - ``"pari_primes"``: Use PARI's :pari:`primes` function to generate all - primes from 2 to stop. This is fast but may crash if there is - insufficient memory. Raises an error if ``stop`` > 436273009. + - ``"pari_primes"``: Use PARI's :pari:`primes` function to generate all + primes from 2 to stop. This is fast but may crash if there is + insufficient memory. Raises an error if ``stop`` > 436273009. - - ``"pari_isprime"``: Wrapper for ``list(primes(start, stop))``. Each (odd) - integer in the specified range is tested for primality by applying PARI's - :pari:`isprime` function. This is slower but will work for much larger input. + - ``"pari_isprime"``: Wrapper for ``list(primes(start, stop))``. Each (odd) + integer in the specified range is tested for primality by applying PARI's + :pari:`isprime` function. This is slower but will work for much larger input. - ``py_ints`` -- optional boolean (default ``False``), return Python ints rather than Sage Integers (faster). Ignored unless algorithm ``"pari_primes"`` is being diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index 71a4c9102eb..388ef3a32d9 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -802,7 +802,8 @@ def ngens(self): EXAMPLES:: sage: R = Frac(PolynomialRing(QQ,'z',10)); R - Fraction Field of Multivariate Polynomial Ring in z0, z1, z2, z3, z4, z5, z6, z7, z8, z9 over Rational Field + Fraction Field of Multivariate Polynomial Ring + in z0, z1, z2, z3, z4, z5, z6, z7, z8, z9 over Rational Field sage: R.ngens() 10 """ @@ -815,7 +816,8 @@ def gen(self, i=0): EXAMPLES:: sage: R = Frac(PolynomialRing(QQ,'z',10)); R - Fraction Field of Multivariate Polynomial Ring in z0, z1, z2, z3, z4, z5, z6, z7, z8, z9 over Rational Field + Fraction Field of Multivariate Polynomial Ring + in z0, z1, z2, z3, z4, z5, z6, z7, z8, z9 over Rational Field sage: R.0 z0 sage: R.gen(3) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 10a94aa156d..442f0447d92 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -25,7 +25,7 @@ Add an integer and a rational number:: Add an integer and a complex number:: sage: b = ComplexField().0 + 1.5 - sage: loads((a+b).dumps()) == a+b + sage: loads((a + b).dumps()) == a + b True sage: z = 32 @@ -354,7 +354,7 @@ cdef class IntegerWrapper(Integer): ``Integers`` (with initialized ``parent`` and ``mpz_t`` fields) into a pool on "deallocation" and then pull them out whenever a new one is needed. Because ``Integers`` are so common, this is - actually a significant savings. However , this does cause issues + actually a significant savings. However, this does cause issues with subclassing a Python class directly from ``Integer`` (but that's ok for a Cython class). @@ -762,7 +762,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def _im_gens_(self, codomain, im_gens, base_map=None): """ - Return the image of self under the map that sends the generators of + Return the image of ``self`` under the map that sends the generators of the parent to im_gens. Since ZZ maps canonically in the category of rings, this is just the natural coercion. @@ -1077,7 +1077,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: - sage: two=Integer(2) + sage: two = Integer(2) sage: two.str(1) Traceback (most recent call last): ... @@ -1364,7 +1364,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Return a list of digits for ``self`` in the given base in little endian order. - The returned value is unspecified if self is a negative number + The returned value is unspecified if ``self`` is a negative number and the digits are given. INPUT: @@ -1695,7 +1695,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def ndigits(self, base=10): """ - Return the number of digits of self expressed in the given base. + Return the number of digits of ``self`` expressed in the given base. INPUT: @@ -2316,25 +2316,25 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def nth_root(self, int n, bint truncate_mode=0): r""" - Returns the (possibly truncated) n'th root of self. + Returns the (possibly truncated) ``n``-th root of ``self``. INPUT: - - ``n`` - integer >= 1 (must fit in C int type). + - ``n`` - integer >= 1 (must fit in the C ``int`` type). - ``truncate_mode`` - boolean, whether to allow truncation if - self is not an n'th power. + ``self`` is not an n'th power. OUTPUT: - If truncate_mode is 0 (default), then returns the exact n'th root - if self is an n'th power, or raises a ValueError if it is not. + If ``truncate_mode`` is 0 (default), then returns the exact n'th root + if ``self`` is an n'th power, or raises a ValueError if it is not. - If truncate_mode is 1, then if either n is odd or self is - positive, returns a pair (root, exact_flag) where root is the - truncated nth root (rounded towards zero) and exact_flag is a + If ``truncate_mode`` is 1, then if either n is odd or ``self`` is + positive, returns a pair ``(root, exact_flag)`` where ``root`` is the + truncated ``n``-th root (rounded towards zero) and ``exact_flag`` is a boolean indicating whether the root extraction was exact; - otherwise raises a ValueError. + otherwise raises a :class:`ValueError`. AUTHORS: @@ -2643,11 +2643,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: # The following are very very fast. sage: # Note that for base m a perfect power of 2, we get the exact log by counting bits. - sage: n=2983579823750185701375109835; m=32 + sage: n = 2983579823750185701375109835; m = 32 sage: n.exact_log(m) 18 sage: # The next is a favorite of mine. The log2 approximate is exact and immediately provable. - sage: n=90153710570912709517902579010793251709257901270941709247901209742124;m=213509721309572 + sage: n = 90153710570912709517902579010793251709257901270941709247901209742124 + sage: m = 213509721309572 sage: n.exact_log(m) 4 @@ -2663,9 +2664,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: x.exact_log(3) 100000 - sage: (x+1).exact_log(3) + sage: (x + 1).exact_log(3) 100000 - sage: (x-1).exact_log(3) + sage: (x - 1).exact_log(3) 99999 :: @@ -2751,19 +2752,19 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def log(self, m=None, prec=None): r""" Returns symbolic log by default, unless the logarithm is exact (for - an integer argument). When precision is given, the RealField + an integer argument). When ``prec`` is given, the :class:`RealField` approximation to that bit precision is used. This function is provided primarily so that Sage integers may be treated in the same manner as real numbers when convenient. Direct - use of exact_log is probably best for arithmetic log computation. + use of :meth:`exact_log` is probably best for arithmetic log computation. INPUT: - ``m`` - default: natural log base e - - ``prec`` - integer (default: None): if None, returns - symbolic, else to given bits of precision as in RealField + - ``prec`` - integer (default: ``None``): if ``None``, returns + symbolic, else to given bits of precision as in :class:`RealField` EXAMPLES:: @@ -2784,8 +2785,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: log(x, 3) 100000 - With the new Pynac symbolic backend, log(x) also - works in a reasonable amount of time for this x:: + Also ``log(x)``, giving a symbolic output, + works in a reasonable amount of time for this ``x``:: sage: x = 3^100000 sage: log(x) @@ -2794,20 +2795,20 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): But approximations are probably more useful in this case, and work to as high a precision as we desire:: - sage: x.log(3,53) # default precision for RealField + sage: x.log(3, 53) # default precision for RealField 100000.000000000 - sage: (x+1).log(3,53) + sage: (x +1 ).log(3, 53) 100000.000000000 - sage: (x+1).log(3,1000) + sage: (x + 1).log(3, 1000) 100000.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 We can use non-integer bases, with default e:: - sage: x.log(2.5,prec=53) + sage: x.log(2.5, prec=53) 119897.784671579 We also get logarithms of negative integers, via the - symbolic ring, using the branch from `-pi` to `pi`:: + symbolic ring, using the branch from `-\pi` to `\pi`:: sage: log(-1) I*pi @@ -2872,7 +2873,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def exp(self, prec=None): r""" - Returns the exponential function of self as a real number. + Returns the exponential function of ``self`` as a real number. This function is provided only so that Sage integers may be treated in the same manner as real numbers when convenient. @@ -2911,7 +2912,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def prime_to_m_part(self, m): """ - Returns the prime-to-m part of self, i.e., the largest divisor of + Returns the prime-to-m part of ``self``, i.e., the largest divisor of ``self`` that is coprime to ``m``. INPUT: @@ -3394,7 +3395,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def quo_rem(Integer self, other): """ - Returns the quotient and the remainder of self divided by other. + Returns the quotient and the remainder of ``self`` divided by other. Note that the remainder returned is always either zero or of the same sign as other. @@ -3484,7 +3485,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def powermod(self, exp, mod): r""" - Compute self\*\*exp modulo mod. + Compute ``self**exp`` modulo ``mod``. EXAMPLES:: @@ -3517,11 +3518,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): return x def rational_reconstruction(self, Integer m): - """ - Return the rational reconstruction of this integer modulo m, i.e., - the unique (if it exists) rational number that reduces to self + r""" + Return the rational reconstruction of this integer modulo `m`, i.e., + the unique (if it exists) rational number that reduces to ``self`` modulo m and whose numerator and denominator is bounded by - sqrt(m/2). + `\sqrt{m/2}`. INPUT: @@ -3687,17 +3688,15 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def trial_division(self, long bound=LONG_MAX, long start=2): """ - Return smallest prime divisor of self up to bound, beginning - checking at start, or abs(self) if no such divisor is found. + Return smallest prime divisor of ``self`` up to bound, beginning + checking at ``start``, or ``abs(self)`` if no such divisor is found. INPUT: - - ``bound`` -- a positive integer that fits in a C signed long - - ``start`` -- a positive integer that fits in a C signed long + - ``bound`` -- a positive integer that fits in a C ``signed long`` + - ``start`` -- a positive integer that fits in a C ``signed long`` - OUTPUT: - - - a positive integer + OUTPUT: A positive integer EXAMPLES:: @@ -3885,7 +3884,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: dict(f)[3] 6 - We use proof=False, which doesn't prove correctness of the primes + We use ``proof=False``, which doesn't prove correctness of the primes that appear in the factorization:: sage: n = 920384092842390423848290348203948092384082349082 @@ -4154,7 +4153,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): cpdef RingElement _valuation(Integer self, Integer p): r""" - Return the p-adic valuation of self. + Return the p-adic valuation of ``self``. We do not require that p be prime, but it must be at least 2. For more documentation see ``valuation`` @@ -4179,8 +4178,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): cdef object _val_unit(Integer self, Integer p): r""" - Returns a pair: the p-adic valuation of self, and the p-adic unit - of self. + Returns a pair: the p-adic valuation of ``self``, and the p-adic unit + of ``self``. We do not require the p be prime, but it must be at least 2. For more documentation see ``val_unit`` @@ -4204,7 +4203,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def valuation(self, p): """ - Return the p-adic valuation of self. + Return the p-adic valuation of ``self``. INPUT: @@ -4265,8 +4264,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def val_unit(self, p): r""" - Returns a pair: the p-adic valuation of self, and the p-adic unit - of self. + Returns a pair: the p-adic valuation of ``self``, and the p-adic unit + of ``self``. INPUT: @@ -4301,10 +4300,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): IMPLEMENTATION: - Currently returns 0 when self is 0. This behaviour is fairly arbitrary, + Currently returns 0 when ``self`` is 0. This behaviour is fairly arbitrary, and in Sage 4.6 this special case was not handled at all, eventually propagating a TypeError. The caller should not rely on the behaviour - in case self is 0. + in case ``self`` is 0. EXAMPLES:: @@ -4328,10 +4327,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): cdef Integer _divide_knowing_divisible_by(Integer self, Integer right): r""" - Returns the integer self / right when self is divisible by right. + Returns the integer ``self`` / ``right`` when ``self`` is divisible by right. - If self is not divisible by right, the return value is undefined, - and may not even be close to self/right. For more documentation see + If ``self`` is not divisible by right, the return value is undefined, + and may not even be close to ``self`` / ``right``. For more documentation see ``divide_knowing_divisible_by`` AUTHORS: @@ -4354,10 +4353,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def divide_knowing_divisible_by(self, right): r""" - Returns the integer self / right when self is divisible by right. + Returns the integer ``self`` / ``right`` when ``self`` is divisible by ``right``. - If self is not divisible by right, the return value is undefined, - and may not even be close to self/right for multi-word integers. + If ``self`` is not divisible by right, the return value is undefined, + and may not even be close to ``self`` / ``right`` for multi-word integers. EXAMPLES:: @@ -4384,7 +4383,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def _lcm(self, Integer n): """ - Returns the least common multiple of self and `n`. + Returns the least common multiple of ``self`` and `n`. EXAMPLES:: @@ -4400,7 +4399,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def _gcd(self, Integer n): """ - Return the greatest common divisor of self and `n`. + Return the greatest common divisor of ``self`` and `n`. EXAMPLES:: @@ -4517,7 +4516,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def multifactorial(self, long k): r""" - Compute the k-th factorial `n!^{(k)}` of self. + Compute the k-th factorial `n!^{(k)}` of ``self``. The multifactorial number `n!^{(k)}` is defined for non-negative integers `n` as follows. For `k=1` this is the standard factorial, @@ -4619,7 +4618,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def floor(self): """ - Return the floor of self, which is just self since self is an + Return the floor of ``self``, which is just self since ``self`` is an integer. EXAMPLES:: @@ -4632,7 +4631,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def ceil(self): """ - Return the ceiling of self, which is self since self is an + Return the ceiling of ``self``, which is ``self`` since ``self`` is an integer. EXAMPLES:: @@ -4645,8 +4644,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def trunc(self): """ - Round this number to the nearest integer, which is self since - self is an integer. + Round this number to the nearest integer, which is ``self`` since + ``self`` is an integer. EXAMPLES:: @@ -4658,8 +4657,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def round(Integer self, mode="away"): """ - Returns the nearest integer to ``self``, which is self since - self is an integer. + Returns the nearest integer to ``self``, which is ``self`` since + ``self`` is an integer. EXAMPLES: @@ -4673,7 +4672,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def real(self): """ - Returns the real part of self, which is self. + Returns the real part of ``self``, which is ``self``. EXAMPLES:: @@ -4684,7 +4683,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def imag(self): """ - Returns the imaginary part of self, which is zero. + Returns the imaginary part of ``self``, which is zero. EXAMPLES:: @@ -4771,7 +4770,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def is_square(self): r""" - Returns ``True`` if self is a perfect square. + Returns ``True`` if ``self`` is a perfect square. EXAMPLES:: @@ -5022,8 +5021,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): .. NOTE:: - For large integers self, is_power_of() is faster than - is_perfect_power(). The following examples gives some indication of + For large integers ``self``, :meth:`is_power_of` is faster than + :meth:`is_perfect_power`. The following examples give some indication of how much faster. :: @@ -5031,15 +5030,15 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: b = lcm(range(1,10000)) sage: b.exact_log(2) 14446 - sage: t=cputime() + sage: t = cputime() sage: for a in range(2, 1000): k = b.is_perfect_power() sage: cputime(t) # random 0.53203299999999976 - sage: t=cputime() + sage: t = cputime() sage: for a in range(2, 1000): k = b.is_power_of(2) sage: cputime(t) # random 0.0 - sage: t=cputime() + sage: t = cputime() sage: for a in range(2, 1000): k = b.is_power_of(3) sage: cputime(t) # random 0.032002000000000308 @@ -5049,19 +5048,20 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: b = lcm(range(1, 1000)) sage: b.exact_log(2) 1437 - sage: t=cputime() - sage: for a in range(2, 10000): k = b.is_perfect_power() # note that we change the range from the example above + sage: t = cputime() + sage: for a in range(2, 10000): # note that we change the range from the example above + ....: k = b.is_perfect_power() sage: cputime(t) # random 0.17201100000000036 - sage: t=cputime(); TWO=int(2) + sage: t = cputime(); TWO = int(2) sage: for a in range(2, 10000): k = b.is_power_of(TWO) sage: cputime(t) # random 0.0040000000000000036 - sage: t=cputime() + sage: t = cputime() sage: for a in range(2, 10000): k = b.is_power_of(3) sage: cputime(t) # random 0.040003000000000011 - sage: t=cputime() + sage: t = cputime() sage: for a in range(2, 10000): k = b.is_power_of(a) sage: cputime(t) # random 0.02800199999999986 @@ -5140,7 +5140,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: (p*q).is_prime_power(get_data=True) # optional - sage.libs.pari (10000000000000000016800000000000000005031, 0) - The method works for large entries when `proof=False`:: + The method works for large entries when ``proof=False``:: sage: proof.arithmetic(False) sage: ((10^500 + 961)^4).is_prime_power() # optional - sage.libs.pari @@ -5262,7 +5262,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): ALGORITHM: - Calls the PARI ``isprime`` function. + Calls the PARI function :pari:`isprime`. TESTS: @@ -5331,7 +5331,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def is_irreducible(self): r""" - Returns ``True`` if self is irreducible, i.e. +/- + Returns ``True`` if ``self`` is irreducible, i.e. +/- prime EXAMPLES:: @@ -5358,7 +5358,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): This uses PARI's Baillie-PSW probabilistic primality test. Currently, there are no known pseudoprimes for - Baillie-PSW that are not actually prime. However it is + Baillie-PSW that are not actually prime. However, it is conjectured that there are infinitely many. See :wikipedia:`Baillie-PSW_primality_test` @@ -5423,7 +5423,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): - :meth:`perfect_power`: Finds the minimal base for which this integer is a perfect power. - - :meth:`is_power_of`: If you know the base already this method is + - :meth:`is_power_of`: If you know the base already, this method is the fastest option. - :meth:`is_prime_power`: Checks whether the base is prime. @@ -5515,7 +5515,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def jacobi(self, b): r""" - Calculate the Jacobi symbol `\left(\frac{self}{b}\right)`. + Calculate the Jacobi symbol `\left(\frac{\text{self}}{b}\right)`. EXAMPLES:: @@ -5552,9 +5552,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def kronecker(self, b): r""" - Calculate the Kronecker symbol `\left(\frac{self}{b}\right)` - with the Kronecker extension `(self/2)=(2/self)` when `self` is odd, - or `(self/2)=0` when `self` is even. + Calculate the Kronecker symbol `\left(\frac{\text{self}}{b}\right)` + with the Kronecker extension `(\text{self}/2)=(2/\text{self})` when ``self`` is odd, + or `(\text{self}/2)=0` when ``self`` is even. EXAMPLES:: @@ -5589,7 +5589,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): - ``proof`` (boolean, default ``True``) -- if ``False`` then for negative discriminants a faster algorithm is used by the PARI library which is known to give incorrect results - when the class group has many cyclic factors. However the + when the class group has many cyclic factors. However, the results are correct for discriminants `D` with `|D|\le 2\cdot10^{10}`. OUTPUT: @@ -5662,7 +5662,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Use ``self.radical()`` for the product of the primes that divide self. - If self is 0, just returns 0. + If ``self`` is 0, just returns 0. EXAMPLES:: @@ -5738,7 +5738,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def next_probable_prime(self): """ - Return the next probable prime after self, as determined by PARI. + Return the next probable prime after ``self``, as determined by PARI. EXAMPLES:: @@ -5759,9 +5759,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def next_prime(self, proof=None): r""" - Return the next prime after self. + Return the next prime after ``self``. - This method calls the PARI ``nextprime`` function. + This method calls the PARI function :pari:`nextprime`. INPUT: @@ -5798,9 +5798,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def previous_prime(self, proof=None): r""" - Returns the previous prime before self. + Returns the previous prime before ``self``. - This method calls the PARI ``precprime`` function. + This method calls the PARI function :pari:`precprime`. INPUT: @@ -5846,7 +5846,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def next_prime_power(self, proof=None): r""" - Return the next prime power after self. + Return the next prime power after ``self``. INPUT: @@ -5858,7 +5858,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): ALGORITHM: - The algorithm is naive. It computes the next power of 2 and go through + The algorithm is naive. It computes the next power of 2 and goes through the odd numbers calling :meth:`is_prime_power`. .. SEEALSO:: @@ -5912,7 +5912,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def previous_prime_power(self, proof=None): r""" - Return the previous prime power before self. + Return the previous prime power before ``self``. INPUT: @@ -5924,7 +5924,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): ALGORITHM: - The algorithm is naive. It computes the previous power of 2 and go + The algorithm is naive. It computes the previous power of 2 and goes through the odd numbers calling the method :meth:`is_prime_power`. .. SEEALSO:: @@ -5983,7 +5983,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def additive_order(self): """ - Return the additive order of self. + Return the additive order of ``self``. EXAMPLES:: @@ -5999,7 +5999,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def multiplicative_order(self): r""" - Return the multiplicative order of self. + Return the multiplicative order of ``self``. EXAMPLES:: @@ -6242,9 +6242,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def sqrtrem(self): r""" - Return (s, r) where s is the integer square root of self and + Return (s, r) where s is the integer square root of ``self`` and r is the remainder such that `\text{self} = s^2 + r`. - Raises ``ValueError`` if self is negative. + Raises ``ValueError`` if ``self`` is negative. EXAMPLES:: @@ -6272,8 +6272,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def isqrt(self): r""" - Returns the integer floor of the square root of self, or raises an - ``ValueError`` if self is negative. + Returns the integer floor of the square root of ``self``, or raises an + ``ValueError`` if ``self`` is negative. EXAMPLES:: @@ -6315,7 +6315,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): is not None. - ``all`` - bool (default: False); if True, return all - square roots of self (a list of length 0, 1 or 2). + square roots of ``self`` (a list of length 0, 1 or 2). EXAMPLES:: @@ -6752,7 +6752,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def __invert__(self): """ - Return the multiplicative inverse of self, as a rational number. + Return the multiplicative inverse of ``self``, as a rational number. EXAMPLES:: @@ -6778,8 +6778,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def inverse_of_unit(self): """ - Return inverse of self if self is a unit in the integers, i.e., - self is -1 or 1. Otherwise, raise a ZeroDivisionError. + Return inverse of ``self`` if ``self`` is a unit in the integers, i.e., + ``self`` is -1 or 1. Otherwise, raise a :class:`ZeroDivisionError`. EXAMPLES:: @@ -6803,7 +6803,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): def inverse_mod(self, n): r""" - Return the inverse of self modulo `n`, if this inverse exists. + Return the inverse of ``self`` modulo `n`, if this inverse exists. Otherwise, raises a ``ZeroDivisionError`` exception. @@ -7271,7 +7271,7 @@ def GCD_list(v): @cython.binding(True) def make_integer(s): """ - Create a Sage integer from the base-32 Python *string* s. This is + Create a Sage integer from the base-32 Python *string* ``s``. This is used in unpickling integers. EXAMPLES:: diff --git a/src/sage/rings/invariants/invariant_theory.py b/src/sage/rings/invariants/invariant_theory.py index 0c0aa1c9f69..4d50c289fb3 100644 --- a/src/sage/rings/invariants/invariant_theory.py +++ b/src/sage/rings/invariants/invariant_theory.py @@ -140,15 +140,15 @@ def _guess_variables(polynomial, *args): sage: from sage.rings.invariants.invariant_theory import _guess_variables sage: R. = QQ[] - sage: _guess_variables(x^2+y^2) + sage: _guess_variables(x^2 + y^2) (x, y) sage: _guess_variables([x^2, y^2]) (x, y) - sage: _guess_variables(x^2+y^2, x) + sage: _guess_variables(x^2 + y^2, x) (x,) - sage: _guess_variables(x^2+y^2, x,y) + sage: _guess_variables(x^2 + y^2, x, y) (x, y) - sage: _guess_variables(x^2+y^2, [x,y]) + sage: _guess_variables(x^2 + y^2, [x,y]) (x, y) """ if isinstance(polynomial, (list, tuple)): @@ -177,7 +177,7 @@ def transvectant(f, g, h=1, scale='default'): INPUT: - - ``f,g`` -- two homogeneous binary forms in the same polynomial ring. + - ``f``, ``g`` -- two homogeneous binary forms in the same polynomial ring. - ``h`` -- the order of the transvectant. If it is not specified, the first transvectant is returned. @@ -214,14 +214,14 @@ def transvectant(f, g, h=1, scale='default'): factor will not be invertible in that case. The scale argument ``'none'`` can be used to compute the transvectant in this case:: - sage: R. = GF(5)[] - sage: p = a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 + a3*x1^2*x0^3 + a4*x1*x0^4 + a5*x0^5 - sage: f = AlgebraicForm(2, 5, p, x0, x1) - sage: transvectant(f, f, 4) + sage: R. = GF(5)[] # optional - sage.rings.finite_rings + sage: f = AlgebraicForm(2, 5, a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 # optional - sage.rings.finite_rings + ....: + a3*x1^2*x0^3 + a4*x1*x0^4 + a5*x0^5, x0, x1) + sage: transvectant(f, f, 4) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ZeroDivisionError - sage: transvectant(f, f, 4, scale='none') + sage: transvectant(f, f, 4, scale='none') # optional - sage.rings.finite_rings Binary quadratic given by -a3^2*x0^2 + a2*a4*x0^2 + a2*a3*x0*x1 - a1*a4*x0*x1 - a2^2*x1^2 + a1*a3*x1^2 @@ -230,8 +230,8 @@ def transvectant(f, g, h=1, scale='default'): it to the scaled version:: sage: R. = QQ[] - sage: p = a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 + a3*x1^2*x0^3 + a4*x1*x0^4 + a5*x0^5 - sage: f = AlgebraicForm(2, 5, p, x0, x1) + sage: f = AlgebraicForm(2, 5, a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 + ....: + a3*x1^2*x0^3 + a4*x1*x0^4 + a5*x0^5, x0, x1) sage: transvectant(f, f, 4) Binary quadratic given by 3/50*a3^2*x0^2 - 4/25*a2*a4*x0^2 + 2/5*a1*a5*x0^2 + 1/25*a2*a3*x0*x1 - 6/25*a1*a4*x0*x1 + 2*a0*a5*x0*x1 @@ -247,14 +247,14 @@ def transvectant(f, g, h=1, scale='default'): one variable:: sage: R. = QQ[] - sage: quintic = invariant_theory.binary_quintic(x^5+x^3+2*x^2+y^5, x) + sage: quintic = invariant_theory.binary_quintic(x^5 + x^3 + 2*x^2 + y^5, x) sage: transvectant(quintic, quintic, 2) Traceback (most recent call last): ... ValueError: polynomial is not homogeneous sage: R. = QQ[] sage: S. = R[] - sage: quintic = invariant_theory.binary_quintic(x^5+x^3+2*x^2+y^5, x) + sage: quintic = invariant_theory.binary_quintic(x^5 + x^3 + 2*x^2 + y^5, x) sage: transvectant(quintic, quintic, 2) Binary sextic given by 1/5*x^6 + 6/5*x^5*h - 3/25*x^4*h^2 + (50*y^5 - 8)/25*x^3*h^3 - 12/25*x^2*h^4 + (3*y^5)/5*x*h^5 @@ -387,12 +387,12 @@ def ring(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4+t*x^2*y^2, [x,y]) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4 + t*x^2*y^2, [x,y]) sage: quartic.ring() Multivariate Polynomial Ring in x, y, t over Rational Field sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+1+t*x^2, [x]) + sage: quartic = invariant_theory.binary_quartic(x^4 + 1 + t*x^2, [x]) sage: quartic.ring() Multivariate Polynomial Ring in x, y, t over Rational Field """ @@ -411,12 +411,12 @@ def variables(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4+t*x^2*y^2, [x,y]) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4 + t*x^2*y^2, [x,y]) sage: quartic.variables() (x, y) sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+1+t*x^2, [x]) + sage: quartic = invariant_theory.binary_quartic(x^4 + 1 + t*x^2, [x]) sage: quartic.variables() (x, None) """ @@ -435,14 +435,14 @@ def is_homogeneous(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4+t*x^2*y^2, [x,y]) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4 + t*x^2*y^2, [x,y]) sage: quartic.is_homogeneous() True sage: quartic.form() x^2*y^2*t + x^4 + y^4 sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+1+t*x^2, [x]) + sage: quartic = invariant_theory.binary_quartic(x^4 + 1 + t*x^2, [x]) sage: quartic.is_homogeneous() False sage: quartic.form() @@ -509,7 +509,7 @@ class AlgebraicForm(FormsBase): ... ValueError: polynomial is of the wrong degree - sage: AlgebraicForm(2, 2, x^2+y, [x,y]).variables() + sage: AlgebraicForm(2, 2, x^2 + y, [x,y]).variables() Traceback (most recent call last): ... ValueError: polynomial is not homogeneous @@ -654,7 +654,7 @@ def _repr_(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4) sage: quartic._repr_() 'Binary quartic with coefficients (1, 0, 0, 0, 1)' @@ -699,7 +699,7 @@ def form(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4) sage: quartic.form() x^4 + y^4 sage: quartic.polynomial() @@ -798,7 +798,7 @@ def _extract_coefficients(self, monomials): (a30, a03, a00, a21, a20, a12, a02, a10, a01, a11) sage: T. = QQ[] - sage: univariate = AlgebraicForm(2, 3, t^3+2*t^2+3*t+4) + sage: univariate = AlgebraicForm(2, 3, t^3 + 2*t^2 + 3*t + 4) sage: m = [t^3, 1, t, t^2] sage: univariate._extract_coefficients(m) (1, 4, 3, 2) @@ -812,7 +812,7 @@ def _extract_coefficients(self, monomials): Check for :trac:`30035`:: sage: R. = QQ[] - sage: f = 3*a**3+b**3+a*b*c + sage: f = 3*a**3 + b**3 + a*b*c sage: T = invariant_theory.ternary_cubic(f) sage: T.S_invariant().parent() Rational Field @@ -913,9 +913,9 @@ def transformed(self, g): sage: R. = QQ[] sage: cubic = invariant_theory.ternary_cubic(x^3 + 2*y^3 + 3*z^3 + 4*x*y*z) - sage: cubic.transformed({x:y, y:z, z:x}).form() + sage: cubic.transformed({x: y, y: z, z: x}).form() 3*x^3 + y^3 + 4*x*y*z + 2*z^3 - sage: cyc = matrix([[0,1,0],[0,0,1],[1,0,0]]) + sage: cyc = matrix([[0,1,0], [0,0,1], [1,0,0]]) sage: cubic.transformed(cyc) == cubic.transformed({x:y, y:z, z:x}) True sage: g = matrix(QQ, [[1, 0, 0], [-1, 1, -3], [-5, -5, 16]]) @@ -981,11 +981,11 @@ def __init__(self, n, d, polynomial, *args): sage: R. = QQ[] sage: from sage.rings.invariants.invariant_theory import QuadraticForm - sage: form = QuadraticForm(2, 2, x^2+2*y^2+3*x*y) + sage: form = QuadraticForm(2, 2, x^2 + 2*y^2 + 3*x*y) sage: form Binary quadratic with coefficients (1, 2, 3) sage: form._check_covariant('discriminant', invariant=True) - sage: QuadraticForm(3, 2, x^2+y^2) + sage: QuadraticForm(3, 2, x^2 + y^2) Ternary quadratic with coefficients (1, 1, 0, 0, 0, 0) """ assert d == 2 @@ -1033,11 +1033,11 @@ def monomials(self): EXAMPLES:: sage: R. = QQ[] - sage: quadratic = invariant_theory.quadratic_form(x^2+y^2) + sage: quadratic = invariant_theory.quadratic_form(x^2 + y^2) sage: quadratic.monomials() (x^2, y^2, x*y) - sage: quadratic = invariant_theory.inhomogeneous_quadratic_form(x^2+y^2) + sage: quadratic = invariant_theory.inhomogeneous_quadratic_form(x^2 + y^2) sage: quadratic.monomials() (x^2, y^2, 1, x*y, x, y) """ @@ -1171,7 +1171,7 @@ def discriminant(self): EXAMPLES:: sage: R. = QQ[] - sage: p = a*x^2+b*x*y+c*y^2 + sage: p = a*x^2 + b*x*y + c*y^2 sage: quadratic = invariant_theory.quadratic_form(p, x,y) sage: quadratic.discriminant() b^2 - 4*a*c @@ -1305,7 +1305,7 @@ def as_QuadraticForm(self): EXAMPLES:: sage: R. = QQ[] - sage: p = x^2+y^2+z^2+2*x*y+3*x*z + sage: p = x^2 + y^2 + z^2 + 2*x*y + 3*x*z sage: quadratic = invariant_theory.ternary_quadratic(p) sage: matrix(quadratic) [ 1 1 3/2] @@ -1358,7 +1358,7 @@ def __init__(self, n, d, polynomial, *args): sage: R. = QQ[] sage: from sage.rings.invariants.invariant_theory import BinaryQuartic - sage: BinaryQuartic(2, 4, x^4+y^4) + sage: BinaryQuartic(2, 4, x^4 + y^4) Binary quartic with coefficients (1, 0, 0, 0, 1) """ assert n == 2 and d == 4 @@ -1379,7 +1379,7 @@ def monomials(self): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4) sage: quartic.monomials() (y^4, x*y^3, x^2*y^2, x^3*y, x^4) """ @@ -1472,7 +1472,7 @@ def EisensteinD(self): EXAMPLES:: sage: R. = QQ[] - sage: f = a0*x1^4+4*a1*x0*x1^3+6*a2*x0^2*x1^2+4*a3*x0^3*x1+a4*x0^4 + sage: f = a0*x1^4 + 4*a1*x0*x1^3 + 6*a2*x0^2*x1^2 + 4*a3*x0^3*x1 + a4*x0^4 sage: inv = invariant_theory.binary_quartic(f, x0, x1) sage: inv.EisensteinD() 3*a2^2 - 4*a1*a3 + a0*a4 @@ -1502,7 +1502,7 @@ def EisensteinE(self): EXAMPLES:: sage: R. = QQ[] - sage: f = a0*x1^4+4*a1*x0*x1^3+6*a2*x0^2*x1^2+4*a3*x0^3*x1+a4*x0^4 + sage: f = a0*x1^4 + 4*a1*x0*x1^3 + 6*a2*x0^2*x1^2 + 4*a3*x0^3*x1 + a4*x0^4 sage: inv = invariant_theory.binary_quartic(f, x0, x1) sage: inv.EisensteinE() a2^3 - 2*a1*a2*a3 + a0*a3^2 + a1^2*a4 - a0*a2*a4 @@ -1535,7 +1535,7 @@ def g_covariant(self): EXAMPLES:: sage: R. = QQ[] - sage: p = a0*x^4+4*a1*x^3*y+6*a2*x^2*y^2+4*a3*x*y^3+a4*y^4 + sage: p = a0*x^4 + 4*a1*x^3*y + 6*a2*x^2*y^2 + 4*a3*x*y^3 + a4*y^4 sage: inv = invariant_theory.binary_quartic(p, x, y) sage: g = inv.g_covariant(); g a1^2*x^4 - a0*a2*x^4 + 2*a1*a2*x^3*y - 2*a0*a3*x^3*y + 3*a2^2*x^2*y^2 @@ -1587,7 +1587,7 @@ def h_covariant(self): EXAMPLES:: sage: R. = QQ[] - sage: p = a0*x^4+4*a1*x^3*y+6*a2*x^2*y^2+4*a3*x*y^3+a4*y^4 + sage: p = a0*x^4 + 4*a1*x^3*y + 6*a2*x^2*y^2 + 4*a3*x*y^3 + a4*y^4 sage: inv = invariant_theory.binary_quartic(p, x, y) sage: h = inv.h_covariant(); h -2*a1^3*x^6 + 3*a0*a1*a2*x^6 - a0^2*a3*x^6 - 6*a1^2*a2*x^5*y + 9*a0*a2^2*x^5*y @@ -1606,7 +1606,7 @@ def h_covariant(self): + 2*a1*a3*a4*x + a0*a4^2*x + 2*a3^3 - 3*a2*a3*a4 + a1*a4^2 sage: g = inv.g_covariant() - sage: h == 1/8 * (p.derivative(x)*g.derivative(y)-p.derivative(y)*g.derivative(x)) + sage: h == 1/8 * (p.derivative(x)*g.derivative(y) - p.derivative(y)*g.derivative(x)) True """ a0, a1, a2, a3, a4 = self.scaled_coeffs() @@ -1735,7 +1735,7 @@ def monomials(self): EXAMPLES:: sage: R. = QQ[] - sage: quintic = invariant_theory.binary_quintic(x^5+y^5) + sage: quintic = invariant_theory.binary_quintic(x^5 + y^5) sage: quintic.monomials() (y^5, x*y^4, x^2*y^3, x^3*y^2, x^4*y, x^5) """ @@ -2603,7 +2603,7 @@ def monomials(self): EXAMPLES:: sage: R. = QQ[] - sage: quadratic = invariant_theory.ternary_quadratic(x^2+y*z) + sage: quadratic = invariant_theory.ternary_quadratic(x^2 + y*z) sage: quadratic.monomials() (x^2, y^2, z^2, x*y, x*z, y*z) """ @@ -2689,8 +2689,8 @@ def covariant_conic(self, other): EXAMPLES:: sage: ring. = QQ[] - sage: Q = invariant_theory.ternary_quadratic(x^2+y^2+z^2) - sage: R = invariant_theory.ternary_quadratic(x*y+x*z+y*z) + sage: Q = invariant_theory.ternary_quadratic(x^2 + y^2 + z^2) + sage: R = invariant_theory.ternary_quadratic(x*y + x*z + y*z) sage: Q.covariant_conic(R) -x*y - x*z - y*z sage: R.covariant_conic(Q) @@ -2737,7 +2737,7 @@ class TernaryCubic(AlgebraicForm): TESTS:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: cubic Ternary cubic with coefficients (1, 1, 1, 0, 0, 0, 0, 0, 0, 0) sage: TestSuite(cubic).run() @@ -2874,7 +2874,7 @@ def S_invariant(self): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^2*y+y^3+z^3+x*y*z) + sage: cubic = invariant_theory.ternary_cubic(x^2*y + y^3 + z^3 + x*y*z) sage: cubic.S_invariant() -1/1296 """ @@ -2896,12 +2896,12 @@ def T_invariant(self): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: cubic.T_invariant() 1 sage: R. = GF(7)[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3+t*x*y*z, [x,y,z]) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3 + t*x*y*z, [x,y,z]) sage: cubic.T_invariant() -t^6 - t^3 + 1 """ @@ -2999,12 +2999,12 @@ def Hessian(self): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: cubic.Hessian() x*y*z sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+1) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + 1) sage: cubic.Hessian() x*y """ @@ -3031,12 +3031,12 @@ def Theta_covariant(self): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: cubic.Theta_covariant() -x^3*y^3 - x^3*z^3 - y^3*z^3 sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+1) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + 1) sage: cubic.Theta_covariant() -x^3*y^3 - x^3 - y^3 @@ -3065,12 +3065,12 @@ def J_covariant(self): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: cubic.J_covariant() x^6*y^3 - x^3*y^6 - x^6*z^3 + y^6*z^3 + x^3*z^6 - y^3*z^6 sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+1) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + 1) sage: cubic.J_covariant() x^6*y^3 - x^3*y^6 - x^6 + y^6 + x^3 - y^3 """ @@ -3286,7 +3286,7 @@ def homogenized(self, var='h'): EXAMPLES:: sage: R. = QQ[] - sage: q = invariant_theory.quaternary_biquadratic(x^2+1, y^2+1, [x,y,z]) + sage: q = invariant_theory.quaternary_biquadratic(x^2 + 1, y^2 + 1, [x,y,z]) sage: q Joint quaternary quadratic with coefficients (1, 0, 0, 1, 0, 0, 0, 0, 0, 0) and quaternary quadratic with coefficients (0, 1, 0, 1, 0, 0, 0, 0, 0, 0) @@ -3427,7 +3427,8 @@ class TwoTernaryQuadratics(TwoAlgebraicForms): TESTS:: sage: R. = QQ[] - sage: inv = invariant_theory.ternary_biquadratic(x^2+y^2+z^2, x*y+y*z+x*z, [x, y, z]) + sage: inv = invariant_theory.ternary_biquadratic(x^2 + y^2 + z^2, + ....: x*y + y*z + x*z, [x, y, z]) sage: inv Joint ternary quadratic with coefficients (1, 1, 1, 0, 0, 0) and ternary quadratic with coefficients (0, 0, 0, 1, 1, 1) @@ -3484,7 +3485,7 @@ def _Theta_helper(self, scaled_coeffs_1, scaled_coeffs_2): TESTS:: sage: R. = QQ[] - sage: inv = invariant_theory.ternary_biquadratic(x^2 + y*z, x*y+z^2, x, y, z) + sage: inv = invariant_theory.ternary_biquadratic(x^2 + y*z, x*y + z^2, x, y, z) sage: inv._Theta_helper([1]*6, [2]*6) 0 """ @@ -3640,7 +3641,7 @@ class TwoQuaternaryQuadratics(TwoAlgebraicForms): TESTS:: sage: R. = QQ[] - sage: inv = invariant_theory.quaternary_biquadratic(w^2+x^2, y^2+z^2, w, x, y, z) + sage: inv = invariant_theory.quaternary_biquadratic(w^2 + x^2, y^2 + z^2, w, x, y, z) sage: inv Joint quaternary quadratic with coefficients (1, 1, 0, 0, 0, 0, 0, 0, 0, 0) and quaternary quadratic with coefficients (0, 0, 1, 1, 0, 0, 0, 0, 0, 0) @@ -3705,7 +3706,7 @@ def _Theta_helper(self, scaled_coeffs_1, scaled_coeffs_2): TESTS:: sage: R. = QQ[] - sage: inv = invariant_theory.quaternary_biquadratic(w^2+x^2, y^2+z^2, w, x, y, z) + sage: inv = invariant_theory.quaternary_biquadratic(w^2 + x^2, y^2 + z^2, w, x, y, z) sage: inv._Theta_helper([1]*10, [2]*10) 0 """ @@ -4064,10 +4065,10 @@ class InvariantTheoryFactory(): EXAMPLES:: sage: R. = QQ[] - sage: invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: invariant_theory.ternary_cubic(x^3 + y^3 + z^3) Ternary cubic with coefficients (1, 1, 1, 0, 0, 0, 0, 0, 0, 0) - sage: invariant_theory.ternary_cubic(x^3+y^3+z^3).J_covariant() + sage: invariant_theory.ternary_cubic(x^3 + y^3 + z^3).J_covariant() x^6*y^3 - x^3*y^6 - x^6*z^3 + y^6*z^3 + x^3*z^6 - y^3*z^6 """ @@ -4101,7 +4102,7 @@ def quadratic_form(self, polynomial, *args): EXAMPLES:: sage: R. = QQ[] - sage: quadratic = x^2+y^2+z^2 + sage: quadratic = x^2 + y^2 + z^2 sage: inv = invariant_theory.quadratic_form(quadratic) sage: type(inv) @@ -4110,7 +4111,7 @@ def quadratic_form(self, polynomial, *args): you need to specify the polynomial variables:: sage: R. = QQ[] - sage: quadratic = a*x^2+b*y^2+z^2+2*y*z + sage: quadratic = a*x^2 + b*y^2 + z^2 + 2*y*z sage: invariant_theory.quadratic_form(quadratic, x,y,z) Ternary quadratic with coefficients (a, b, 1, 0, 0, 2) sage: invariant_theory.quadratic_form(quadratic, [x,y,z]) # alternate syntax @@ -4145,11 +4146,11 @@ def inhomogeneous_quadratic_form(self, polynomial, *args): EXAMPLES:: sage: R. = QQ[] - sage: quadratic = x^2+2*y^2+3*x*y+4*x+5*y+6 + sage: quadratic = x^2 + 2*y^2 + 3*x*y + 4*x + 5*y + 6 sage: inv3 = invariant_theory.inhomogeneous_quadratic_form(quadratic) sage: type(inv3) - sage: inv4 = invariant_theory.inhomogeneous_quadratic_form(x^2+y^2+z^2) + sage: inv4 = invariant_theory.inhomogeneous_quadratic_form(x^2 + y^2 + z^2) sage: type(inv4) """ @@ -4178,7 +4179,7 @@ def binary_quadratic(self, quadratic, *args): EXAMPLES:: sage: R. = QQ[] - sage: invariant_theory.binary_quadratic(x^2+y^2) + sage: invariant_theory.binary_quadratic(x^2 + y^2) Binary quadratic with coefficients (1, 1, 0) sage: T. = QQ[] @@ -4206,11 +4207,11 @@ def quaternary_quadratic(self, quadratic, *args): EXAMPLES:: sage: R. = QQ[] - sage: invariant_theory.quaternary_quadratic(w^2+x^2+y^2+z^2) + sage: invariant_theory.quaternary_quadratic(w^2 + x^2 + y^2 + z^2) Quaternary quadratic with coefficients (1, 1, 1, 1, 0, 0, 0, 0, 0, 0) sage: R. = QQ[] - sage: invariant_theory.quaternary_quadratic(1+x^2+y^2+z^2) + sage: invariant_theory.quaternary_quadratic(1 + x^2 + y^2 + z^2) Quaternary quadratic with coefficients (1, 1, 1, 1, 0, 0, 0, 0, 0, 0) """ return QuadraticForm(4, 2, quadratic, *args) @@ -4254,7 +4255,7 @@ def binary_quartic(self, quartic, *args, **kwds): EXAMPLES:: sage: R. = QQ[] - sage: quartic = invariant_theory.binary_quartic(x^4+y^4) + sage: quartic = invariant_theory.binary_quartic(x^4 + y^4) sage: quartic Binary quartic with coefficients (1, 0, 0, 0, 1) sage: type(quartic) @@ -4293,14 +4294,14 @@ def binary_quintic(self, quintic, *args, **kwds): If no variables are provided, they will be guessed:: sage: R. = QQ[] - sage: quintic = invariant_theory.binary_quintic(x^5+y^5) + sage: quintic = invariant_theory.binary_quintic(x^5 + y^5) sage: quintic Binary quintic with coefficients (1, 0, 0, 0, 0, 1) If only one variable is given, the quintic is the homogenisation of the provided polynomial:: - sage: quintic = invariant_theory.binary_quintic(x^5+y^5, x) + sage: quintic = invariant_theory.binary_quintic(x^5 + y^5, x) sage: quintic Binary quintic with coefficients (y^5, 0, 0, 0, 0, 1) sage: quintic.is_homogeneous() @@ -4310,11 +4311,11 @@ def binary_quintic(self, quintic, *args, **kwds): specified:: sage: R. = QQ[] - sage: quintic = invariant_theory.binary_quintic(x^5+z*y^5) + sage: quintic = invariant_theory.binary_quintic(x^5 + z*y^5) Traceback (most recent call last): ... ValueError: need 2 or 1 variables, got (x, y, z) - sage: quintic = invariant_theory.binary_quintic(x^5+z*y^5, x, y) + sage: quintic = invariant_theory.binary_quintic(x^5 + z*y^5, x, y) sage: quintic Binary quintic with coefficients (z, 0, 0, 0, 0, 1) @@ -4384,12 +4385,13 @@ def binary_form_from_invariants(self, degree, invariants, variables=None, as_for Binary quintic with coefficients (-37725479487783/1048576, 565882192316745/8388608, 0, 1033866765362693115/67108864, 12849486940936328715/268435456, -23129076493685391687/2147483648) - sage: invariant_theory.binary_form_from_invariants(5, invariants, scaling='normalized') + sage: invariant_theory.binary_form_from_invariants(5, invariants, + ....: scaling='normalized') Binary quintic with coefficients (24389/892616806656, 4205/11019960576, 0, 1015/209952, -145/1296, -3/16) - sage: invariant_theory.binary_form_from_invariants(5, invariants, scaling='coprime') - Binary quintic with coefficients (-2048, 3840, 0, 876960, 2724840, - -613089) + sage: invariant_theory.binary_form_from_invariants(5, invariants, + ....: scaling='coprime') + Binary quintic with coefficients (-2048, 3840, 0, 876960, 2724840, -613089) The invariants can also be computed using the invariants of a given binary quintic. The resulting form has the same invariants up to scaling, is @@ -4401,7 +4403,8 @@ def binary_form_from_invariants(self, degree, invariants, variables=None, as_for sage: p = 3*x1^5 + 6*x1^4*x0 + 3*x1^3*x0^2 + 4*x1^2*x0^3 - 5*x1*x0^4 + 4*x0^5 sage: quintic = invariant_theory.binary_quintic(p, x0, x1) sage: invariants = quintic.clebsch_invariants(as_tuple=True) - sage: newquintic = invariant_theory.binary_form_from_invariants(5, invariants, variables=quintic.variables()) + sage: newquintic = invariant_theory.binary_form_from_invariants( + ....: 5, invariants, variables=quintic.variables()) sage: newquintic Binary quintic with coefficients (9592267437341790539005557/244140625000000, 2149296928207625556323004064707/610351562500000000, @@ -4510,14 +4513,14 @@ def ternary_quadratic(self, quadratic, *args, **kwds): EXAMPLES:: sage: R. = QQ[] - sage: invariant_theory.ternary_quadratic(x^2+y^2+z^2) + sage: invariant_theory.ternary_quadratic(x^2 + y^2 + z^2) Ternary quadratic with coefficients (1, 1, 1, 0, 0, 0) sage: T. = QQ[] - sage: invariant_theory.ternary_quadratic(1+u^2+v^2) + sage: invariant_theory.ternary_quadratic(1 + u^2 + v^2) Ternary quadratic with coefficients (1, 1, 1, 0, 0, 0) - sage: quadratic = x^2+y^2+z^2 + sage: quadratic = x^2 + y^2 + z^2 sage: inv = invariant_theory.ternary_quadratic(quadratic) sage: type(inv) @@ -4582,7 +4585,7 @@ def ternary_cubic(self, cubic, *args, **kwds): EXAMPLES:: sage: R. = QQ[] - sage: cubic = invariant_theory.ternary_cubic(x^3+y^3+z^3) + sage: cubic = invariant_theory.ternary_cubic(x^3 + y^3 + z^3) sage: type(cubic) """ @@ -4604,7 +4607,7 @@ def ternary_biquadratic(self, quadratic1, quadratic2, *args, **kwds): EXAMPLES:: sage: R. = QQ[] - sage: q1 = x^2+y^2+z^2 + sage: q1 = x^2 + y^2 + z^2 sage: q2 = x*y + y*z + x*z sage: inv = invariant_theory.ternary_biquadratic(q1, q2) sage: type(inv) @@ -4658,7 +4661,7 @@ def quaternary_biquadratic(self, quadratic1, quadratic2, *args, **kwds): EXAMPLES:: sage: R. = QQ[] - sage: q1 = w^2+x^2+y^2+z^2 + sage: q1 = w^2 + x^2 + y^2 + z^2 sage: q2 = w*x + y*z sage: inv = invariant_theory.quaternary_biquadratic(q1, q2) sage: type(inv) diff --git a/src/sage/rings/invariants/reconstruction.py b/src/sage/rings/invariants/reconstruction.py index bde5c307ee4..a8134f4734d 100644 --- a/src/sage/rings/invariants/reconstruction.py +++ b/src/sage/rings/invariants/reconstruction.py @@ -41,7 +41,7 @@ def binary_quadratic_coefficients_from_invariants(discriminant, invariant_choice EXAMPLES:: sage: from sage.rings.invariants.reconstruction import binary_quadratic_coefficients_from_invariants - sage: quadratic = invariant_theory.binary_form_from_invariants(2, [24]) # indirect doctest + sage: quadratic = invariant_theory.binary_form_from_invariants(2, [24]) # indirect doctest sage: quadratic Binary quadratic with coefficients (1, -6, 0) sage: quadratic.discriminant() @@ -142,7 +142,8 @@ def binary_quintic_coefficients_from_invariants(invariants, K=None, invariant_ch sage: p = 3*x1^5 + 6*x1^4*x0 + 3*x1^3*x0^2 + 4*x1^2*x0^3 - 5*x1*x0^4 + 4*x0^5 sage: quintic = invariant_theory.binary_quintic(p, x0, x1) sage: invs = quintic.clebsch_invariants(as_tuple=True) - sage: reconstructed = invariant_theory.binary_form_from_invariants(5, invs, variables=quintic.variables()) # indirect doctest + sage: reconstructed = invariant_theory.binary_form_from_invariants( # indirect doctest + ....: 5, invs, variables=quintic.variables()) sage: reconstructed Binary quintic with coefficients (9592267437341790539005557/244140625000000, 2149296928207625556323004064707/610351562500000000, @@ -167,8 +168,10 @@ def binary_quintic_coefficients_from_invariants(invariants, K=None, invariant_ch sage: alpha = quintic.alpha_covariant() sage: beta = quintic.beta_covariant() - sage: g = matrix([[alpha(x0=1,x1=0),alpha(x0=0,x1=1)],[beta(x0=1,x1=0),beta(x0=0,x1=1)]])^-1 - sage: transformed = tuple([g.determinant()^-5*x for x in quintic.transformed(g).coeffs()]) + sage: g = matrix([[alpha(x0=1,x1=0), alpha(x0=0,x1=1)], + ....: [beta(x0=1,x1=0), beta(x0=0,x1=1)]])^-1 + sage: transformed = tuple([g.determinant()^-5*x + ....: for x in quintic.transformed(g).coeffs()]) sage: transformed == reconstructed.coeffs() True @@ -231,7 +234,8 @@ def binary_quintic_coefficients_from_invariants(invariants, K=None, invariant_ch sage: binary_quintic_coefficients_from_invariants([3,1,2], K=GF(5)) Traceback (most recent call last): ... - NotImplementedError: no reconstruction of binary quintics implemented for fields of characteristic 2, 3 or 5 + NotImplementedError: no reconstruction of binary quintics implemented + for fields of characteristic 2, 3 or 5 TESTS:: diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx index 01cb166b7fb..864e2766407 100644 --- a/src/sage/rings/polynomial/hilbert.pyx +++ b/src/sage/rings/polynomial/hilbert.pyx @@ -442,16 +442,16 @@ def first_hilbert_series(I, grading=None, return_grading=False): sage: I = singular.ideal(['x^2','y^2','z^2']) sage: first_hilbert_series(I) -t^6 + 3*t^4 - 3*t^2 + 1 - sage: first_hilbert_series(I,return_grading=True) + sage: first_hilbert_series(I, return_grading=True) (-t^6 + 3*t^4 - 3*t^2 + 1, (1, 1, 1)) - sage: first_hilbert_series(I,grading=(1,2,3)) + sage: first_hilbert_series(I, grading=(1,2,3)) -t^12 + t^10 + t^8 - t^4 - t^2 + 1 TESTS: We test against some corner cases:: - sage: R.=PolynomialRing(QQ) + sage: R. = PolynomialRing(QQ) sage: I = 0*R sage: first_hilbert_series(I) 1 @@ -559,18 +559,19 @@ def hilbert_poincare_series(I, grading=None): sage: from sage.rings.polynomial.hilbert import hilbert_poincare_series sage: R = PolynomialRing(QQ,'x',9) - sage: I = [m.lm() for m in ((matrix(R,3,R.gens())^2).list()*R).groebner_basis()]*R + sage: I = [m.lm() + ....: for m in ((matrix(R, 3, R.gens())^2).list() * R).groebner_basis()] * R sage: hilbert_poincare_series(I) (t^7 - 3*t^6 + 2*t^5 + 2*t^4 - 2*t^3 + 6*t^2 + 5*t + 1)/(t^4 - 4*t^3 + 6*t^2 - 4*t + 1) - sage: hilbert_poincare_series((R*R.gens())^2, grading=range(1,10)) + sage: hilbert_poincare_series((R * R.gens())^2, grading=range(1,10)) t^9 + t^8 + t^7 + t^6 + t^5 + t^4 + t^3 + t^2 + t + 1 The following example is taken from :trac:`20145`:: - sage: n=4;m=11;P = PolynomialRing(QQ,n*m,"x"); x = P.gens(); M = Matrix(n,x) + sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x) sage: from sage.rings.polynomial.hilbert import first_hilbert_series sage: I = P.ideal(M.minors(2)) - sage: J = P*[m.lm() for m in I.groebner_basis()] + sage: J = P * [m.lm() for m in I.groebner_basis()] sage: hilbert_poincare_series(J).numerator() 120*t^3 + 135*t^2 + 30*t + 1 sage: hilbert_poincare_series(J).denominator().factor() @@ -578,7 +579,7 @@ def hilbert_poincare_series(I, grading=None): This example exceeded the capabilities of Singular before version 4.2.1p2. In Singular 4.3.1, it works correctly on 64-bit, but on 32-bit, it prints overflow warnings - and omits some terms. + and omits some terms:: sage: J.hilbert_numerator(algorithm='singular') 120*t^33 - 3465*t^32 + 48180*t^31 - 429374*t^30 + 2753520*t^29 - 13522410*t^28 + 52832780*t^27 - 168384150*t^26 + 445188744*t^25 - 987193350*t^24 + 1847488500*t^23 + 1372406746*t^22 - 403422496*t^21 - 8403314*t^20 - 471656596*t^19 + 1806623746*t^18 + 752776200*t^17 + 752776200*t^16 - 1580830020*t^15 + 1673936550*t^14 - 1294246800*t^13 + 786893250*t^12 - 382391100*t^11 + 146679390*t^10 - 42299400*t^9 + 7837830*t^8 - 172260*t^7 - 468930*t^6 + 183744*t^5 - 39270*t^4 + 5060*t^3 - 330*t^2 + 1 # 64-bit diff --git a/src/sage/rings/polynomial/infinite_polynomial_element.py b/src/sage/rings/polynomial/infinite_polynomial_element.py index 8a67eb9f9bb..cad5877fd0f 100644 --- a/src/sage/rings/polynomial/infinite_polynomial_element.py +++ b/src/sage/rings/polynomial/infinite_polynomial_element.py @@ -80,7 +80,7 @@ sage: C. = InfinitePolynomialRing(B,order='degrevlex') sage: C Infinite polynomial ring in b, c over Infinite polynomial ring in a over Integer Ring - sage: 1/2*b_1*a[4]+c[3] + sage: 1/2*b_1*a[4] + c[3] 1/2*a_4*b_1 + c_3 """ @@ -403,7 +403,7 @@ def subs(self, fixed=None, **kwargs): INPUT: - - ``fixed`` -- (optional) ``dict`` with ``{variable:value}`` pairs + - ``fixed`` -- (optional) ``dict`` with ``{variable: value}`` pairs - ``**kwargs`` -- named parameters OUTPUT: @@ -488,7 +488,7 @@ def ring(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(ZZ,implementation='sparse') - sage: p = x[100]*y[1]^3*x[1]^2+2*x[10]*y[30] + sage: p = x[100]*y[1]^3*x[1]^2 + 2*x[10]*y[30] sage: p.ring() Infinite polynomial ring in x, y over Integer Ring @@ -503,7 +503,7 @@ def is_unit(self): sage: R1. = InfinitePolynomialRing(ZZ) sage: R2. = InfinitePolynomialRing(QQ) - sage: (1+x[2]).is_unit() + sage: (1 + x[2]).is_unit() False sage: R1(1).is_unit() True @@ -511,7 +511,7 @@ def is_unit(self): False sage: R2(2).is_unit() True - sage: (1+a[2]).is_unit() + sage: (1 + a[2]).is_unit() False Check that :trac:`22454` is fixed:: @@ -587,7 +587,7 @@ def max_index(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p=x[1]^2+y[2]^2+x[1]*x[2]*y[3]+x[1]*y[4] + sage: p = x[1]^2 + y[2]^2 + x[1]*x[2]*y[3] + x[1]*y[4] sage: p.max_index() 4 sage: x[0].max_index() @@ -634,7 +634,7 @@ def _div_(self, x): Division by an integer over `\ZZ`:: sage: R. = InfinitePolynomialRing(ZZ, implementation='sparse') - sage: p = x[3]+x[2] + sage: p = x[3] + x[2] sage: q = p/2 sage: q 1/2*x_3 + 1/2*x_2 @@ -648,7 +648,7 @@ def _div_(self, x): 1/x_1 sage: (x[0]/x[0]) x_0/x_0 - sage: qt = 1/x[2]+2/x[1]; qt + sage: qt = 1/x[2] + 2/x[1]; qt (2*x_2 + x_1)/(x_2*x_1) sage: qt.parent() Fraction Field of Infinite polynomial ring in x over Rational Field @@ -701,7 +701,7 @@ def lm(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = 2*x[10]*y[30]+x[10]*y[1]^3*x[1]^2 + sage: p = 2*x[10]*y[30] + x[10]*y[1]^3*x[1]^2 sage: p.lm() x_10*x_1^2*y_1^3 @@ -723,7 +723,7 @@ def lc(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = 2*x[10]*y[30]+3*x[10]*y[1]^3*x[1]^2 + sage: p = 2*x[10]*y[30] + 3*x[10]*y[1]^3*x[1]^2 sage: p.lc() 3 @@ -743,7 +743,7 @@ def lt(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = 2*x[10]*y[30]+3*x[10]*y[1]^3*x[1]^2 + sage: p = 2*x[10]*y[30] + 3*x[10]*y[1]^3*x[1]^2 sage: p.lt() 3*x_10*x_1^2*y_1^3 @@ -763,7 +763,7 @@ def tail(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = 2*x[10]*y[30]+3*x[10]*y[1]^3*x[1]^2 + sage: p = 2*x[10]*y[30] + 3*x[10]*y[1]^3*x[1]^2 sage: p.tail() 2*x_10*y_30 @@ -812,7 +812,7 @@ def footprint(self): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = x[30]*y[1]^3*x[1]^2+2*x[10]*y[30] + sage: p = x[30]*y[1]^3*x[1]^2 + 2*x[10]*y[30] sage: sorted(p.footprint().items()) [(1, [2, 3]), (30, [1, 0])] @@ -864,7 +864,7 @@ def symmetric_cancellation_order(self, other): INPUT: - self, other -- two Infinite Polynomials + ``self``, ``other`` -- two Infinite Polynomials ASSUMPTION: @@ -1086,7 +1086,7 @@ def reduce(self, I, tailreduce=False, report=None): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: p = y[1]^2*y[3]+y[2]*x[3]^3 + sage: p = y[1]^2*y[3] + y[2]*x[3]^3 sage: p.reduce([y[2]*x[1]^2]) x_3^3*y_2 + y_3*y_1^2 @@ -1112,7 +1112,7 @@ def reduce(self, I, tailreduce=False, report=None): Last, we demonstrate the ``report`` option:: - sage: p=x[1]^2+y[2]^2+x[1]*x[2]*y[3]+x[1]*y[4] + sage: p = x[1]^2 + y[2]^2 + x[1]*x[2]*y[3] + x[1]*y[4] sage: p.reduce(I, tailreduce=True, report=True) :T[2]:> > @@ -1201,7 +1201,7 @@ def gcd(self, x): EXAMPLES:: sage: R.=InfinitePolynomialRing(QQ) - sage: p1=x[0]+x[1]**2 + sage: p1=x[0] + x[1]**2 sage: gcd(p1,p1+3) 1 sage: gcd(p1,p1)==p1 @@ -1233,9 +1233,11 @@ class InfinitePolynomial_sparse(InfinitePolynomial): sage: p a*b_100 + 1/2*c_4 sage: p.parent() - Infinite polynomial ring in b, c over Univariate Polynomial Ring in a over Rational Field + Infinite polynomial ring in b, c + over Univariate Polynomial Ring in a over Rational Field sage: p.polynomial().parent() - Multivariate Polynomial Ring in b_100, b_0, c_4, c_0 over Univariate Polynomial Ring in a over Rational Field + Multivariate Polynomial Ring in b_100, b_0, c_4, c_0 + over Univariate Polynomial Ring in a over Rational Field """ @@ -1524,9 +1526,6 @@ class InfinitePolynomial_dense(InfinitePolynomial): Of course, one should not directly invoke this class, but rather construct elements of ``A`` in the usual way. - This class inherits from - :class:`~sage.rings.polynomial.infinite_polynomial_element.InfinitePolynomial_sparse`. See - there for a description of the methods. """ def __call__(self, *args, **kwargs): diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index 42e9a1935da..b75f9aebc40 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -179,14 +179,14 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): sage: R. = LaurentPolynomialRing(QQ) sage: a = x^2 + 3*x^3 + 5*x^-1 - sage: a.change_ring(GF(3)) + sage: a.change_ring(GF(3)) # optional - sage.rings.finite_rings 2*x^-1 + x^2 Check that :trac:`22277` is fixed:: sage: R. = LaurentPolynomialRing(QQ) sage: a = 2*x^2 + 3*x^3 + 4*x^-1 - sage: a.change_ring(GF(3)) + sage: a.change_ring(GF(3)) # optional - sage.rings.finite_rings -x^2 + x^-1 """ return self._parent.change_ring(R)(self) @@ -389,7 +389,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): sage: Pxy = PolynomialRing(QQ, "x,y") sage: Paxb = PolynomialRing(QQ, "a,x,b") sage: Qx = PolynomialRing(ZZ, "x") - sage: Rx = PolynomialRing(GF(2), "x") + sage: Rx = PolynomialRing(GF(2), "x") # optional - sage.rings.finite_rings sage: p1 = Lx.gen() sage: p2 = Lx.zero() sage: p3 = Lx.one() @@ -397,8 +397,10 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial): sage: p5 = Lx.gen()**3 + 2*Lx.gen()**2 sage: p6 = Lx.gen() >> 2 - sage: for P,x in [(Px, Px.gen()), (Qx, Qx.gen()), (Rx, Rx.gen()), - ....: (Pxy, Pxy.gen(0)), (Paxb, Paxb.gen(1))]: + sage: Pxes = [(Px, Px.gen()), (Qx, Qx.gen()), + ....: (Pxy, Pxy.gen(0)), (Paxb, Paxb.gen(1))] + sage: Pxes += [(Rx, Rx.gen())] # optional - sage.rings.finite_rings + sage: for P, x in Pxes: ....: assert P(p1) == x and parent(P(p1)) is P ....: assert P(p2) == P.zero() and parent(P(p2)) is P ....: assert P(p3) == P.one() and parent(P(p3)) is P @@ -3107,7 +3109,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): OUTPUT: - Returns True if self contains a monomial including the inverse of + Returns True if ``self`` contains a monomial including the inverse of ``self.parent().gen(i)``, False otherwise. EXAMPLES:: @@ -3132,7 +3134,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): def has_any_inverse(self): """ - Returns True if self contains any monomials with a negative exponent, False otherwise. + Return True if ``self`` contains any monomials with a negative exponent, False otherwise. EXAMPLES:: @@ -3410,7 +3412,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): def univariate_polynomial(self, R=None): """ - Returns a univariate polynomial associated to this + Return a univariate polynomial associated to this multivariate polynomial. INPUT: @@ -3467,7 +3469,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): def factor(self): """ - Returns a Laurent monomial (the unit part of the factorization) and a factored multi-polynomial. + Return a Laurent monomial (the unit part of the factorization) and a factored multi-polynomial. EXAMPLES:: @@ -3526,7 +3528,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial): EXAMPLES:: sage: L. = LaurentPolynomialRing(QQ) - sage: p = (1 + x*y + z^-3) + sage: p = 1 + x*y + z^-3 sage: (p**2).is_square() True sage: (p**2).is_square(root=True) diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring.py b/src/sage/rings/polynomial/laurent_polynomial_ring.py index aaa1166b9d2..956d36da106 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_ring.py +++ b/src/sage/rings/polynomial/laurent_polynomial_ring.py @@ -88,7 +88,7 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): 3. ``LaurentPolynomialRing(base_ring, name, n, order='degrevlex')`` 4. ``LaurentPolynomialRing(base_ring, n, name, order='degrevlex')`` - The optional arguments sparse and order *must* be explicitly + The optional arguments ``sparse`` and ``order`` *must* be explicitly named, and the other arguments must be given positionally. INPUT: @@ -101,10 +101,10 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): - ``order`` -- string or :class:`~sage.rings.polynomial.term_order.TermOrder`, e.g., - - ``'degrevlex'`` (default) -- degree reverse lexicographic - - ``'lex'`` -- lexicographic - - ``'deglex'`` -- degree lexicographic - - ``TermOrder('deglex',3) + TermOrder('deglex',3)`` -- block ordering + - ``'degrevlex'`` (default) -- degree reverse lexicographic + - ``'lex'`` -- lexicographic + - ``'deglex'`` -- degree lexicographic + - ``TermOrder('deglex',3) + TermOrder('deglex',3)`` -- block ordering OUTPUT: @@ -120,7 +120,7 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): :: - sage: R. = LaurentPolynomialRing(QQ,2); R + sage: R. = LaurentPolynomialRing(QQ, 2); R Multivariate Laurent Polynomial Ring in x, y over Rational Field sage: f = x^2 - 2*y^-2 @@ -162,8 +162,9 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): sage: R. = LaurentPolynomialRing(QQ, sparse=True); R Univariate Laurent Polynomial Ring in abc over Rational Field - sage: R. = LaurentPolynomialRing(PolynomialRing(GF(7),'k')); R - Univariate Laurent Polynomial Ring in w over Univariate Polynomial Ring in k over Finite Field of size 7 + sage: R. = LaurentPolynomialRing(PolynomialRing(GF(7),'k')); R # optional - sage.rings.finite_rings + Univariate Laurent Polynomial Ring in w over + Univariate Polynomial Ring in k over Finite Field of size 7 Rings with different variables are different:: @@ -210,10 +211,12 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): :: sage: LaurentPolynomialRing(QQ, 'x', 10) - Multivariate Laurent Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 over Rational Field + Multivariate Laurent Polynomial Ring in x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 + over Rational Field - sage: LaurentPolynomialRing(GF(7), 'y', 5) - Multivariate Laurent Polynomial Ring in y0, y1, y2, y3, y4 over Finite Field of size 7 + sage: LaurentPolynomialRing(GF(7), 'y', 5) # optional - sage.rings.finite_rings + Multivariate Laurent Polynomial Ring in y0, y1, y2, y3, y4 + over Finite Field of size 7 sage: LaurentPolynomialRing(QQ, 'y', 3, sparse=True) Multivariate Laurent Polynomial Ring in y0, y1, y2 over Rational Field @@ -222,11 +225,12 @@ def LaurentPolynomialRing(base_ring, *args, **kwds): :meth:`~sage.structure.category_object.CategoryObject.inject_variables` method, all those variable names are available for interactive use:: - sage: R = LaurentPolynomialRing(GF(7),15,'w'); R - Multivariate Laurent Polynomial Ring in w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 over Finite Field of size 7 - sage: R.inject_variables() + sage: R = LaurentPolynomialRing(GF(7), 15, 'w'); R # optional - sage.rings.finite_rings + Multivariate Laurent Polynomial Ring in w0, w1, w2, w3, w4, w5, w6, w7, + w8, w9, w10, w11, w12, w13, w14 over Finite Field of size 7 + sage: R.inject_variables() # optional - sage.rings.finite_rings Defining w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14 - sage: (w0 + 2*w8 + w13)^2 + sage: (w0 + 2*w8 + w13)^2 # optional - sage.rings.finite_rings w0^2 + 4*w0*w8 + 4*w8^2 + 2*w0*w13 + 4*w8*w13 + w13^2 """ from sage.rings.polynomial.polynomial_ring import is_PolynomialRing diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring_base.py b/src/sage/rings/polynomial/laurent_polynomial_ring_base.py index bb6b23e78d3..dc3b4a4fc2d 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_ring_base.py +++ b/src/sage/rings/polynomial/laurent_polynomial_ring_base.py @@ -40,7 +40,10 @@ class LaurentPolynomialRing_generic(CommutativeRing, Parent): sage: R. = LaurentPolynomialRing(QQ) sage: R.category() - Join of Category of unique factorization domains and Category of commutative algebras over (number fields and quotient fields and metric spaces) and Category of infinite sets + Join of Category of unique factorization domains + and Category of commutative algebras + over (number fields and quotient fields and metric spaces) + and Category of infinite sets sage: TestSuite(R).run() """ @@ -48,7 +51,7 @@ def __init__(self, R): """ EXAMPLES:: - sage: R = LaurentPolynomialRing(QQ,2,'x') + sage: R = LaurentPolynomialRing(QQ, 2, 'x') sage: R == loads(dumps(R)) True """ @@ -65,9 +68,9 @@ def ngens(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').ngens() + sage: LaurentPolynomialRing(QQ, 2, 'x').ngens() 2 - sage: LaurentPolynomialRing(QQ,1,'x').ngens() + sage: LaurentPolynomialRing(QQ, 1, 'x').ngens() 1 """ return self._n @@ -79,16 +82,16 @@ def gen(self, i=0): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').gen() + sage: LaurentPolynomialRing(QQ, 2, 'x').gen() x0 - sage: LaurentPolynomialRing(QQ,2,'x').gen(0) + sage: LaurentPolynomialRing(QQ, 2, 'x').gen(0) x0 - sage: LaurentPolynomialRing(QQ,2,'x').gen(1) + sage: LaurentPolynomialRing(QQ, 2, 'x').gen(1) x1 TESTS:: - sage: LaurentPolynomialRing(QQ,2,'x').gen(3) + sage: LaurentPolynomialRing(QQ, 2, 'x').gen(3) Traceback (most recent call last): ... ValueError: generator not defined @@ -141,14 +144,15 @@ def is_integral_domain(self, proof=True): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').is_integral_domain() + sage: LaurentPolynomialRing(QQ, 2, 'x').is_integral_domain() True The following used to fail; see :trac:`7530`:: sage: L = LaurentPolynomialRing(ZZ, 'X') sage: L['Y'] - Univariate Polynomial Ring in Y over Univariate Laurent Polynomial Ring in X over Integer Ring + Univariate Polynomial Ring in Y over + Univariate Laurent Polynomial Ring in X over Integer Ring """ return self.base_ring().is_integral_domain(proof) @@ -158,7 +162,7 @@ def is_noetherian(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').is_noetherian() + sage: LaurentPolynomialRing(QQ, 2, 'x').is_noetherian() Traceback (most recent call last): ... NotImplementedError @@ -171,9 +175,9 @@ def construction(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x,y').construction() + sage: LaurentPolynomialRing(QQ, 2, 'x,y').construction() (LaurentPolynomialFunctor, - Univariate Laurent Polynomial Ring in x over Rational Field) + Univariate Laurent Polynomial Ring in x over Rational Field) """ from sage.categories.pushout import LaurentPolynomialFunctor @@ -197,11 +201,9 @@ def completion(self, p=None, prec=20, extras=None): EXAMPLES:: - sage: P. = LaurentPolynomialRing(QQ) - sage: P + sage: P. = LaurentPolynomialRing(QQ); P Univariate Laurent Polynomial Ring in x over Rational Field - sage: PP = P.completion(x) - sage: PP + sage: PP = P.completion(x); PP Laurent Series Ring in x over Rational Field sage: f = 1 - 1/x sage: PP(f) @@ -346,7 +348,7 @@ def _latex_(self): r""" EXAMPLES:: - sage: latex(LaurentPolynomialRing(QQ,2,'x')) + sage: latex(LaurentPolynomialRing(QQ, 2, 'x')) \Bold{Q}[x_{0}^{\pm 1}, x_{1}^{\pm 1}] """ from sage.misc.latex import latex @@ -358,7 +360,7 @@ def _ideal_class_(self, n=0): """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x')._ideal_class_() + sage: LaurentPolynomialRing(QQ, 2, 'x')._ideal_class_() Traceback (most recent call last): ... NotImplementedError @@ -370,7 +372,7 @@ def ideal(self, *args, **kwds): """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').ideal([1]) + sage: LaurentPolynomialRing(QQ, 2, 'x').ideal([1]) Ideal (1) of Multivariate Laurent Polynomial Ring in x0, x1 over Rational Field TESTS: @@ -417,7 +419,7 @@ def term_order(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').term_order() + sage: LaurentPolynomialRing(QQ, 2, 'x').term_order() Degree reverse lexicographic term order """ @@ -427,7 +429,7 @@ def is_finite(self): """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').is_finite() + sage: LaurentPolynomialRing(QQ, 2, 'x').is_finite() False """ @@ -437,7 +439,7 @@ def is_field(self, proof = True): """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').is_field() + sage: LaurentPolynomialRing(QQ, 2, 'x').is_field() False """ return False @@ -448,9 +450,9 @@ def polynomial_ring(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').polynomial_ring() + sage: LaurentPolynomialRing(QQ, 2, 'x').polynomial_ring() Multivariate Polynomial Ring in x0, x1 over Rational Field - sage: LaurentPolynomialRing(QQ,1,'x').polynomial_ring() + sage: LaurentPolynomialRing(QQ, 1, 'x').polynomial_ring() Multivariate Polynomial Ring in x over Rational Field """ return self._R @@ -461,7 +463,7 @@ def characteristic(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').characteristic() + sage: LaurentPolynomialRing(QQ, 2, 'x').characteristic() 0 sage: LaurentPolynomialRing(GF(3), 2, 'x').characteristic() # optional - sage.libs.pari 3 @@ -473,7 +475,7 @@ def krull_dimension(self): """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').krull_dimension() + sage: LaurentPolynomialRing(QQ, 2, 'x').krull_dimension() Traceback (most recent call last): ... NotImplementedError @@ -484,7 +486,7 @@ def random_element(self, low_degree = -2, high_degree = 2, terms = 5, choose_deg """ EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').random_element() + sage: LaurentPolynomialRing(QQ, 2, 'x').random_element() Traceback (most recent call last): ... NotImplementedError @@ -497,9 +499,9 @@ def is_exact(self): EXAMPLES:: - sage: LaurentPolynomialRing(QQ,2,'x').is_exact() + sage: LaurentPolynomialRing(QQ, 2, 'x').is_exact() True - sage: LaurentPolynomialRing(RDF,2,'x').is_exact() + sage: LaurentPolynomialRing(RDF, 2, 'x').is_exact() False """ return self.base_ring().is_exact() @@ -508,7 +510,7 @@ def change_ring(self, base_ring=None, names=None, sparse=False, order=None): """ EXAMPLES:: - sage: R = LaurentPolynomialRing(QQ,2,'x') + sage: R = LaurentPolynomialRing(QQ, 2, 'x') sage: R.change_ring(ZZ) Multivariate Laurent Polynomial Ring in x0, x1 over Integer Ring diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index 8412e612080..13d0af27963 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -304,10 +304,10 @@ cdef class MPolynomial(CommutativePolynomial): def derivative(self, *args): r""" The formal derivative of this polynomial, with respect to - variables supplied in args. + variables supplied in ``args``. Multiple variables and iteration counts may be supplied; see - documentation for the global derivative() function for more details. + documentation for the global function :func:`derivative` for more details. .. SEEALSO:: :meth:`._derivative` @@ -361,8 +361,8 @@ cdef class MPolynomial(CommutativePolynomial): def polynomial(self, var): """ - Let var be one of the variables of the parent of self. This - returns self viewed as a univariate polynomial in var over the + Let ``var`` be one of the variables of the parent of ``self``. This + returns ``self`` viewed as a univariate polynomial in ``var`` over the polynomial ring generated by all the other variables of the parent. EXAMPLES:: @@ -599,7 +599,7 @@ cdef class MPolynomial(CommutativePolynomial): def args(self): r""" - Returns the named of the arguments of self, in the + Returns the names of the arguments of ``self``, in the order they are accepted from call. EXAMPLES:: @@ -740,7 +740,7 @@ cdef class MPolynomial(CommutativePolynomial): def is_homogeneous(self): r""" - Return ``True`` if self is a homogeneous polynomial. + Return ``True`` if ``self`` is a homogeneous polynomial. TESTS:: @@ -1035,7 +1035,7 @@ cdef class MPolynomial(CommutativePolynomial): def _magma_init_(self, magma): """ - Returns a Magma string representation of self valid in the + Returns a Magma string representation of ``self`` valid in the given magma session. EXAMPLES:: @@ -1148,7 +1148,7 @@ cdef class MPolynomial(CommutativePolynomial): def __iter__(self): """ - Facilitates iterating over the monomials of self, + Facilitates iterating over the monomials of ``self``, returning tuples of the form ``(coeff, mon)`` for each non-zero monomial. @@ -1272,7 +1272,7 @@ cdef class MPolynomial(CommutativePolynomial): def map_coefficients(self, f, new_base_ring=None): """ Returns the polynomial obtained by applying ``f`` to the non-zero - coefficients of self. + coefficients of ``self``. If ``f`` is a :class:`sage.categories.map.Map`, then the resulting polynomial will be defined over the codomain of ``f``. Otherwise, the @@ -1281,7 +1281,7 @@ cdef class MPolynomial(CommutativePolynomial): INPUT: - - ``f`` -- a callable that will be applied to the coefficients of self. + - ``f`` -- a callable that will be applied to the coefficients of ``self``. - ``new_base_ring`` (optional) -- if given, the resulting polynomial will be defined over this ring. @@ -1354,7 +1354,7 @@ cdef class MPolynomial(CommutativePolynomial): def sylvester_matrix(self, right, variable = None): """ - Given two nonzero polynomials self and right, returns the Sylvester + Given two nonzero polynomials ``self`` and ``right``, return the Sylvester matrix of the polynomials with respect to a given variable. Note that the Sylvester matrix is not defined if one of the polynomials @@ -1362,14 +1362,14 @@ cdef class MPolynomial(CommutativePolynomial): INPUT: - - self , right: multivariate polynomials - - variable: optional, compute the Sylvester matrix with respect to this - variable. If variable is not provided, the first variable of the + - ``self``, ``right``: multivariate polynomials + - ``variable``: optional, compute the Sylvester matrix with respect to this + variable. If ``variable`` is not provided, the first variable of the polynomial ring is used. OUTPUT: - - The Sylvester matrix of self and right. + - The Sylvester matrix of ``self`` and ``right``. EXAMPLES:: @@ -1392,7 +1392,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: f.sylvester_matrix(1 + g, x).determinant() # optional - sage.modules y^2 - y + 7 - If both polynomials are of positive degree with respect to variable, the + If both polynomials are of positive degree with respect to ``variable``, the determinant of the Sylvester matrix is the resultant:: sage: f = R.random_element(4) @@ -1509,17 +1509,14 @@ cdef class MPolynomial(CommutativePolynomial): def discriminant(self,variable): """ - Returns the discriminant of self with respect to the given variable. + Returns the discriminant of ``self`` with respect to the given variable. INPUT: - - ``variable`` - The variable with respect to which we compute - the discriminant - - OUTPUT: - - - An element of the base ring of the polynomial ring. + - ``variable`` - The variable with respect to which we compute + the discriminant + OUTPUT: An element of the base ring of the polynomial ring. EXAMPLES:: @@ -1553,8 +1550,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: f.discriminant(y) # optional - sage.rings.number_field x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - AUTHOR: - Miguel Marco + AUTHOR: Miguel Marco """ if self.is_zero(): return self.parent().zero() @@ -1603,7 +1599,7 @@ cdef class MPolynomial(CommutativePolynomial): def macaulay_resultant(self, *args): r""" - This is an implementation of the Macaulay Resultant. It computes + This is an implementation of the Macaulay resultant. It computes the resultant of universal polynomials as well as polynomials with constant coefficients. This is a project done in sage days 55. It's based on the implementation in Maple by @@ -1618,12 +1614,12 @@ cdef class MPolynomial(CommutativePolynomial): INPUT: - ``args`` -- a list of `n-1` homogeneous polynomials in `n` variables. - works when ``args[0]`` is the list of polynomials, - or ``args`` is itself the list of polynomials + works when ``args[0]`` is the list of polynomials, + or ``args`` is itself the list of polynomials OUTPUT: - - the macaulay resultant + - the Macaulay resultant EXAMPLES: @@ -1645,9 +1641,9 @@ cdef class MPolynomial(CommutativePolynomial): All polynomials must be in the same ring:: - sage: R. = PolynomialRing(QQ,3 ) + sage: R. = PolynomialRing(QQ, 3) sage: S. = PolynomialRing(QQ, 2) - sage: y.macaulay_resultant(z+x, z) # optional - sage.modules + sage: y.macaulay_resultant(z + x, z) # optional - sage.modules Traceback (most recent call last): ... TypeError: not all inputs are polynomials in the calling ring @@ -1673,7 +1669,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: f0 = y0*x2^2 - x0^2 + 2*x1*x2 sage: f1 = y1*x2^2 - x1^2 + 2*x0*x2 sage: f2 = x0*x1 - x2^2 - sage: f0.macaulay_resultant(f1,f2) # optional - sage.modules + sage: f0.macaulay_resultant(f1, f2) # optional - sage.modules y0^2*y1^2 - 4*y0^3 - 4*y1^3 + 18*y0*y1 - 27 a simple example with constant rational coefficients:: @@ -1685,7 +1681,7 @@ cdef class MPolynomial(CommutativePolynomial): an example where the resultant vanishes:: sage: R. = PolynomialRing(QQ, 3) - sage: (x+y).macaulay_resultant([y^2, x]) # optional - sage.modules + sage: (x + y).macaulay_resultant([y^2, x]) # optional - sage.modules 0 an example of bad reduction at a prime ``p = 5``:: @@ -1715,10 +1711,10 @@ cdef class MPolynomial(CommutativePolynomial): sage: y.macaulay_resultant([x + z, z^2]) # optional - sage.modules -1 - when there are only 2 polynomials, macaulay resultant degenerates to the traditional resultant:: + When there are only 2 polynomials, the Macaulay resultant degenerates to the traditional resultant:: sage: R. = PolynomialRing(QQ, 1) - sage: f = x^2+1; g = x^5 + 1 + sage: f = x^2 + 1; g = x^5 + 1 sage: fh = f.homogenize() sage: gh = g.homogenize() sage: RH = fh.parent() @@ -1732,11 +1728,11 @@ cdef class MPolynomial(CommutativePolynomial): def denominator(self): """ - Return a denominator of self. + Return a denominator of ``self``. - First, the lcm of the denominators of the entries of self + First, the lcm of the denominators of the entries of ``self`` is computed and returned. If this computation fails, the - unit of the parent of self is returned. + unit of the parent of ``self`` is returned. Note that some subclasses may implement its own denominator function. @@ -1811,7 +1807,7 @@ cdef class MPolynomial(CommutativePolynomial): def numerator(self): """ - Return a numerator of self computed as self * self.denominator() + Return a numerator of ``self``, computed as ``self * self.denominator()``. Note that some subclasses may implement its own numerator function. @@ -1819,13 +1815,13 @@ cdef class MPolynomial(CommutativePolynomial): .. warning:: This is not the numerator of the rational function - defined by self, which would always be self since self is a + defined by ``self``, which would always be self since ``self`` is a polynomial. EXAMPLES: First we compute the numerator of a polynomial with - integer coefficients, which is of course self. + integer coefficients, which is of course ``self``. :: @@ -1860,7 +1856,7 @@ cdef class MPolynomial(CommutativePolynomial): -x*z - z^2 - y + 1 We check that the computation the numerator and denominator - are valid + are valid. :: @@ -1895,12 +1891,13 @@ cdef class MPolynomial(CommutativePolynomial): def inverse_mod(self, I): """ - Returns an inverse of self modulo the polynomial ideal `I`, + Returns an inverse of ``self`` modulo the polynomial ideal `I`, namely a multivariate polynomial `f` such that ``self * f - 1`` belongs to `I`. INPUT: - - ``I`` -- an ideal of the polynomial ring in which self lives + + - ``I`` -- an ideal of the polynomial ring in which ``self`` lives OUTPUT: @@ -2070,15 +2067,17 @@ cdef class MPolynomial(CommutativePolynomial): sage: gcd(p,q) z*t*x*y + 1 sage: _.parent() - Multivariate Polynomial Ring in x, y over Multivariate Polynomial Ring in z, t over Integer Ring + Multivariate Polynomial Ring in x, y over + Multivariate Polynomial Ring in z, t over Integer Ring Some multivariate polynomial rings have no gcd implementation:: - sage: R. =GaussianIntegers()[] + sage: R. = GaussianIntegers()[] sage: x.gcd(x) Traceback (most recent call last): ... - NotImplementedError: GCD is not implemented for multivariate polynomials over Gaussian Integers in Number Field in I with defining polynomial x^2 + 1 with I = 1*I + NotImplementedError: GCD is not implemented for multivariate polynomials over + Gaussian Integers in Number Field in I with defining polynomial x^2 + 1 with I = 1*I TESTS:: @@ -2167,11 +2166,11 @@ cdef class MPolynomial(CommutativePolynomial): def is_square(self, root=False): r""" - Test whether this polynomial is a square root. + Test whether this polynomial is a square. INPUT: - - ``root`` - if set to ``True`` return a pair ``(True, root)`` + - ``root`` - if set to ``True``, return a pair ``(True, root)`` where ``root`` is a square root or ``(False, None)`` if it is not a square. @@ -2204,7 +2203,7 @@ cdef class MPolynomial(CommutativePolynomial): - ``D`` -- dictionary (optional) - - ``phi`` -- SpecializationMorphism (optional) + - ``phi`` -- :class:`SpecializationMorphism` (optional) OUTPUT: a new polynomial @@ -2281,11 +2280,11 @@ cdef class MPolynomial(CommutativePolynomial): keywords: - - ``prec`` -- integer, sets the precision (default:300) + - ``prec`` -- integer, sets the precision (default: 300) - - ``return_conjugation`` -- boolean. Returns element of `SL(2, \ZZ)` (default:True) + - ``return_conjugation`` -- boolean. Returns element of `SL(2, \ZZ)` (default: True) - - ``error_limit`` -- sets the error tolerance (default:0.000001) + - ``error_limit`` -- sets the error tolerance (default: 0.000001) - ``smallest_coeffs`` -- (default: True), boolean, whether to find the model with smallest coefficients @@ -2293,15 +2292,17 @@ cdef class MPolynomial(CommutativePolynomial): - ``norm_type`` -- either ``'norm'`` or ``'height'``. What type of norm to use for smallest coefficients - - ``emb`` -- (optional) embedding of based field into CC + - ``emb`` -- (optional) embedding of based field into ``CC`` OUTPUT: - - a polynomial (reduced binary form) + - a polynomial (reduced binary form) + + - a matrix (element of `SL(2, \ZZ)`) - - a matrix (element of `SL(2, \ZZ)`) + .. TODO:: - TODO: When Newton's Method doesn't converge to a root in the upper half plane. + When Newton's Method doesn't converge to a root in the upper half plane. Now we just return z0. It would be better to modify and find the unique root in the upper half plane. diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index d2d5831c6a6..c019e73e174 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -593,17 +593,17 @@ def degrees(self): def degree(self, x=None, std_grading=False): """ - Return the degree of self in x, where x must be one of the - generators for the parent of self. + Return the degree of ``self`` in ``x``, where ``x`` must be one of the + generators for the parent of ``self``. INPUT: - ``x`` - multivariate polynomial (a generator of the parent - of self). If ``x`` is not specified (or is None), return - the total degree, which is the maximum degree of any - monomial. Note that a weighted term ordering alters the - grading of the generators of the ring; see the tests below. - To avoid this behavior, set the optional argument ``std_grading=True``. + of ``self``). If ``x`` is not specified (or is None), return + the total degree, which is the maximum degree of any + monomial. Note that a weighted term ordering alters the + grading of the generators of the ring; see the tests below. + To avoid this behavior, set the optional argument ``std_grading=True``. OUTPUT: integer @@ -631,9 +631,9 @@ def degree(self, x=None, std_grading=False): 2 sage: y.degree() 3 - sage: x.degree(y),x.degree(x),y.degree(x),y.degree(y) + sage: x.degree(y), x.degree(x), y.degree(x), y.degree(y) (0, 1, 0, 1) - sage: f = (x^2*y+x*y^2) + sage: f = x^2*y + x*y^2 sage: f.degree(x) 2 sage: f.degree(y) @@ -643,7 +643,7 @@ def degree(self, x=None, std_grading=False): sage: f.degree(std_grading=True) 3 - Note that if ``x`` is not a generator of the parent of self, + Note that if ``x`` is not a generator of the parent of ``self``, for example if it is a generator of a polynomial algebra which maps naturally to this one, then it is converted to an element of this algebra. (This fixes the problem reported in @@ -712,8 +712,8 @@ def degree(self, x=None, std_grading=False): def total_degree(self): """ - Return the total degree of self, which is the maximum degree of any - monomial in self. + Return the total degree of ``self``, which is the maximum degree of any + monomial in ``self``. EXAMPLES:: @@ -741,8 +741,8 @@ def total_degree(self): def monomial_coefficient(self, mon): """ - Return the coefficient in the base ring of the monomial mon in - self, where mon must have the same parent as self. + Return the coefficient in the base ring of the monomial ``mon`` in + ``self``, where ``mon`` must have the same parent as ``self``. This function contrasts with the function ``coefficient`` which returns the coefficient of a @@ -763,16 +763,9 @@ def monomial_coefficient(self, mon): EXAMPLES: - The parent of the return is a member of the base ring. - :: sage: R. = QQbar[] # optional - sage.rings.number_field - - The parent of the return is a member of the base ring. - - :: - sage: f = 2 * x * y # optional - sage.rings.number_field sage: c = f.monomial_coefficient(x*y); c # optional - sage.rings.number_field 2 @@ -1026,7 +1019,7 @@ def global_height(self, prec=None): INPUT: - ``prec`` -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1158,7 +1151,7 @@ def local_height_arch(self, i, prec=None): - ``i`` -- an integer. - ``prec`` -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1286,11 +1279,11 @@ def is_homogeneous(self): EXAMPLES:: sage: R. = QQbar[] # optional - sage.rings.number_field - sage: (x+y).is_homogeneous() # optional - sage.rings.number_field + sage: (x + y).is_homogeneous() # optional - sage.rings.number_field True sage: (x.parent()(0)).is_homogeneous() # optional - sage.rings.number_field True - sage: (x+y^2).is_homogeneous() # optional - sage.rings.number_field + sage: (x + y^2).is_homogeneous() # optional - sage.rings.number_field False sage: (x^2 + y^2).is_homogeneous() # optional - sage.rings.number_field True @@ -1373,7 +1366,7 @@ def is_monomial(self): sage: (x*y).is_monomial() # optional - sage.rings.number_field True - To allow a non-1 leading coefficient, use is_term():: + To allow a non-1 leading coefficient, use :meth:`is_term`:: sage: (2*x*y).is_term() # optional - sage.rings.number_field True @@ -1402,7 +1395,7 @@ def is_term(self): sage: (7*x^5*y).is_term() # optional - sage.rings.number_field True - To require leading coefficient 1, use is_monomial():: + To require leading coefficient 1, use :meth:`is_monomial`:: sage: (2*x*y).is_monomial() # optional - sage.rings.number_field False @@ -1413,10 +1406,10 @@ def is_term(self): def subs(self, fixed=None, **kw): """ - Fixes some given variables in a given multivariate polynomial and - returns the changed multivariate polynomials. The polynomial itself - is not affected. The variable,value pairs for fixing are to be - provided as a dictionary of the form {variable:value}. + Fix some given variables in a given multivariate polynomial and + return the changed multivariate polynomials. The polynomial itself + is not affected. The variable, value pairs for fixing are to be + provided as a dictionary of the form ``{variable: value}``. This is a special case of evaluating the polynomial with some of the variables constants and the others the original variables. @@ -1429,7 +1422,7 @@ def subs(self, fixed=None, **kw): - ``**kw`` - named parameters - OUTPUT: new MPolynomial + OUTPUT: new :class:`MPolynomial` EXAMPLES:: @@ -1450,10 +1443,10 @@ def subs(self, fixed=None, **kw): def monomials(self): """ - Returns the list of monomials in self. The returned list is - decreasingly ordered by the term ordering of self.parent(). + Return the list of monomials in ``self``. The returned list is + decreasingly ordered by the term ordering of ``self.parent()``. - OUTPUT: list of MPolynomials representing Monomials + OUTPUT: list of :class:`MPolynomial` instances, representing monomials EXAMPLES:: @@ -1465,14 +1458,13 @@ def monomials(self): :: sage: R. = QQbar[] # optional - sage.rings.number_field - sage: F = ((fx*gy - fy*gx)^3) # optional - sage.rings.number_field - sage: F # optional - sage.rings.number_field + sage: F = (fx*gy - fy*gx)^3; F # optional - sage.rings.number_field -fy^3*gx^3 + 3*fx*fy^2*gx^2*gy + (-3)*fx^2*fy*gx*gy^2 + fx^3*gy^3 sage: F.monomials() # optional - sage.rings.number_field [fy^3*gx^3, fx*fy^2*gx^2*gy, fx^2*fy*gx*gy^2, fx^3*gy^3] sage: F.coefficients() # optional - sage.rings.number_field [-1, 3, -3, 1] - sage: sum(map(mul,zip(F.coefficients(),F.monomials()))) == F # optional - sage.rings.number_field + sage: sum(map(mul, zip(F.coefficients(), F.monomials()))) == F # optional - sage.rings.number_field True """ ring = self.parent() @@ -1540,13 +1532,13 @@ def univariate_polynomial(self, R=None): INPUT: - - ``R`` - (default: None) PolynomialRing + - ``R`` - (default: None) :class:`PolynomialRing` If this polynomial is not in at most one variable, then a - ValueError exception is raised. This is checked using the - is_univariate() method. The new Polynomial is over the same base - ring as the given MPolynomial. + :class:`ValueError` exception is raised. This is checked using the + method :meth:`is_univariate`. The new :class:`Polynomial` is over the same base + ring as the given :class:`MPolynomial`. EXAMPLES:: @@ -1636,7 +1628,7 @@ def variables(self): def variable(self,i): """ - Returns `i`-th variable occurring in this polynomial. + Return the `i`-th variable occurring in this polynomial. EXAMPLES:: @@ -1651,7 +1643,7 @@ def variable(self,i): def nvariables(self): """ - Number of variables in this polynomial + Return the number of variables in this polynomial. EXAMPLES:: @@ -1684,8 +1676,8 @@ def is_constant(self): def lm(self): """ - Returns the lead monomial of self with respect to the term order of - self.parent(). + Return the lead monomial of ``self`` with respect to the term order of + ``self.parent()``. EXAMPLES:: @@ -1733,8 +1725,8 @@ def lm(self): def lc(self): """ - Returns the leading coefficient of self i.e., - self.coefficient(self.lm()) + Returns the leading coefficient of ``self``, i.e., + ``self.coefficient(self.lm())`` EXAMPLES:: @@ -1755,7 +1747,7 @@ def lc(self): def lt(self): r""" - Returns the leading term of self i.e., self.lc()\*self.lm(). The + Return the leading term of ``self`` i.e., ``self.lc()*self.lm()``. The notion of "leading term" depends on the ordering defined in the parent ring. @@ -1857,7 +1849,7 @@ def _derivative(self, var=None): r""" Differentiates ``self`` with respect to variable ``var``. - If ``var`` is not one of the generators of this ring, _derivative(var) + If ``var`` is not one of the generators of this ring, ``_derivative(var)`` is called recursively on each coefficient of this polynomial. .. SEEALSO:: @@ -1918,7 +1910,7 @@ def integral(self, var=None): The integral is always chosen so the constant term is 0. - If ``var`` is not one of the generators of this ring, integral(var) + If ``var`` is not one of the generators of this ring, ``integral(var)`` is called recursively on each coefficient of this polynomial. EXAMPLES: @@ -1935,7 +1927,8 @@ def integral(self, var=None): sage: R = ZZ['x']['y, z'] sage: y, z = R.gens() sage: R.an_element().integral(y).parent() - Multivariate Polynomial Ring in y, z over Univariate Polynomial Ring in x over Rational Field + Multivariate Polynomial Ring in y, z + over Univariate Polynomial Ring in x over Rational Field On polynomials with coefficients in power series:: @@ -2011,7 +2004,7 @@ def factor(self, proof=None): INPUT: - - ``proof'' - insist on provably correct results (default: ``True`` + - ``proof`` - insist on provably correct results (default: ``True`` unless explicitly disabled for the ``"polynomial"`` subsystem with :class:`sage.structure.proof.proof.WithProof`.) @@ -2165,15 +2158,15 @@ def factor(self, proof=None): @handle_AA_and_QQbar def lift(self,I): """ - given an ideal I = (f_1,...,f_r) and some g (== self) in I, find - s_1,...,s_r such that g = s_1 f_1 + ... + s_r f_r + Given an ideal `I = (f_1,...,f_r)` and some `g` (= ``self``) in `I`, find + `s_1,...,s_r` such that `g = s_1 f_1 + ... + s_r f_r`. ALGORITHM: Use Singular. EXAMPLES:: - sage: A. = PolynomialRing(CC,2,order='degrevlex') - sage: I = A.ideal([x^10 + x^9*y^2, y^8 - x^2*y^7 ]) + sage: A. = PolynomialRing(CC, 2, order='degrevlex') + sage: I = A.ideal([x^10 + x^9*y^2, y^8 - x^2*y^7]) sage: f = x*y^13 + y^12 sage: M = f.lift(I) sage: M @@ -2183,7 +2176,7 @@ def lift(self,I): TESTS: - Check that this method works over QQbar (:trac:`25351`):: + Check that this method works over ``QQbar`` (:trac:`25351`):: sage: A. = QQbar[] # optional - sage.rings.number_field sage: I = A.ideal([x^2 + y^2 - 1, x^2 - y^2]) # optional - sage.rings.number_field @@ -2461,22 +2454,22 @@ def reduce(self, I): def degree_lowest_rational_function(r, x): r""" - Return the difference of valuations of r with respect to variable x. + Return the difference of valuations of ``r`` with respect to variable ``x``. INPUT: - ``r`` -- a multivariate rational function - - ``x`` -- a multivariate polynomial ring generator x + - ``x`` -- a multivariate polynomial ring generator OUTPUT: - - ``integer`` -- the difference val_x(p) - val_x(q) where r = p/q + - ``integer`` -- the difference `val_x(p) - val_x(q)` where `r = p/q` .. NOTE:: This function should be made a method of the - FractionFieldElement class. + :class:`FractionFieldElement` class. EXAMPLES:: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index ad2e44c38a6..d4b70dbf8ab 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -12,7 +12,7 @@ EXAMPLES: We compute a Groebner basis for some given ideal. The type returned by -the ``groebner_basis`` method is ``PolynomialSequence``, i.e. it is not a +the ``groebner_basis`` method is ``PolynomialSequence``, i.e., it is not a :class:`MPolynomialIdeal`:: sage: x,y,z = QQ['x,y,z'].gens() @@ -150,7 +150,7 @@ sage: I.change_ring(P.change_ring(QQ)).groebner_basis() [1] - However, when we compute the Groebner basis of I (defined over + However, when we compute the Groebner basis of `I` (defined over `\ZZ`), we note that there is a certain integer in the ideal which is not 1. :: @@ -158,7 +158,7 @@ [x + y + 57119*z + 4, y^2 + 3*y + 17220, y*z + ..., 2*y + 158864, z^2 + 17223, 2*z + 41856, 164878] Now for each prime `p` dividing this integer 164878, the Groebner - basis of I modulo `p` will be non-trivial and will thus give a + basis of `I` modulo `p` will be non-trivial and will thus give a solution of the original system modulo `p`. :: @@ -302,7 +302,7 @@ def __call__(self, *args, **kwds): def is_MPolynomialIdeal(x): """ - Return ``True`` if the provided argument ``x`` is an ideal in the + Return ``True`` if the provided argument ``x`` is an ideal in a multivariate polynomial ring. INPUT: @@ -727,7 +727,7 @@ def complete_primary_decomposition(self, algorithm="sy"): `b^n \in Q` for some `n \in \ZZ`. If `Q` is a primary ideal of the ring `R`, then the radical - ideal `P` of `Q` (i.e. the ideal consisting of all `a \in R` + ideal `P` of `Q` (i.e., the ideal consisting of all `a \in R` with a^n \in Q` for some `n \in \ZZ`), is called the associated prime of `Q`. @@ -761,7 +761,7 @@ def complete_primary_decomposition(self, algorithm="sy"): sage: R. = PolynomialRing(QQ, 3, order='lex') sage: p = z^2 + 1; q = z^3 + 2 - sage: I = (p*q^2, y-z^2)*R + sage: I = (p*q^2, y - z^2) * R sage: pd = I.complete_primary_decomposition(); sorted(pd, key=str) [(Ideal (z^2 + 1, y + 1) of Multivariate Polynomial Ring in x, y, z over Rational Field, Ideal (z^2 + 1, y + 1) of Multivariate Polynomial Ring in x, y, z over Rational Field), @@ -840,8 +840,8 @@ def primary_decomposition(self, algorithm='sy'): `b^n \in Q` for some `n \in \ZZ`. If `Q` is a primary ideal of the ring `R`, then the radical - ideal `P` of `Q` (i.e. the ideal consisting of all `a \in R` - with a^n \in Q` for some `n \in \ZZ`), is called the + ideal `P` of `Q` (i.e., the ideal consisting of all `a \in R` + with `a^n \in Q` for some `n \in \ZZ`), is called the associated prime of `Q`. If `I` is a proper ideal of a Noetherian ring `R`, then there @@ -873,15 +873,17 @@ def primary_decomposition(self, algorithm='sy'): sage: R. = PolynomialRing(QQ, 3, order='lex') sage: p = z^2 + 1; q = z^3 + 2 - sage: I = (p*q^2, y-z^2)*R + sage: I = (p*q^2, y - z^2) * R sage: pd = I.primary_decomposition(); sorted(pd, key=str) - [Ideal (z^2 + 1, y + 1) of Multivariate Polynomial Ring in x, y, z over Rational Field, - Ideal (z^6 + 4*z^3 + 4, y - z^2) of Multivariate Polynomial Ring in x, y, z over Rational Field] + [Ideal (z^2 + 1, y + 1) + of Multivariate Polynomial Ring in x, y, z over Rational Field, + Ideal (z^6 + 4*z^3 + 4, y - z^2) + of Multivariate Polynomial Ring in x, y, z over Rational Field] :: sage: from functools import reduce - sage: reduce(lambda Qi,Qj: Qi.intersection(Qj), pd) == I + sage: reduce(lambda Qi, Qj: Qi.intersection(Qj), pd) == I True ALGORITHM: @@ -945,7 +947,7 @@ def associated_primes(self, algorithm='sy'): sage: R. = PolynomialRing(QQ, 3, order='lex') sage: p = z^2 + 1; q = z^3 + 2 - sage: I = (p*q^2, y-z^2)*R + sage: I = (p*q^2, y - z^2) * R sage: pd = I.associated_primes(); sorted(pd, key=str) [Ideal (z^2 + 1, y + 1) of Multivariate Polynomial Ring in x, y, z over Rational Field, Ideal (z^3 + 2, y - z^2) of Multivariate Polynomial Ring in x, y, z over Rational Field] @@ -975,13 +977,13 @@ def is_prime(self, **kwds): EXAMPLES:: sage: R. = PolynomialRing(QQ, 2) - sage: I = (x^2 - y^2 - 1)*R + sage: I = (x^2 - y^2 - 1) * R sage: I.is_prime() True sage: (I^2).is_prime() False - sage: J = (x^2 - y^2)*R + sage: J = (x^2 - y^2) * R sage: J.is_prime() False sage: (J^3).is_prime() @@ -995,9 +997,12 @@ def is_prime(self, **kwds): fraction field is not the quotient ring itself:: sage: Q = R.quotient(I); Q - Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 - y^2 - 1) + Quotient of Multivariate Polynomial Ring in x, y over Rational Field + by the ideal (x^2 - y^2 - 1) sage: Q.fraction_field() - Fraction Field of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 - y^2 - 1) + Fraction Field of + Quotient of Multivariate Polynomial Ring in x, y over Rational Field + by the ideal (x^2 - y^2 - 1) """ if not self.ring().base_ring().is_field(): raise NotImplementedError @@ -1017,7 +1022,7 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): sets. This requires that the given basis is reduced w.r.t. to the - lexicographical monomial ordering. If the basis of self does + lexicographical monomial ordering. If the basis of ``self`` does not have this property, the required Groebner basis is computed implicitly. @@ -1027,14 +1032,14 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): ALGORITHMS: - - ``singular:triangL`` - decomposition of self into triangular + - ``"singular:triangL"`` - decomposition of ``self`` into triangular systems (Lazard). - - ``singular:triangLfak`` - decomp. of self into tri. systems + - ``"singular:triangLfak"`` - decomposition of ``self`` into triangular systems plus factorization. - - ``singular:triangM`` - decomposition of self into - triangular systems (Moeller). + - ``"singular:triangM"`` - decomposition of ``self`` into + triangular systems (Moeller). OUTPUT: a list `T` of lists `t` such that the variety of ``self`` is the union of the varieties of `t` in `L` and each @@ -1042,23 +1047,38 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): EXAMPLES:: - sage: P. = PolynomialRing(QQ,5,order='lex') + sage: P. = PolynomialRing(QQ, 5, order='lex'); P.rename("P") sage: I = sage.rings.ideal.Cyclic(P) sage: GB = Ideal(I.groebner_basis('libsingular:stdfglm')) sage: GB.triangular_decomposition('singular:triangLfak') - [Ideal (a - 1, b - 1, c - 1, d^2 + 3*d + 1, e + d + 3) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a - 1, b - 1, c^2 + 3*c + 1, d + c + 3, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a - 1, b^2 + 3*b + 1, c + b + 3, d - 1, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a - 1, b^4 + b^3 + b^2 + b + 1, -c + b^2, -d + b^3, e + b^3 + b^2 + b + 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^2 + 3*a + 1, b - 1, c - 1, d - 1, e + a + 3) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^2 + 3*a + 1, b + a + 3, c - 1, d - 1, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 - 4*a^3 + 6*a^2 + a + 1, -11*b^2 + 6*b*a^3 - 26*b*a^2 + 41*b*a - 4*b - 8*a^3 + 31*a^2 - 40*a - 24, 11*c + 3*a^3 - 13*a^2 + 26*a - 2, 11*d + 3*a^3 - 13*a^2 + 26*a - 2, -11*e - 11*b + 6*a^3 - 26*a^2 + 41*a - 4) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + a^2 + a + 1, b - 1, c + a^3 + a^2 + a + 1, -d + a^3, -e + a^2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + a^2 + a + 1, b - a, c - a, d^2 + 3*d*a + a^2, e + d + 3*a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + a^2 + a + 1, b - a, c^2 + 3*c*a + a^2, d + c + 3*a, e - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + a^2 + a + 1, b^2 + 3*b*a + a^2, c + b + 3*a, d - a, e - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + a^2 + a + 1, b^3 + b^2*a + b^2 + b*a^2 + b*a + b + a^3 + a^2 + a + 1, c + b^2*a^3 + b^2*a^2 + b^2*a + b^2, -d + b^2*a^2 + b^2*a + b^2 + b*a^2 + b*a + a^2, -e + b^2*a^3 - b*a^2 - b*a - b - a^2 - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field, - Ideal (a^4 + a^3 + 6*a^2 - 4*a + 1, -11*b^2 + 6*b*a^3 + 10*b*a^2 + 39*b*a + 2*b + 16*a^3 + 23*a^2 + 104*a - 24, 11*c + 3*a^3 + 5*a^2 + 25*a + 1, 11*d + 3*a^3 + 5*a^2 + 25*a + 1, -11*e - 11*b + 6*a^3 + 10*a^2 + 39*a + 2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field] + [Ideal (a - 1, b - 1, c - 1, d^2 + 3*d + 1, e + d + 3) of P, + Ideal (a - 1, b - 1, c^2 + 3*c + 1, d + c + 3, e - 1) of P, + Ideal (a - 1, b^2 + 3*b + 1, c + b + 3, d - 1, e - 1) of P, + Ideal (a - 1, b^4 + b^3 + b^2 + b + 1, -c + b^2, -d + b^3, + e + b^3 + b^2 + b + 1) of P, + Ideal (a^2 + 3*a + 1, b - 1, c - 1, d - 1, e + a + 3) of P, + Ideal (a^2 + 3*a + 1, b + a + 3, c - 1, d - 1, e - 1) of P, + Ideal (a^4 - 4*a^3 + 6*a^2 + a + 1, + -11*b^2 + 6*b*a^3 - 26*b*a^2 + 41*b*a - 4*b - 8*a^3 + 31*a^2 - 40*a - 24, + 11*c + 3*a^3 - 13*a^2 + 26*a - 2, 11*d + 3*a^3 - 13*a^2 + 26*a - 2, + -11*e - 11*b + 6*a^3 - 26*a^2 + 41*a - 4) of P, + Ideal (a^4 + a^3 + a^2 + a + 1, + b - 1, c + a^3 + a^2 + a + 1, -d + a^3, -e + a^2) of P, + Ideal (a^4 + a^3 + a^2 + a + 1, + b - a, c - a, d^2 + 3*d*a + a^2, e + d + 3*a) of P, + Ideal (a^4 + a^3 + a^2 + a + 1, + b - a, c^2 + 3*c*a + a^2, d + c + 3*a, e - a) of P, + Ideal (a^4 + a^3 + a^2 + a + 1, + b^2 + 3*b*a + a^2, c + b + 3*a, d - a, e - a) of P, + Ideal (a^4 + a^3 + a^2 + a + 1, + b^3 + b^2*a + b^2 + b*a^2 + b*a + b + a^3 + a^2 + a + 1, + c + b^2*a^3 + b^2*a^2 + b^2*a + b^2, + -d + b^2*a^2 + b^2*a + b^2 + b*a^2 + b*a + a^2, + -e + b^2*a^3 - b*a^2 - b*a - b - a^2 - a) of P, + Ideal (a^4 + a^3 + 6*a^2 - 4*a + 1, + -11*b^2 + 6*b*a^3 + 10*b*a^2 + 39*b*a + 2*b + 16*a^3 + 23*a^2 + 104*a - 24, + 11*c + 3*a^3 + 5*a^2 + 25*a + 1, 11*d + 3*a^3 + 5*a^2 + 25*a + 1, + -11*e - 11*b + 6*a^3 + 10*a^2 + 39*a + 2) of P] sage: R. = PolynomialRing(QQ, 2, order='lex') sage: f1 = 1/2*((x1^2 + 2*x1 - 4)*x2^2 + 2*(x1^2 + x1)*x2 + x1^2) @@ -1068,7 +1088,8 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): [Ideal (x2, x1^2) of Multivariate Polynomial Ring in x1, x2 over Rational Field, Ideal (x2, x1^2) of Multivariate Polynomial Ring in x1, x2 over Rational Field, Ideal (x2, x1^2) of Multivariate Polynomial Ring in x1, x2 over Rational Field, - Ideal (x2^4 + 4*x2^3 - 6*x2^2 - 20*x2 + 5, 8*x1 - x2^3 + x2^2 + 13*x2 - 5) of Multivariate Polynomial Ring in x1, x2 over Rational Field] + Ideal (x2^4 + 4*x2^3 - 6*x2^2 - 20*x2 + 5, 8*x1 - x2^3 + x2^2 + 13*x2 - 5) + of Multivariate Polynomial Ring in x1, x2 over Rational Field] TESTS:: @@ -1152,7 +1173,7 @@ def dimension(self, singular=singular_default): EXAMPLES:: sage: R. = PolynomialRing(GF(2147483659^2), order='lex') # optional - sage.rings.finite_rings - sage: I = R.ideal([x*y, x*y+1]) # optional - sage.rings.finite_rings + sage: I = R.ideal([x*y, x*y + 1]) # optional - sage.rings.finite_rings sage: I.dimension() # optional - sage.rings.finite_rings verbose 0 (...: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation. -1 @@ -1252,7 +1273,7 @@ def dimension(self, singular=singular_default): def vector_space_dimension(self): """ Return the vector space dimension of the ring modulo this ideal. If - the ideal is not zero-dimensional, a TypeError is raised. + the ideal is not zero-dimensional, a :class:`TypeError` is raised. ALGORITHM: @@ -1602,22 +1623,23 @@ def intersection(self, *others): The following simple example illustrates that the product need not equal the intersection. :: - sage: I = (x^2, y)*R - sage: J = (y^2, x)*R + sage: I = (x^2, y) * R + sage: J = (y^2, x) * R sage: K = I.intersection(J); K Ideal (y^2, x*y, x^2) of Multivariate Polynomial Ring in x, y over Rational Field sage: IJ = I*J; IJ - Ideal (x^2*y^2, x^3, y^3, x*y) of Multivariate Polynomial Ring in x, y over Rational Field + Ideal (x^2*y^2, x^3, y^3, x*y) + of Multivariate Polynomial Ring in x, y over Rational Field sage: IJ == K False Intersection of several ideals:: sage: R. = PolynomialRing(QQ, 3, order='lex') - sage: I1 = x*R - sage: I2 = y*R - sage: I3 = (x, y)*R - sage: I4 = (x^2 + x*y*z, y^2 - z^3*y, z^3 + y^5*x*z)*R + sage: I1 = x * R + sage: I2 = y * R + sage: I3 = (x, y) * R + sage: I4 = (x^2 + x*y*z, y^2 - z^3*y, z^3 + y^5*x*z) * R sage: I1.intersection(I2, I3, I4).groebner_basis() [x^2*y + x*y*z^4, x*y^2 - x*y*z^3, x*y*z^20 - x*y*z^3] @@ -1667,10 +1689,12 @@ def minimal_associated_primes(self): sage: R. = PolynomialRing(QQ, 3, 'xyz') sage: p = z^2 + 1; q = z^3 + 2 - sage: I = (p*q^2, y-z^2)*R + sage: I = (p*q^2, y - z^2) * R sage: sorted(I.minimal_associated_primes(), key=str) - [Ideal (z^2 + 1, -z^2 + y) of Multivariate Polynomial Ring in x, y, z over Rational Field, - Ideal (z^3 + 2, -z^2 + y) of Multivariate Polynomial Ring in x, y, z over Rational Field] + [Ideal (z^2 + 1, -z^2 + y) + of Multivariate Polynomial Ring in x, y, z over Rational Field, + Ideal (z^3 + 2, -z^2 + y) + of Multivariate Polynomial Ring in x, y, z over Rational Field] ALGORITHM: @@ -1694,7 +1718,7 @@ def radical(self): This is an obviously not radical ideal:: sage: R. = PolynomialRing(QQ, 3) - sage: I = (x^2, y^3, (x*z)^4 + y^3 + 10*x^2)*R + sage: I = (x^2, y^3, (x*z)^4 + y^3 + 10*x^2) * R sage: I.radical() Ideal (y, x) of Multivariate Polynomial Ring in x, y, z over Rational Field @@ -1706,9 +1730,10 @@ def radical(self): This is the example from the Singular manual:: sage: p = z^2 + 1; q = z^3 + 2 - sage: I = (p*q^2, y-z^2)*R + sage: I = (p*q^2, y - z^2) * R sage: I.radical() - Ideal (z^2 - y, y^2*z + y*z + 2*y + 2) of Multivariate Polynomial Ring in x, y, z over Rational Field + Ideal (z^2 - y, y^2*z + y*z + 2*y + 2) + of Multivariate Polynomial Ring in x, y, z over Rational Field .. NOTE:: @@ -1720,9 +1745,10 @@ def radical(self): sage: R. = PolynomialRing(GF(37), 3) # optional - sage.rings.finite_rings sage: p = z^2 + 1; q = z^3 + 2 # optional - sage.rings.finite_rings - sage: I = (p*q^2, y - z^2)*R # optional - sage.rings.finite_rings + sage: I = (p*q^2, y - z^2) * R # optional - sage.rings.finite_rings sage: I.radical() # optional - sage.rings.finite_rings - Ideal (z^2 - y, y^2*z + y*z + 2*y + 2) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 37 + Ideal (z^2 - y, y^2*z + y*z + 2*y + 2) + of Multivariate Polynomial Ring in x, y, z over Finite Field of size 37 """ from sage.libs.singular.function_factory import ff radical = ff.primdec__lib.radical @@ -1906,38 +1932,38 @@ def graded_free_resolution(self, *args, **kwds): @libsingular_gb_standard_options def interreduced_basis(self): r""" - If this ideal is spanned by `(f_1, ..., f_n)` this method - returns `(g_1, ..., g_s)` such that: + If this ideal is spanned by `(f_1, ..., f_n)`, + return `(g_1, ..., g_s)` such that: - `(f_1,...,f_n) = (g_1,...,g_s)` - - `LT(g_i) != LT(g_j)` for all `i != j` + - `LT(g_i) \neq LT(g_j)` for all `i \neq j` - `LT(g_i)` does not divide `m` for all monomials `m` of - `\{g_1,...,g_{i-1},g_{i+1},...,g_s\}` + `\{g_1,...,g_{i-1},g_{i+1},...,g_s\}` - - `LC(g_i) == 1` for all `i` if the coefficient ring is a field. + - `LC(g_i) = 1` for all `i` if the coefficient ring is a field. EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: I = Ideal([z*x+y^3,z+y^3,z+x*y]) + sage: I = Ideal([z*x + y^3, z + y^3, z + x*y]) sage: I.interreduced_basis() [y^3 + z, x*y + z, x*z - z] Note that tail reduction for local orderings is not well-defined:: sage: R. = PolynomialRing(QQ,order='negdegrevlex') - sage: I = Ideal([z*x+y^3,z+y^3,z+x*y]) + sage: I = Ideal([z*x + y^3, z + y^3, z + x*y]) sage: I.interreduced_basis() [z + x*y, x*y - y^3, x^2*y - y^3] A fixed error with nonstandard base fields:: - sage: R.=QQ['t'] - sage: K.=R.fraction_field()['x,y'] - sage: I=t*x*K + sage: R. = QQ['t'] + sage: K. = R.fraction_field()['x,y'] + sage: I = t*x * K sage: I.interreduced_basis() [x] @@ -1949,7 +1975,7 @@ def interreduced_basis(self): ALGORITHM: - Uses Singular's interred command or + Uses Singular's ``interred`` command or :func:`sage.rings.polynomial.toy_buchberger.inter_reduction` if conversion to Singular fails. @@ -1998,28 +2024,47 @@ def basis_is_groebner(self, singular=singular_default): A more complicated example:: sage: R. = PolynomialRing(GF(7583)) # optional - sage.rings.finite_rings - sage: l = [u6 + u5 + u4 + u3 + u2 - 3791*h, \ - U6 + U5 + U4 + U3 + U2 - 3791*h, \ - U2*u2 - h^2, U3*u3 - h^2, U4*u4 - h^2, \ - U5*u4 + U5*u3 + U4*u3 + U5*u2 + U4*u2 + U3*u2 - 3791*U5*h - 3791*U4*h - 3791*U3*h - 3791*U2*h - 2842*h^2, \ - U4*u5 + U3*u5 + U2*u5 + U3*u4 + U2*u4 + U2*u3 - 3791*u5*h - 3791*u4*h - 3791*u3*h - 3791*u2*h - 2842*h^2, \ - U5*u5 - h^2, U4*U2*u3 + U5*U3*u2 + U4*U3*u2 + U3^2*u2 - 3791*U5*U3*h - 3791*U4*U3*h - 3791*U3^2*h - 3791*U5*U2*h \ - - 3791*U4*U2*h + U3*U2*h - 3791*U2^2*h - 3791*U4*u3*h - 3791*U4*u2*h - 3791*U3*u2*h - 2843*U5*h^2 + 1897*U4*h^2 - 946*U3*h^2 - 947*U2*h^2 + 2370*h^3, \ - U3*u5*u4 + U2*u5*u4 + U3*u4^2 + U2*u4^2 + U2*u4*u3 - 3791*u5*u4*h - 3791*u4^2*h - 3791*u4*u3*h - 3791*u4*u2*h + u5*h^2 - 2842*u4*h^2, \ - U2*u5*u4*u3 + U2*u4^2*u3 + U2*u4*u3^2 - 3791*u5*u4*u3*h - 3791*u4^2*u3*h - 3791*u4*u3^2*h - 3791*u4*u3*u2*h + u5*u4*h^2 + u4^2*h^2 + u5*u3*h^2 - 2842*u4*u3*h^2, \ - U5^2*U4*u3 + U5*U4^2*u3 + U5^2*U4*u2 + U5*U4^2*u2 + U5^2*U3*u2 + 2*U5*U4*U3*u2 + U5*U3^2*u2 - 3791*U5^2*U4*h - 3791*U5*U4^2*h - 3791*U5^2*U3*h \ - + U5*U4*U3*h - 3791*U5*U3^2*h - 3791*U5^2*U2*h + U5*U4*U2*h + U5*U3*U2*h - 3791*U5*U2^2*h - 3791*U5*U3*u2*h - 2842*U5^2*h^2 + 1897*U5*U4*h^2 \ - - U4^2*h^2 - 947*U5*U3*h^2 - U4*U3*h^2 - 948*U5*U2*h^2 - U4*U2*h^2 - 1422*U5*h^3 + 3791*U4*h^3, \ - u5*u4*u3*u2*h + u4^2*u3*u2*h + u4*u3^2*u2*h + u4*u3*u2^2*h + 2*u5*u4*u3*h^2 + 2*u4^2*u3*h^2 + 2*u4*u3^2*h^2 + 2*u5*u4*u2*h^2 + 2*u4^2*u2*h^2 \ - + 2*u5*u3*u2*h^2 + 1899*u4*u3*u2*h^2, \ - U5^2*U4*U3*u2 + U5*U4^2*U3*u2 + U5*U4*U3^2*u2 - 3791*U5^2*U4*U3*h - 3791*U5*U4^2*U3*h - 3791*U5*U4*U3^2*h - 3791*U5*U4*U3*U2*h \ - + 3791*U5*U4*U3*u2*h + U5^2*U4*h^2 + U5*U4^2*h^2 + U5^2*U3*h^2 - U4^2*U3*h^2 - U5*U3^2*h^2 - U4*U3^2*h^2 - U5*U4*U2*h^2 \ - - U5*U3*U2*h^2 - U4*U3*U2*h^2 + 3791*U5*U4*h^3 + 3791*U5*U3*h^3 + 3791*U4*U3*h^3, \ - u4^2*u3*u2*h^2 + 1515*u5*u3^2*u2*h^2 + u4*u3^2*u2*h^2 + 1515*u5*u4*u2^2*h^2 + 1515*u5*u3*u2^2*h^2 + u4*u3*u2^2*h^2 \ - + 1521*u5*u4*u3*h^3 - 3028*u4^2*u3*h^3 - 3028*u4*u3^2*h^3 + 1521*u5*u4*u2*h^3 - 3028*u4^2*u2*h^3 + 1521*u5*u3*u2*h^3 + 3420*u4*u3*u2*h^3, \ - U5^2*U4*U3*U2*h + U5*U4^2*U3*U2*h + U5*U4*U3^2*U2*h + U5*U4*U3*U2^2*h + 2*U5^2*U4*U3*h^2 + 2*U5*U4^2*U3*h^2 + 2*U5*U4*U3^2*h^2 \ - + 2*U5^2*U4*U2*h^2 + 2*U5*U4^2*U2*h^2 + 2*U5^2*U3*U2*h^2 - 2*U4^2*U3*U2*h^2 - 2*U5*U3^2*U2*h^2 - 2*U4*U3^2*U2*h^2 \ - - 2*U5*U4*U2^2*h^2 - 2*U5*U3*U2^2*h^2 - 2*U4*U3*U2^2*h^2 - U5*U4*U3*h^3 - U5*U4*U2*h^3 - U5*U3*U2*h^3 - U4*U3*U2*h^3] # optional - sage.rings.finite_rings + sage: l = [u6 + u5 + u4 + u3 + u2 - 3791*h, # optional - sage.rings.finite_rings + ....: U6 + U5 + U4 + U3 + U2 - 3791*h, + ....: U2*u2 - h^2, U3*u3 - h^2, U4*u4 - h^2, + ....: U5*u4 + U5*u3 + U4*u3 + U5*u2 + U4*u2 + U3*u2 - 3791*U5*h + ....: - 3791*U4*h - 3791*U3*h - 3791*U2*h - 2842*h^2, + ....: U4*u5 + U3*u5 + U2*u5 + U3*u4 + U2*u4 + U2*u3 - 3791*u5*h + ....: - 3791*u4*h - 3791*u3*h - 3791*u2*h - 2842*h^2, + ....: U5*u5 - h^2, U4*U2*u3 + U5*U3*u2 + U4*U3*u2 + U3^2*u2 - 3791*U5*U3*h + ....: - 3791*U4*U3*h - 3791*U3^2*h - 3791*U5*U2*h- 3791*U4*U2*h + U3*U2*h + ....: - 3791*U2^2*h - 3791*U4*u3*h - 3791*U4*u2*h - 3791*U3*u2*h + ....: - 2843*U5*h^2 + 1897*U4*h^2 - 946*U3*h^2 - 947*U2*h^2 + 2370*h^3, + ....: U3*u5*u4 + U2*u5*u4 + U3*u4^2 + U2*u4^2 + U2*u4*u3 - 3791*u5*u4*h + ....: - 3791*u4^2*h - 3791*u4*u3*h - 3791*u4*u2*h + u5*h^2 - 2842*u4*h^2, + ....: U2*u5*u4*u3 + U2*u4^2*u3 + U2*u4*u3^2 - 3791*u5*u4*u3*h + ....: - 3791*u4^2*u3*h - 3791*u4*u3^2*h - 3791*u4*u3*u2*h + u5*u4*h^2 + ....: + u4^2*h^2 + u5*u3*h^2 - 2842*u4*u3*h^2, + ....: U5^2*U4*u3 + U5*U4^2*u3 + U5^2*U4*u2 + U5*U4^2*u2 + U5^2*U3*u2 + ....: + 2*U5*U4*U3*u2 + U5*U3^2*u2 - 3791*U5^2*U4*h - 3791*U5*U4^2*h + ....: - 3791*U5^2*U3*h + U5*U4*U3*h - 3791*U5*U3^2*h - 3791*U5^2*U2*h + ....: + U5*U4*U2*h+ U5*U3*U2*h - 3791*U5*U2^2*h - 3791*U5*U3*u2*h + ....: - 2842*U5^2*h^2 + 1897*U5*U4*h^2 - U4^2*h^2 - 947*U5*U3*h^2 + ....: - U4*U3*h^2 - 948*U5*U2*h^2 - U4*U2*h^2 - 1422*U5*h^3 + 3791*U4*h^3, + ....: u5*u4*u3*u2*h + u4^2*u3*u2*h + u4*u3^2*u2*h + u4*u3*u2^2*h + ....: + 2*u5*u4*u3*h^2 + 2*u4^2*u3*h^2 + 2*u4*u3^2*h^2 + 2*u5*u4*u2*h^2 + ....: + 2*u4^2*u2*h^2 + 2*u5*u3*u2*h^2 + 1899*u4*u3*u2*h^2, + ....: U5^2*U4*U3*u2 + U5*U4^2*U3*u2 + U5*U4*U3^2*u2 - 3791*U5^2*U4*U3*h + ....: - 3791*U5*U4^2*U3*h - 3791*U5*U4*U3^2*h - 3791*U5*U4*U3*U2*h + ....: + 3791*U5*U4*U3*u2*h + U5^2*U4*h^2 + U5*U4^2*h^2 + U5^2*U3*h^2 + ....: - U4^2*U3*h^2 - U5*U3^2*h^2 - U4*U3^2*h^2 - U5*U4*U2*h^2 - U5*U3*U2*h^2 + ....: - U4*U3*U2*h^2 + 3791*U5*U4*h^3 + 3791*U5*U3*h^3 + 3791*U4*U3*h^3, + ....: u4^2*u3*u2*h^2 + 1515*u5*u3^2*u2*h^2 + u4*u3^2*u2*h^2 + ....: + 1515*u5*u4*u2^2*h^2 + 1515*u5*u3*u2^2*h^2 + u4*u3*u2^2*h^2 + ....: + 1521*u5*u4*u3*h^3 - 3028*u4^2*u3*h^3 - 3028*u4*u3^2*h^3 + ....: + 1521*u5*u4*u2*h^3 - 3028*u4^2*u2*h^3 + 1521*u5*u3*u2*h^3 + ....: + 3420*u4*u3*u2*h^3, + ....: U5^2*U4*U3*U2*h + U5*U4^2*U3*U2*h + U5*U4*U3^2*U2*h + U5*U4*U3*U2^2*h + ....: + 2*U5^2*U4*U3*h^2 + 2*U5*U4^2*U3*h^2 + 2*U5*U4*U3^2*h^2 + ....: + 2*U5^2*U4*U2*h^2 + 2*U5*U4^2*U2*h^2 + 2*U5^2*U3*U2*h^2 + ....: - 2*U4^2*U3*U2*h^2 - 2*U5*U3^2*U2*h^2 - 2*U4*U3^2*U2*h^2 + ....: - 2*U5*U4*U2^2*h^2 - 2*U5*U3*U2^2*h^2 - 2*U4*U3*U2^2*h^2 + ....: - U5*U4*U3*h^3 - U5*U4*U2*h^3 - U5*U3*U2*h^3 - U4*U3*U2*h^3] sage: Ideal(l).basis_is_groebner() # optional - sage.rings.finite_rings False @@ -2097,25 +2142,25 @@ def transformed_basis(self, algorithm="gwalk", other_ring=None, singular=singula - ``algorithm`` - see below for options. - - ``other_ring`` - only valid for algorithm 'fglm', if - provided conversion will be performed to this + - ``other_ring`` - only valid for ``algorithm='fglm'``; if + provided, conversion will be performed to this ring. Otherwise a lex Groebner basis will be returned. ALGORITHMS: - - ``fglm`` - FGLM algorithm. The input ideal must be given with a reduced + - ``"fglm"`` - FGLM algorithm. The input ideal must be given with a reduced Groebner Basis of a zero-dimensional ideal - - ``gwalk`` - Groebner Walk algorithm (*default*) + - ``"gwalk"`` - Groebner Walk algorithm (*default*) - - ``awalk1`` - 'first alternative' algorithm + - ``"awalk1"`` - 'first alternative' algorithm - - ``awalk2`` - 'second alternative' algorithm + - ``"awalk2"`` - 'second alternative' algorithm - - ``twalk`` - Tran algorithm + - ``"twalk"`` - Tran algorithm - - ``fwalk`` - Fractal Walk algorithm + - ``"fwalk"`` - Fractal Walk algorithm EXAMPLES:: @@ -2126,7 +2171,7 @@ def transformed_basis(self, algorithm="gwalk", other_ring=None, singular=singula sage: J = Ideal(I.transformed_basis('fglm',S)) sage: J Ideal (z^4 + y^3 - y, x^2 + y^3, x*y^3 - y^3, y^4 + y^3) - of Multivariate Polynomial Ring in z, x, y over Rational Field + of Multivariate Polynomial Ring in z, x, y over Rational Field :: @@ -2134,13 +2179,14 @@ def transformed_basis(self, algorithm="gwalk", other_ring=None, singular=singula sage: I = Ideal([y^3 + x*y*z + y^2*z + x*z^3, 3 + x*y + x^2*y + y^2*z]) # optional - sage.rings.finite_rings sage: I.transformed_basis('gwalk') # optional - sage.rings.finite_rings [z*y^2 + y*x^2 + y*x + 3, - z*x + 8297*y^8*x^2 + 8297*y^8*x + 3556*y^7 - 8297*y^6*x^4 + 15409*y^6*x^3 - 8297*y^6*x^2 - - 8297*y^5*x^5 + 15409*y^5*x^4 - 8297*y^5*x^3 + 3556*y^5*x^2 + 3556*y^5*x + 3556*y^4*x^3 - + 3556*y^4*x^2 - 10668*y^4 - 10668*y^3*x - 8297*y^2*x^9 - 1185*y^2*x^8 + 14224*y^2*x^7 - - 1185*y^2*x^6 - 8297*y^2*x^5 - 14223*y*x^7 - 10666*y*x^6 - 10666*y*x^5 - 14223*y*x^4 - + x^5 + 2*x^4 + x^3, - y^9 - y^7*x^2 - y^7*x - y^6*x^3 - y^6*x^2 - 3*y^6 - 3*y^5*x - y^3*x^7 - 3*y^3*x^6 - - 3*y^3*x^5 - y^3*x^4 - 9*y^2*x^5 - 18*y^2*x^4 - 9*y^2*x^3 - 27*y*x^3 - 27*y*x^2 - 27*x] + z*x + 8297*y^8*x^2 + 8297*y^8*x + 3556*y^7 - 8297*y^6*x^4 + 15409*y^6*x^3 + - 8297*y^6*x^2 - 8297*y^5*x^5 + 15409*y^5*x^4 - 8297*y^5*x^3 + 3556*y^5*x^2 + + 3556*y^5*x + 3556*y^4*x^3 + 3556*y^4*x^2 - 10668*y^4 - 10668*y^3*x + - 8297*y^2*x^9 - 1185*y^2*x^8 + 14224*y^2*x^7 - 1185*y^2*x^6 - 8297*y^2*x^5 + - 14223*y*x^7 - 10666*y*x^6 - 10666*y*x^5 - 14223*y*x^4 + x^5 + 2*x^4 + x^3, + y^9 - y^7*x^2 - y^7*x - y^6*x^3 - y^6*x^2 - 3*y^6 - 3*y^5*x - y^3*x^7 + - 3*y^3*x^6 - 3*y^3*x^5 - y^3*x^4 - 9*y^2*x^5 - 18*y^2*x^4 - 9*y^2*x^3 + - 27*y*x^3 - 27*y*x^2 - 27*x] ALGORITHM: @@ -2201,7 +2247,7 @@ def elimination_ideal(self, variables, algorithm=None, *args, **kwds): - ``variables`` -- a list or tuple of variables in ``self.ring()`` - ``algorithm`` - determines the algorithm to use, see below - for available algorithms. + for available algorithms. ALGORITHMS: @@ -2216,10 +2262,10 @@ def elimination_ideal(self, variables, algorithm=None, *args, **kwds): EXAMPLES:: sage: R. = PolynomialRing(QQ,5) - sage: I = R * [x-t,y-t^2,z-t^3,s-x+y^3] - sage: J = I.elimination_ideal([t,s]); J - Ideal (y^2 - x*z, x*y - z, x^2 - y) of Multivariate - Polynomial Ring in x, y, t, s, z over Rational Field + sage: I = R * [x - t, y - t^2, z - t^3, s - x + y^3] + sage: J = I.elimination_ideal([t, s]); J + Ideal (y^2 - x*z, x*y - z, x^2 - y) + of Multivariate Polynomial Ring in x, y, t, s, z over Rational Field You can use Giac to compute the elimination ideal:: @@ -2245,7 +2291,7 @@ def elimination_ideal(self, variables, algorithm=None, *args, **kwds): sage: R. = QQbar[] # optional - sage.rings.number_field sage: I = R * [x - t, y - t^2, z - t^3, s - x + y^3] # optional - sage.rings.number_field - sage: J = I.elimination_ideal([t,s]); J # optional - sage.rings.number_field + sage: J = I.elimination_ideal([t, s]); J # optional - sage.rings.number_field Ideal (y^2 - x*z, x*y - z, x^2 - y) of Multivariate Polynomial Ring in x, y, t, s, z over Algebraic Field sage: print("possible output from giac", flush=True); I.elimination_ideal([t, s], algorithm="giac") == J # optional - sage.rings.number_field @@ -2319,7 +2365,7 @@ def quotient(self, J): EXAMPLES:: sage: R. = PolynomialRing(GF(181), 3) # optional - sage.rings.finite_rings - sage: I = Ideal([x^2+x*y*z, y^2-z^3*y, z^3+y^5*x*z]) # optional - sage.rings.finite_rings + sage: I = Ideal([x^2 + x*y*z, y^2 - z^3*y, z^3 + y^5*x*z]) # optional - sage.rings.finite_rings sage: J = Ideal([x]) # optional - sage.rings.finite_rings sage: Q = I.quotient(J) # optional - sage.rings.finite_rings sage: y*z + x in I # optional - sage.rings.finite_rings @@ -2414,7 +2460,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True r""" Return the variety of this ideal. - Given a zero-dimensional ideal `I` (== ``self``) of a + Given a zero-dimensional ideal `I` (= ``self``) of a polynomial ring `P` whose order is lexicographic, return the variety of `I` as a list of dictionaries with ``(variable, value)`` pairs. By default, the variety of the ideal over its @@ -2454,19 +2500,19 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True sage: P. = PolynomialRing(K, 2, order='lex') # optional - sage.rings.finite_rings sage: I = Ideal([x^8 + y + 2, y^6 + x*y^5 + x^2]) # optional - sage.rings.finite_rings sage: I = Ideal(I.groebner_basis()); I # optional - sage.rings.finite_rings - Ideal (x - y^47 - y^45 + y^44 - y^43 + y^41 - y^39 - y^38 - - y^37 - y^36 + y^35 - y^34 - y^33 + y^32 - y^31 + y^30 + - y^28 + y^27 + y^26 + y^25 - y^23 + y^22 + y^21 - y^19 - - y^18 - y^16 + y^15 + y^13 + y^12 - y^10 + y^9 + y^8 + y^7 - - y^6 + y^4 + y^3 + y^2 + y - 1, y^48 + y^41 - y^40 + y^37 - - y^36 - y^33 + y^32 - y^29 + y^28 - y^25 + y^24 + y^2 + y - + 1) of Multivariate Polynomial Ring in x, y over Finite - Field in w of size 3^3 + Ideal (x - y^47 - y^45 + y^44 - y^43 + y^41 - y^39 - y^38 - y^37 - y^36 + + y^35 - y^34 - y^33 + y^32 - y^31 + y^30 + y^28 + y^27 + y^26 + + y^25 - y^23 + y^22 + y^21 - y^19 - y^18 - y^16 + y^15 + y^13 + + y^12 - y^10 + y^9 + y^8 + y^7 - y^6 + y^4 + y^3 + y^2 + y - 1, + y^48 + y^41 - y^40 + y^37 - y^36 - y^33 + y^32 - y^29 + y^28 + - y^25 + y^24 + y^2 + y + 1) + of Multivariate Polynomial Ring in x, y over Finite Field in w of size 3^3 sage: V = I.variety(); # optional - sage.rings.finite_rings sage: sorted(V, key=str) # optional - sage.rings.finite_rings [{y: w^2 + 2*w, x: 2*w + 2}, {y: w^2 + 2, x: 2*w}, {y: w^2 + w, x: 2*w + 1}] - sage: [f.subs(v) for f in I.gens() for v in V] # check that all polynomials vanish # optional - sage.rings.finite_rings + sage: [f.subs(v) # check that all polynomials vanish # optional - sage.rings.finite_rings + ....: for f in I.gens() for v in V] [0, 0, 0, 0, 0, 0] sage: [I.subs(v).is_zero() for v in V] # same test, but nicer syntax # optional - sage.rings.finite_rings [True, True, True] @@ -2481,10 +2527,10 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True circle, in several fields:: sage: K. = PolynomialRing(QQ, 2, order='lex') - sage: I = Ideal([ x*y - 1, (x-2)^2 + (y-1)^2 - 1]) + sage: I = Ideal([x*y - 1, (x-2)^2 + (y-1)^2 - 1]) sage: I = Ideal(I.groebner_basis()); I Ideal (x + y^3 - 2*y^2 + 4*y - 4, y^4 - 2*y^3 + 4*y^2 - 4*y + 1) - of Multivariate Polynomial Ring in x, y over Rational Field + of Multivariate Polynomial Ring in x, y over Rational Field These two curves have one rational intersection:: @@ -2558,7 +2604,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True or even generator names as strings, when provided as keys:: sage: K. = QQ[] - sage: I = ideal([x^2+2*y-5,x+y+3]) + sage: I = ideal([x^2 + 2*y - 5, x + y + 3]) sage: v = I.variety(AA)[0]; v[x], v[y] # optional - sage.rings.number_field (4.464101615137755?, -7.464101615137755?) sage: list(v)[0].parent() # optional - sage.rings.number_field @@ -2568,11 +2614,13 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True sage: v["y"] # optional - sage.rings.number_field -7.464101615137755? - msolve also works over finite fields:: + ``msolve`` also works over finite fields:: sage: R. = PolynomialRing(GF(536870909), 2, order='lex') # optional - sage.rings.finite_rings sage: I = Ideal([x^2 - 1, y^2 - 1]) # optional - sage.rings.finite_rings - sage: sorted(I.variety(algorithm='msolve', proof=False), key=str) # optional - msolve # optional - sage.rings.finite_rings + sage: sorted(I.variety(algorithm='msolve', # optional - msolve # optional - sage.rings.finite_rings + ....: proof=False), + ....: key=str) [{x: 1, y: 1}, {x: 1, y: 536870908}, {x: 536870908, y: 1}, @@ -2583,7 +2631,7 @@ def variety(self, ring=None, *, algorithm="triangular_decomposition", proof=True sage: R. = PolynomialRing(GF(3), 2, order='lex') # optional - sage.rings.finite_rings sage: I = Ideal([x^2 - 1, y^2 - 1]) # optional - sage.rings.finite_rings - sage: I.variety(algorithm='msolve', proof=False) # optional - msolve # optional - sage.rings.finite_rings + sage: I.variety(algorithm='msolve', proof=False) # optional - msolve # optional - sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: characteristic 3 too small @@ -2804,7 +2852,8 @@ def hilbert_polynomial(self, algorithm='sage'): Of course, the Hilbert polynomial of a zero-dimensional ideal is zero:: - sage: J0 = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5, y^3 - 2*x*z^2 + x*y, x^4 + x*y - y*z^2]) + sage: J0 = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5, + ....: y^3 - 2*x*z^2 + x*y, x^4 + x*y - y*z^2]) sage: J = P*[m.lm() for m in J0.groebner_basis()] sage: J.dimension() 0 @@ -2820,7 +2869,8 @@ def hilbert_polynomial(self, algorithm='sage'): Here is a bigger examples:: - sage: n = 4; m = 11; P = PolynomialRing(QQ, n * m, "x"); x = P.gens(); M = Matrix(n, x) + sage: n = 4; m = 11; P = PolynomialRing(QQ, n * m, "x"); x = P.gens() + sage: M = Matrix(n, x) sage: Minors = P.ideal(M.minors(2)) sage: hp = Minors.hilbert_polynomial(); hp # optional - sage.libs.flint 1/21772800*t^13 + 61/21772800*t^12 + 1661/21772800*t^11 @@ -2846,7 +2896,8 @@ def hilbert_polynomial(self, algorithm='sage'): sage: P = PowerSeriesRing(QQ, 't', default_prec=50) sage: hs = Minors.hilbert_series() # optional - sage.libs.flint - sage: list(P(hs.numerator()) / P(hs.denominator())) == [hp(t = k) for k in range(50)] + sage: list(P(hs.numerator()) / P(hs.denominator())) == [hp(t = k) + ....: for k in range(50)] True TESTS: @@ -3193,7 +3244,7 @@ def normal_basis(self, degree=None, algorithm='libsingular', EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: I = R.ideal(x^2+y^2+z^2-4, x^2+2*y^2-5, x*z-1) + sage: I = R.ideal(x^2 + y^2 + z^2 - 4, x^2 + 2*y^2 - 5, x*z - 1) sage: I.normal_basis() [y*z^2, z^2, y*z, z, x*y, y, x, 1] sage: I.normal_basis(algorithm='singular') @@ -3203,7 +3254,7 @@ def normal_basis(self, degree=None, algorithm='libsingular', particularly useful when the quotient ring is not finite-dimensional as a vector space. :: - sage: J = R.ideal(x^2+y^2+z^2-4, x^2+2*y^2-5) + sage: J = R.ideal(x^2 + y^2 + z^2 - 4, x^2 + 2*y^2 - 5) sage: J.dimension() 1 sage: [J.normal_basis(d) for d in (0..3)] @@ -3382,8 +3433,8 @@ def __init__(self, ring, gens, coerce=True, side = "left"): - ``gens`` - the generators of this ideal - ``coerce`` (optional - default True) - generators are coerced into the ring before creating the ideal - - ``side`` - optional string, either "left" (default) - or "twosided"; defines whether this ideal is left + - ``side`` - optional string, either ``"left"`` (default) + or ``"twosided"``; defines whether this ideal is left of two-sided. EXAMPLES:: @@ -3392,18 +3443,22 @@ def __init__(self, ring, gens, coerce=True, side = "left"): sage: H = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules sage: H.inject_variables() # optional - sage.combinat sage.modules Defining x, y, z - sage: I = H.ideal([y^2, x^2, z^2-H.one()],coerce=False) # indirect doctest # optional - sage.combinat sage.modules + sage: I = H.ideal([y^2, x^2, z^2 - H.one()], # indirect doctest # optional - sage.combinat sage.modules + ....: coerce=False) sage: I # random # optional - sage.combinat sage.modules - Left Ideal (y^2, x^2, z^2 - 1) of Noncommutative Multivariate Polynomial Ring in x, y, z - over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} + Left Ideal (y^2, x^2, z^2 - 1) of + Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, + nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(I.gens(), key=str) # optional - sage.combinat sage.modules [x^2, y^2, z^2 - 1] - sage: H.ideal([y^2, x^2, z^2-H.one()], side="twosided") #random # optional - sage.combinat sage.modules - Twosided Ideal (y^2, x^2, z^2 - 1) of Noncommutative Multivariate Polynomial Ring in x, y, z - over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} - sage: sorted(H.ideal([y^2, x^2, z^2-H.one()], side="twosided").gens(), key=str) # optional - sage.combinat sage.modules + sage: H.ideal([y^2, x^2, z^2 - H.one()], side="twosided") # random # optional - sage.combinat sage.modules + Twosided Ideal (y^2, x^2, z^2 - 1) of + Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, + nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} + sage: sorted(H.ideal([y^2, x^2, z^2 - H.one()], side="twosided").gens(), # optional - sage.combinat sage.modules + ....: key=str) [x^2, y^2, z^2 - 1] - sage: H.ideal([y^2, x^2, z^2-H.one()], side="right") # optional - sage.combinat sage.modules + sage: H.ideal([y^2, x^2, z^2 - H.one()], side="right") # optional - sage.combinat sage.modules Traceback (most recent call last): ... ValueError: Only left and two-sided ideals are allowed. @@ -3457,7 +3512,7 @@ def std(self): sage: H = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules sage: H.inject_variables() # optional - sage.combinat sage.modules Defining x, y, z - sage: I = H.ideal([y^2, x^2, z^2-H.one()], coerce=False) # optional - sage.combinat sage.modules + sage: I = H.ideal([y^2, x^2, z^2 - H.one()], coerce=False) # optional - sage.combinat sage.modules sage: I.std() #random # optional - sage.combinat sage.modules Left Ideal (z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, @@ -3466,9 +3521,9 @@ def std(self): [2*x*y - z - 1, x*z + x, x^2, y*z - y, y^2, z^2 - 1] - If the ideal is a left ideal, then std returns a left + If the ideal is a left ideal, then :meth:`std` returns a left Groebner basis. But if it is a two-sided ideal, then - the output of std and :meth:`twostd` coincide:: + the output of :meth:`std` and :meth:`twostd` coincide:: sage: JL = H.ideal([x^3, y^3, z^3 - 4*z]) # optional - sage.combinat sage.modules sage: JL #random # optional - sage.combinat sage.modules @@ -3477,31 +3532,33 @@ def std(self): nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(JL.gens(), key=str) # optional - sage.combinat sage.modules [x^3, y^3, z^3 - 4*z] - sage: JL.std() #random # optional - sage.combinat sage.modules - Left Ideal (z^3 - 4*z, y*z^2 - 2*y*z, x*z^2 + 2*x*z, 2*x*y*z - z^2 - 2*z, y^3, x^3) of + sage: JL.std() # random # optional - sage.combinat sage.modules + Left Ideal (z^3 - 4*z, y*z^2 - 2*y*z, + x*z^2 + 2*x*z, 2*x*y*z - z^2 - 2*z, y^3, x^3) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(JL.std().gens(), key=str) # optional - sage.combinat sage.modules [2*x*y*z - z^2 - 2*z, x*z^2 + 2*x*z, x^3, y*z^2 - 2*y*z, y^3, z^3 - 4*z] sage: JT = H.ideal([x^3, y^3, z^3 - 4*z], side='twosided') # optional - sage.combinat sage.modules sage: JT #random # optional - sage.combinat sage.modules - Twosided Ideal (x^3, y^3, z^3 - 4*z) - of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, + Twosided Ideal (x^3, y^3, z^3 - 4*z) of + Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(JT.gens(), key=str) # optional - sage.combinat sage.modules [x^3, y^3, z^3 - 4*z] sage: JT.std() #random # optional - sage.combinat sage.modules - Twosided Ideal (z^3 - 4*z, y*z^2 - 2*y*z, x*z^2 + 2*x*z, y^2*z - 2*y^2, 2*x*y*z - z^2 - 2*z, - x^2*z + 2*x^2, y^3, x*y^2 - y*z, x^2*y - x*z - 2*x, x^3) of + Twosided Ideal (z^3 - 4*z, y*z^2 - 2*y*z, x*z^2 + 2*x*z, + y^2*z - 2*y^2, 2*x*y*z - z^2 - 2*z, x^2*z + 2*x^2, + y^3, x*y^2 - y*z, x^2*y - x*z - 2*x, x^3) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} sage: sorted(JT.std().gens(), key=str) # optional - sage.combinat sage.modules - [2*x*y*z - z^2 - 2*z, x*y^2 - y*z, x*z^2 + 2*x*z, x^2*y - x*z - 2*x, x^2*z + 2*x^2, - x^3, y*z^2 - 2*y*z, y^2*z - 2*y^2, y^3, z^3 - 4*z] + [2*x*y*z - z^2 - 2*z, x*y^2 - y*z, x*z^2 + 2*x*z, x^2*y - x*z - 2*x, + x^2*z + 2*x^2, x^3, y*z^2 - 2*y*z, y^2*z - 2*y^2, y^3, z^3 - 4*z] sage: JT.std() == JL.twostd() # optional - sage.combinat sage.modules True - ALGORITHM: Uses Singular's std command + ALGORITHM: Uses Singular's ``std`` command """ if self.side() == 'twosided': return self.twostd() @@ -3511,7 +3568,7 @@ def std(self): def elimination_ideal(self, variables): r""" Return the elimination ideal of this ideal with respect to the - variables given in "variables". + variables given in ``variables``. EXAMPLES:: @@ -3519,13 +3576,12 @@ def elimination_ideal(self, variables): sage: H = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules sage: H.inject_variables() # optional - sage.combinat sage.modules Defining x, y, z - sage: I = H.ideal([y^2, x^2, z^2-H.one()], coerce=False) # optional - sage.combinat sage.modules + sage: I = H.ideal([y^2, x^2, z^2 - H.one()], coerce=False) # optional - sage.combinat sage.modules sage: I.elimination_ideal([x, z]) # optional - sage.combinat sage.modules Left Ideal (y^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {...} - sage: J = I.twostd() # optional - sage.combinat sage.modules - sage: J # optional - sage.combinat sage.modules + sage: J = I.twostd(); J # optional - sage.combinat sage.modules Twosided Ideal (z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {...} @@ -3535,7 +3591,7 @@ def elimination_ideal(self, variables): nc-relations: {...} - ALGORITHM: Uses Singular's eliminate command + ALGORITHM: Uses Singular's ``eliminate`` command """ from sage.misc.misc_c import prod if self.side() == 'twosided': @@ -3556,14 +3612,14 @@ def twostd(self): sage: H = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules sage: H.inject_variables() # optional - sage.combinat sage.modules Defining x, y, z - sage: I = H.ideal([y^2, x^2, z^2-H.one()], coerce=False) # optional - sage.combinat sage.modules + sage: I = H.ideal([y^2, x^2, z^2 - H.one()], coerce=False) # optional - sage.combinat sage.modules sage: I.twostd() #random # optional - sage.combinat sage.modules Twosided Ideal (z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2) of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field... sage: sorted(I.twostd().gens(), key=str) # optional - sage.combinat sage.modules [2*x*y - z - 1, x*z + x, x^2, y*z - y, y^2, z^2 - 1] - ALGORITHM: Uses Singular's twostd command + ALGORITHM: Uses Singular's ``twostd`` command """ return self.ring().ideal( self.__call_singular('twostd'), side='twosided') # return self.__call_singular('twostd') @@ -3582,7 +3638,7 @@ def _groebner_strategy(self): sage: A. = FreeAlgebra(QQ, 3) # optional - sage.combinat sage.modules sage: H. = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules sage: I = H.ideal([y^2, x^2, z^2-H.one()], coerce=False) # optional - sage.combinat sage.modules - sage: I._groebner_strategy() #random # optional - sage.combinat sage.modules + sage: I._groebner_strategy() # random # optional - sage.combinat sage.modules Groebner Strategy for ideal generated by 6 elements over Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} @@ -3601,15 +3657,12 @@ def reduce(self,p): It returns 0 if and only if the element is in this ideal. In any case, this reduction is unique up to monomial orders. - NOTE: - - There are left and two-sided ideals. Hence, - EXAMPLES:: sage: A. = FreeAlgebra(QQ, 3) # optional - sage.combinat sage.modules sage: H. = A.g_algebra({y*x: x*y-z, z*x: x*z+2*x, z*y: y*z-2*y}) # optional - sage.combinat sage.modules - sage: I = H.ideal([y^2, x^2, z^2-H.one()], coerce=False, side='twosided') # optional - sage.combinat sage.modules + sage: I = H.ideal([y^2, x^2, z^2 - H.one()], # optional - sage.combinat sage.modules + ....: coerce=False, side='twosided') sage: Q = H.quotient(I); Q #random # optional - sage.combinat sage.modules Quotient of Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, @@ -3708,7 +3761,7 @@ def syzygy_module(self): sage: M*G # optional - sage.combinat sage.modules (0, 0, 0, 0, 0, 0, 0, 0, 0) - ALGORITHM: Uses Singular's syz command + ALGORITHM: Uses Singular's ``syz`` command """ if self.side() == 'twosided': warn("The result of this Syzygy computation is one-sided (left)!") @@ -3760,7 +3813,7 @@ def __init__(self, ring, gens, coerce=True): - ``gens`` - a list of generators for the ideal - - ``coerce`` - coerce elements to the ring ``ring``? + - ``coerce`` - whether to coerce elements to the ring ``ring`` EXAMPLES:: @@ -3888,8 +3941,8 @@ def __richcmp__(self, other, op): :: sage: R. = QQ[] - sage: I = (x^3 + y, y)*R - sage: J = (x^3 + y, y, y*x^3 + y^2)*R + sage: I = (x^3 + y, y) * R + sage: J = (x^3 + y, y, y*x^3 + y^2) * R sage: I == J True @@ -4089,7 +4142,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal INPUT: - ``algorithm`` - determines the algorithm to use, see below - for available algorithms. + for available algorithms. - ``deg_bound`` - only compute to degree ``deg_bound``, that is, ignore all S-polynomials of higher degree. (default: @@ -4109,78 +4162,78 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal :func:`set_verbose`. - ``*args`` - additional parameters passed to the respective - implementations + implementations - ``**kwds`` - additional keyword parameters passed to the - respective implementations + respective implementations ALGORITHMS: - '' + ``''`` autoselect (default) - 'singular:groebner' + ``'singular:groebner'`` Singular's ``groebner`` command - 'singular:std' + ``'singular:std'`` Singular's ``std`` command - 'singular:stdhilb' + ``'singular:stdhilb'`` Singular's ``stdhib`` command - 'singular:stdfglm' + ``'singular:stdfglm'`` Singular's ``stdfglm`` command - 'singular:slimgb' + ``'singular:slimgb'`` Singular's ``slimgb`` command - 'libsingular:groebner' + ``'libsingular:groebner'`` libSingular's ``groebner`` command - 'libsingular:std' + ``'libsingular:std'`` libSingular's ``std`` command - 'libsingular:slimgb' + ``'libsingular:slimgb'`` libSingular's ``slimgb`` command - 'libsingular:stdhilb' + ``'libsingular:stdhilb'`` libSingular's ``stdhib`` command - 'libsingular:stdfglm' + ``'libsingular:stdfglm'`` libSingular's ``stdfglm`` command - 'toy:buchberger' + ``'toy:buchberger'`` Sage's toy/educational buchberger without Buchberger criteria - 'toy:buchberger2' + ``'toy:buchberger2'`` Sage's toy/educational buchberger with Buchberger criteria - 'toy:d_basis' + ``'toy:d_basis'`` Sage's toy/educational algorithm for computation over PIDs - 'macaulay2:gb' + ``'macaulay2:gb'`` Macaulay2's ``gb`` command (if available) - 'macaulay2:f4' + ``'macaulay2:f4'`` Macaulay2's ``GroebnerBasis`` command with the strategy "F4" (if available) - 'macaulay2:mgb' + ``'macaulay2:mgb'`` Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available) - 'msolve' + ``'msolve'`` `optional package msolve <../spkg/msolve.html>`_ (degrevlex order, prime fields) - 'magma:GroebnerBasis' + ``'magma:GroebnerBasis'`` Magma's ``Groebnerbasis`` command (if available) - 'ginv:TQ', 'ginv:TQBlockHigh', 'ginv:TQBlockLow' and 'ginv:TQDegree' + ``'ginv:TQ'``, ``'ginv:TQBlockHigh'``, ``'ginv:TQBlockLow'`` and ``'ginv:TQDegree'`` One of GINV's implementations (if available) - 'giac:gbasis' + ``'giac:gbasis'`` Giac's ``gbasis`` command (if available) - If only a system is given - e.g. 'magma' - the default algorithm is + If only a system is given - e.g. ``'magma`` - the default algorithm is chosen for that system. .. NOTE:: @@ -4188,7 +4241,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal The Singular and libSingular versions of the respective algorithms are identical, but the former calls an external Singular process while the latter calls a C function, - i.e. the calling overhead is smaller. However, the + and thus the calling overhead is smaller. However, the libSingular interface does not support pretty printing of computation protocols. @@ -4252,9 +4305,9 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal Giac's gbasis over `\QQ` can benefit from a probabilistic lifting and multi threaded operations:: - sage: A9=PolynomialRing(QQ,9,'x') - sage: I9=sage.rings.ideal.Katsura(A9) - sage: print("possible output from giac", flush=True); I9.groebner_basis("giac",proba_epsilon=1e-7) # long time (3s) + sage: A9 = PolynomialRing(QQ, 9, 'x') + sage: I9 = sage.rings.ideal.Katsura(A9) + sage: print("possible output from giac", flush=True); I9.groebner_basis("giac", proba_epsilon=1e-7) # long time (3s) possible output... Polynomial Sequence with 143 Polynomials in 9 Variables @@ -4312,10 +4365,10 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal restrictions. :: sage: R. = QQ[] - sage: I = R*[x^3+y^2,x^2*y+1] + sage: I = R*[x^3 + y^2, x^2*y + 1] sage: I.groebner_basis(algorithm='singular') [x^3 + y^2, x^2*y + 1, y^3 - x] - sage: I.groebner_basis(algorithm='singular',deg_bound=2) + sage: I.groebner_basis(algorithm='singular', deg_bound=2) [x^3 + y^2, x^2*y + 1] sage: I.groebner_basis() [x^3 + y^2, x^2*y + 1, y^3 - x] @@ -4397,7 +4450,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal Sage also supports local orderings:: - sage: P. = PolynomialRing(QQ,3,order='negdegrevlex') + sage: P. = PolynomialRing(QQ, 3, order='negdegrevlex') sage: I = P * ( x*y*z + z^5, 2*x^2 + y^3 + z^7, 3*z^5 +y ^5 ) sage: I.groebner_basis() [x^2 + 1/2*y^3, x*y*z + z^5, y^5 + 3*z^5, y^4*z - 2*x*z^5, z^6] @@ -4405,7 +4458,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal We can represent every element in the ideal as a combination of the generators using the :meth:`~sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict.lift` method:: - sage: P. = PolynomialRing(QQ,3) + sage: P. = PolynomialRing(QQ, 3) sage: I = P * ( x*y*z + z^5, 2*x^2 + y^3 + z^7, 3*z^5 +y ^5 ) sage: J = Ideal(I.groebner_basis()) sage: f = sum(P.random_element(terms=2)*f for f in I.gens()) @@ -4747,27 +4800,32 @@ def subs(self, in_dict=None, **kwds): OUTPUT: A new ideal with modified generators. If possible, in the same - polynomial ring. Raises a ``TypeError`` if no common + polynomial ring. Raises a :class:`TypeError` if no common polynomial ring of the substituted generators can be found. EXAMPLES:: - sage: R. = PolynomialRing(ZZ,2,'xy') - sage: I = R.ideal(x^5+y^5, x^2 + y + x^2*y^2 + 5); I - Ideal (x^5 + y^5, x^2*y^2 + x^2 + y + 5) of Multivariate Polynomial Ring in x, y over Integer Ring + sage: R. = PolynomialRing(ZZ, 2, 'xy') + sage: I = R.ideal(x^5 + y^5, x^2 + y + x^2*y^2 + 5); I + Ideal (x^5 + y^5, x^2*y^2 + x^2 + y + 5) + of Multivariate Polynomial Ring in x, y over Integer Ring sage: I.subs(x=y) - Ideal (2*y^5, y^4 + y^2 + y + 5) of Multivariate Polynomial Ring in x, y over Integer Ring - sage: I.subs({x:y}) # same substitution but with dictionary - Ideal (2*y^5, y^4 + y^2 + y + 5) of Multivariate Polynomial Ring in x, y over Integer Ring + Ideal (2*y^5, y^4 + y^2 + y + 5) + of Multivariate Polynomial Ring in x, y over Integer Ring + sage: I.subs({x: y}) # same substitution but with dictionary + Ideal (2*y^5, y^4 + y^2 + y + 5) + of Multivariate Polynomial Ring in x, y over Integer Ring The new ideal can be in a different ring:: - sage: R. = PolynomialRing(QQ,2) - sage: S. = PolynomialRing(QQ,2) - sage: I = R.ideal(a^2+b^2+a-b+2); I - Ideal (a^2 + b^2 + a - b + 2) of Multivariate Polynomial Ring in a, b over Rational Field + sage: R. = PolynomialRing(QQ, 2) + sage: S. = PolynomialRing(QQ, 2) + sage: I = R.ideal(a^2 + b^2 + a - b + 2); I + Ideal (a^2 + b^2 + a - b + 2) + of Multivariate Polynomial Ring in a, b over Rational Field sage: I.subs(a=x, b=y) - Ideal (x^2 + y^2 + x - y + 2) of Multivariate Polynomial Ring in x, y over Rational Field + Ideal (x^2 + y^2 + x - y + 2) + of Multivariate Polynomial Ring in x, y over Rational Field The resulting ring need not be a multivariate polynomial ring:: @@ -4781,9 +4839,10 @@ def subs(self, in_dict=None, **kwds): Variables that are not substituted remain unchanged:: - sage: R. = PolynomialRing(QQ,2) - sage: I = R.ideal(x^2+y^2+x-y+2); I - Ideal (x^2 + y^2 + x - y + 2) of Multivariate Polynomial Ring in x, y over Rational Field + sage: R. = PolynomialRing(QQ, 2) + sage: I = R.ideal(x^2 + y^2 + x - y + 2); I + Ideal (x^2 + y^2 + x - y + 2) + of Multivariate Polynomial Ring in x, y over Rational Field sage: I.subs(x=1) Ideal (y^2 - y + 4) of Multivariate Polynomial Ring in x, y over Rational Field """ @@ -4805,7 +4864,7 @@ def reduce(self, f): EXAMPLES:: sage: R. = PolynomialRing(QQ, 2) - sage: I = (x^3 + y, y)*R + sage: I = (x^3 + y, y) * R sage: I.reduce(y) 0 sage: I.reduce(x^3) @@ -4813,7 +4872,7 @@ def reduce(self, f): sage: I.reduce(x - y) x - sage: I = (y^2 - (x^3 + x))*R + sage: I = (y^2 - (x^3 + x)) * R sage: I.reduce(x^3) y^2 - x sage: I.reduce(x^6) @@ -4843,7 +4902,7 @@ def _contains_(self, f): EXAMPLES:: sage: R. = QQ[] - sage: I = (x^3 + y, y)*R + sage: I = (x^3 + y, y) * R sage: x in I # indirect doctest False sage: y in I @@ -4905,7 +4964,7 @@ def homogenize(self, var='h'): def is_homogeneous(self): r""" Return ``True`` if this ideal is spanned by homogeneous - polynomials, i.e. if it is a homogeneous ideal. + polynomials, i.e., if it is a homogeneous ideal. EXAMPLES:: @@ -5048,59 +5107,59 @@ def plot(self, *args, **kwds): - ``self`` - a principal ideal in 2 variables - ``algorithm`` - set this to 'surf' if you want 'surf' to - plot the ideal (default: None) + plot the ideal (default: None) - ``*args`` - optional tuples ``(variable, minimum, maximum)`` - for plotting dimensions + for plotting dimensions - ``**kwds`` - optional keyword arguments passed on to - ``implicit_plot`` + ``implicit_plot`` EXAMPLES: Implicit plotting in 2-d:: - sage: R. = PolynomialRing(QQ,2) + sage: R. = PolynomialRing(QQ, 2) sage: I = R.ideal([y^3 - x^2]) - sage: I.plot() # cusp + sage: I.plot() # cusp # optional - sage.plot Graphics object consisting of 1 graphics primitive :: sage: I = R.ideal([y^2 - x^2 - 1]) - sage: I.plot((x,-3, 3), (y, -2, 2)) # hyperbola + sage: I.plot((x,-3, 3), (y, -2, 2)) # hyperbola # optional - sage.plot Graphics object consisting of 1 graphics primitive :: sage: I = R.ideal([y^2 + x^2*(1/4) - 1]) - sage: I.plot() # ellipse + sage: I.plot() # ellipse # optional - sage.plot Graphics object consisting of 1 graphics primitive :: sage: I = R.ideal([y^2-(x^2-1)*(x-2)]) - sage: I.plot() # elliptic curve + sage: I.plot() # elliptic curve # optional - sage.plot Graphics object consisting of 1 graphics primitive :: sage: f = ((x+3)^3 + 2*(x+3)^2 - y^2)*(x^3 - y^2)*((x-3)^3-2*(x-3)^2-y^2) sage: I = R.ideal(f) - sage: I.plot() # the Singular logo + sage: I.plot() # the Singular logo # optional - sage.plot Graphics object consisting of 1 graphics primitive :: - sage: R. = PolynomialRing(QQ,2) + sage: R. = PolynomialRing(QQ, 2) sage: I = R.ideal([x - 1]) - sage: I.plot((y, -2, 2)) # vertical line + sage: I.plot((y, -2, 2)) # vertical line # optional - sage.plot Graphics object consisting of 1 graphics primitive :: sage: I = R.ideal([-x^2*y + 1]) - sage: I.plot() # blow up + sage: I.plot() # blow up # optional - sage.plot Graphics object consisting of 1 graphics primitive """ @@ -5197,21 +5256,22 @@ def random_element(self, degree, compute_gb=False, *args, **kwds): 1. We sample `n^d` uniformly random elements in the ideal:: - sage: F = Sequence(I.random_element(degree=d, compute_gb=True, terms=infinity) # optional - sage.rings.finite_rings - ....: for _ in range(n^d)) + sage: F = Sequence(I.random_element(degree=d, compute_gb=True, # optional - sage.rings.finite_rings + ....: terms=infinity) + ....: for _ in range(n^d)) 2. We linearize and compute the echelon form:: - sage: A, v = F.coefficient_matrix() # optional - sage.rings.finite_rings - sage: A.echelonize() # optional - sage.rings.finite_rings + sage: A, v = F.coefficient_matrix() # optional - sage.rings.finite_rings + sage: A.echelonize() # optional - sage.rings.finite_rings 3. The result is the desired Gröbner basis:: - sage: G = Sequence((A * v).list()) # optional - sage.rings.finite_rings - sage: G.is_groebner() # optional - sage.rings.finite_rings - True - sage: Ideal(G) == I # optional - sage.rings.finite_rings - True + sage: G = Sequence((A * v).list()) # optional - sage.rings.finite_rings + sage: G.is_groebner() # optional - sage.rings.finite_rings + True + sage: Ideal(G) == I # optional - sage.rings.finite_rings + True We return some element in the ideal with no guarantee on the distribution:: @@ -5226,8 +5286,9 @@ def random_element(self, degree, compute_gb=False, *args, **kwds): We show that the default method does not sample uniformly at random from the ideal:: sage: P. = GF(127)[] # optional - sage.rings.finite_rings - sage: G = Sequence([x+7, y-2, z+110]) # optional - sage.rings.finite_rings - sage: I = Ideal([sum(P.random_element() * g for g in G) for _ in range(4)]) # optional - sage.rings.finite_rings + sage: G = Sequence([x + 7, y - 2, z + 110]) # optional - sage.rings.finite_rings + sage: I = Ideal([sum(P.random_element() * g for g in G) # optional - sage.rings.finite_rings + ....: for _ in range(4)]) sage: all(I.random_element(degree=1) == 0 for _ in range(100)) # optional - sage.rings.finite_rings True @@ -5301,15 +5362,15 @@ def weil_restriction(self): sage: J = I.weil_restriction() # optional - sage.rings.finite_rings sage: J # optional - sage.rings.finite_rings Ideal (x0*y0 + x1*y1 + 1, x1*y0 + x0*y1 + x1*y1, x1 + 1, x0 + x1) of - Multivariate Polynomial Ring in x0, x1, y0, y1 over Finite Field of size 2 + Multivariate Polynomial Ring in x0, x1, y0, y1 over Finite Field of size 2 sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal # optional - sage.rings.finite_rings sage: J.variety() # optional - sage.rings.finite_rings [{y1: 1, y0: 0, x1: 1, x0: 1}] sage: J.weil_restriction() # returns J # optional - sage.rings.finite_rings - Ideal (x0*y0 + x1*y1 + 1, x1*y0 + x0*y1 + x1*y1, x1 + 1, x0 + x1, x0^2 + - x0, x1^2 + x1, y0^2 + y0, y1^2 + y1) of Multivariate Polynomial Ring in - x0, x1, y0, y1 over Finite Field of size 2 + Ideal (x0*y0 + x1*y1 + 1, x1*y0 + x0*y1 + x1*y1, x1 + 1, x0 + x1, + x0^2 + x0, x1^2 + x1, y0^2 + y0, y1^2 + y1) of Multivariate + Polynomial Ring in x0, x1, y0, y1 over Finite Field of size 2 sage: k. = GF(3^5) # optional - sage.rings.finite_rings sage: P. = PolynomialRing(k) # optional - sage.rings.finite_rings @@ -5320,26 +5381,31 @@ def weil_restriction(self): [{z: 0, y: 0, x: 1}] sage: J = I.weil_restriction(); J # optional - sage.rings.finite_rings - Ideal (x0 - y0 - z0 - 1, x1 - y1 - z1, x2 - y2 - z2, x3 - y3 - z3, x4 - - y4 - z4, x0^2 + x2*x3 + x1*x4 - y0^2 - y2*y3 - y1*y4 - z0^2 - z2*z3 - - z1*z4 - x0, -x0*x1 - x2*x3 - x3^2 - x1*x4 + x2*x4 + y0*y1 + y2*y3 + y3^2 - + y1*y4 - y2*y4 + z0*z1 + z2*z3 + z3^2 + z1*z4 - z2*z4 - x1, x1^2 - - x0*x2 + x3^2 - x2*x4 + x3*x4 - y1^2 + y0*y2 - y3^2 + y2*y4 - y3*y4 - - z1^2 + z0*z2 - z3^2 + z2*z4 - z3*z4 - x2, -x1*x2 - x0*x3 - x3*x4 - x4^2 - + y1*y2 + y0*y3 + y3*y4 + y4^2 + z1*z2 + z0*z3 + z3*z4 + z4^2 - x3, x2^2 - - x1*x3 - x0*x4 + x4^2 - y2^2 + y1*y3 + y0*y4 - y4^2 - z2^2 + z1*z3 + - z0*z4 - z4^2 - x4, -x0*y0 + x4*y1 + x3*y2 + x2*y3 + x1*y4 - y0*z0 + - y4*z1 + y3*z2 + y2*z3 + y1*z4 - y0, -x1*y0 - x0*y1 - x4*y1 - x3*y2 + - x4*y2 - x2*y3 + x3*y3 - x1*y4 + x2*y4 - y1*z0 - y0*z1 - y4*z1 - y3*z2 + - y4*z2 - y2*z3 + y3*z3 - y1*z4 + y2*z4 - y1, -x2*y0 - x1*y1 - x0*y2 - - x4*y2 - x3*y3 + x4*y3 - x2*y4 + x3*y4 - y2*z0 - y1*z1 - y0*z2 - y4*z2 - - y3*z3 + y4*z3 - y2*z4 + y3*z4 - y2, -x3*y0 - x2*y1 - x1*y2 - x0*y3 - - x4*y3 - x3*y4 + x4*y4 - y3*z0 - y2*z1 - y1*z2 - y0*z3 - y4*z3 - y3*z4 + - y4*z4 - y3, -x4*y0 - x3*y1 - x2*y2 - x1*y3 - x0*y4 - x4*y4 - y4*z0 - - y3*z1 - y2*z2 - y1*z3 - y0*z4 - y4*z4 - y4) of Multivariate Polynomial - Ring in x0, x1, x2, x3, x4, y0, y1, y2, y3, y4, z0, z1, z2, z3, z4 over - Finite Field of size 3 - sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal # optional - sage.rings.finite_rings + Ideal (x0 - y0 - z0 - 1, + x1 - y1 - z1, x2 - y2 - z2, x3 - y3 - z3, x4 - y4 - z4, + x0^2 + x2*x3 + x1*x4 - y0^2 - y2*y3 - y1*y4 - z0^2 - z2*z3 - z1*z4 - x0, + -x0*x1 - x2*x3 - x3^2 - x1*x4 + x2*x4 + y0*y1 + y2*y3 + + y3^2 + y1*y4 - y2*y4 + z0*z1 + z2*z3 + z3^2 + z1*z4 - z2*z4 - x1, + x1^2 - x0*x2 + x3^2 - x2*x4 + x3*x4 - y1^2 + y0*y2 + - y3^2 + y2*y4 - y3*y4 - z1^2 + z0*z2 - z3^2 + z2*z4 - z3*z4 - x2, + -x1*x2 - x0*x3 - x3*x4 - x4^2 + + y1*y2 + y0*y3 + y3*y4 + y4^2 + z1*z2 + z0*z3 + z3*z4 + z4^2 - x3, + x2^2 - x1*x3 - x0*x4 + x4^2 - y2^2 + + y1*y3 + y0*y4 - y4^2 - z2^2 + z1*z3 + z0*z4 - z4^2 - x4, + -x0*y0 + x4*y1 + x3*y2 + x2*y3 + + x1*y4 - y0*z0 + y4*z1 + y3*z2 + y2*z3 + y1*z4 - y0, + -x1*y0 - x0*y1 - x4*y1 - x3*y2 + x4*y2 - x2*y3 + x3*y3 + - x1*y4 + x2*y4 - y1*z0 - y0*z1 - y4*z1 - y3*z2 + + y4*z2 - y2*z3 + y3*z3 - y1*z4 + y2*z4 - y1, + -x2*y0 - x1*y1 - x0*y2 - x4*y2 - x3*y3 + x4*y3 - x2*y4 + x3*y4 + - y2*z0 - y1*z1 - y0*z2 - y4*z2 - y3*z3 + y4*z3 - y2*z4 + y3*z4 - y2, + -x3*y0 - x2*y1 - x1*y2 - x0*y3 - x4*y3 - x3*y4 + x4*y4 + - y3*z0 - y2*z1 - y1*z2 - y0*z3 - y4*z3 - y3*z4 + y4*z4 - y3, + -x4*y0 - x3*y1 - x2*y2 - x1*y3 - x0*y4 - x4*y4 + - y4*z0 - y3*z1 - y2*z2 - y1*z3 - y0*z4 - y4*z4 - y4) + of Multivariate Polynomial Ring in x0, x1, x2, x3, x4, y0, y1, y2, y3, y4, + z0, z1, z2, z3, z4 over Finite Field of size 3 + sage: J += sage.rings.ideal.FieldIdeal(J.ring()) # ensure radical ideal # optional - sage.rings.finite_rings sage: from sage.doctest.fixtures import reproducible_repr sage: print(reproducible_repr(J.variety())) # optional - sage.rings.finite_rings [{x0: 1, x1: 0, x2: 0, x3: 0, x4: 0, @@ -5380,15 +5446,15 @@ def weil_restriction(self): sage: J = I.weil_restriction() # optional - sage.rings.number_field sage: J # optional - sage.rings.number_field - Ideal (-x0^3 - x0*x1^2 - 2*x0^2*z0 - 2/3*x1^2*z0 + x0*y0*z0 + y0^2*z0 + - 1/3*x1*y1*z0 + 1/3*y1^2*z0 - 4*x0*z0^2 + 3*y0*z0^2 - 5*z0^3 - - 4/3*x0*x1*z1 + 1/3*x1*y0*z1 + 1/3*x0*y1*z1 + 2/3*y0*y1*z1 - 8/3*x1*z0*z1 - + 2*y1*z0*z1 - 4/3*x0*z1^2 + y0*z1^2 - 5*z0*z1^2, -3*x0^2*x1 - 1/3*x1^3 - - 4*x0*x1*z0 + x1*y0*z0 + x0*y1*z0 + 2*y0*y1*z0 - 4*x1*z0^2 + 3*y1*z0^2 - - 2*x0^2*z1 - 2/3*x1^2*z1 + x0*y0*z1 + y0^2*z1 + 1/3*x1*y1*z1 + - 1/3*y1^2*z1 - 8*x0*z0*z1 + 6*y0*z0*z1 - 15*z0^2*z1 - 4/3*x1*z1^2 + - y1*z1^2 - 5/3*z1^3) of Multivariate Polynomial Ring in x0, x1, y0, y1, - z0, z1 over Rational Field + Ideal (-x0^3 - x0*x1^2 - 2*x0^2*z0 - 2/3*x1^2*z0 + x0*y0*z0 + y0^2*z0 + + 1/3*x1*y1*z0 + 1/3*y1^2*z0 - 4*x0*z0^2 + 3*y0*z0^2 - 5*z0^3 + - 4/3*x0*x1*z1 + 1/3*x1*y0*z1 + 1/3*x0*y1*z1 + 2/3*y0*y1*z1 + - 8/3*x1*z0*z1 + 2*y1*z0*z1 - 4/3*x0*z1^2 + y0*z1^2 - 5*z0*z1^2, + -3*x0^2*x1 - 1/3*x1^3 - 4*x0*x1*z0 + x1*y0*z0 + x0*y1*z0 + + 2*y0*y1*z0 - 4*x1*z0^2 + 3*y1*z0^2 - 2*x0^2*z1 - 2/3*x1^2*z1 + + x0*y0*z1 + y0^2*z1 + 1/3*x1*y1*z1 + 1/3*y1^2*z1 - 8*x0*z0*z1 + + 6*y0*z0*z1 - 15*z0^2*z1 - 4/3*x1*z1^2 + y1*z1^2 - 5/3*z1^3) + of Multivariate Polynomial Ring in x0, x1, y0, y1, z0, z1 over Rational Field We can check that the point ``p`` is still a root of all generators of ``J``:: @@ -5405,9 +5471,9 @@ def weil_restriction(self): sage: S. = L[] # optional - sage.rings.number_field sage: I = S.ideal([y^2 - x^3 - 1]) # optional - sage.rings.number_field sage: I.weil_restriction() # optional - sage.rings.number_field - Ideal (-x0^3 + 3*x0*x1^2 + y0^2 - y1^2 - 1, -3*x0^2*x1 + x1^3 + 2*y0*y1) - of Multivariate Polynomial Ring in x0, x1, y0, y1 over Number Field in w - with defining polynomial x^5 - 2 + Ideal (-x0^3 + 3*x0*x1^2 + y0^2 - y1^2 - 1, -3*x0^2*x1 + x1^3 + 2*y0*y1) of + Multivariate Polynomial Ring in x0, x1, y0, y1 + over Number Field in w with defining polynomial x^5 - 2 .. NOTE:: @@ -5480,8 +5546,9 @@ class MPolynomialIdeal_quotient(MPolynomialIdeal): sage: Q. = QQ['x,y,z,w'].quotient(['x*y-z^2', 'y^2-w^2']) sage: I = ideal(x + y^2 + z - 1) sage: I - Ideal (w^2 + x + z - 1) of Quotient of Multivariate Polynomial Ring - in x, y, z, w over Rational Field by the ideal (x*y - z^2, y^2 - w^2) + Ideal (w^2 + x + z - 1) of Quotient + of Multivariate Polynomial Ring in x, y, z, w over Rational Field + by the ideal (x*y - z^2, y^2 - w^2) """ def reduce(self, f): r""" @@ -5492,9 +5559,9 @@ def reduce(self, f): EXAMPLES:: sage: R. = PolynomialRing(QQ, order='lex') - sage: I = R.ideal([T^2+U^2-1, V^2+W^2-1, X^2+Y^2+Z^2-1]) + sage: I = R.ideal([T^2 + U^2 - 1, V^2 + W^2 - 1, X^2 + Y^2 + Z^2 - 1]) sage: Q. = R.quotient(I) - sage: J = Q.ideal([u*v-x, u*w-y, t-z]) + sage: J = Q.ideal([u*v - x, u*w - y, t - z]) sage: J.reduce(t^2 - z^2) 0 sage: J.reduce(u^2) diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx index c4273a54811..ce12783d73b 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx @@ -133,14 +133,13 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): sage: QQ['a','b']['x','y'].flattening_morphism() Flattening morphism: - From: Multivariate Polynomial Ring in x, y over Multivariate - Polynomial Ring in a, b over Rational Field - To: Multivariate Polynomial Ring in a, b, x, y over Rational - Field + From: Multivariate Polynomial Ring in x, y + over Multivariate Polynomial Ring in a, b over Rational Field + To: Multivariate Polynomial Ring in a, b, x, y over Rational Field sage: QQ['x,y'].flattening_morphism() - Identity endomorphism of Multivariate Polynomial Ring in x, y - over Rational Field + Identity endomorphism of + Multivariate Polynomial Ring in x, y over Rational Field """ base = self.base_ring() if is_MPolynomialRing(base) or polynomial_ring.is_PolynomialRing(base): @@ -151,7 +150,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): def construction(self): """ - Returns a functor F and base ring R such that F(R) == self. + Returns a functor ``F`` and base ring ``R`` such that ``F(R) == self``. EXAMPLES:: @@ -284,7 +283,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): def remove_var(self, *var, order=None): """ - Remove a variable or sequence of variables from self. + Remove a variable or sequence of variables from ``self``. If ``order`` is not specified, then the subring inherits the term order of the original ring, if possible. @@ -294,14 +293,14 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): sage: P. = PolynomialRing(ZZ) sage: P.remove_var(z) Multivariate Polynomial Ring in x, y, w over Integer Ring - sage: P.remove_var(z,x) + sage: P.remove_var(z, x) Multivariate Polynomial Ring in y, w over Integer Ring - sage: P.remove_var(y,z,x) + sage: P.remove_var(y, z, x) Univariate Polynomial Ring in w over Integer Ring Removing all variables results in the base ring:: - sage: P.remove_var(y,z,x,w) + sage: P.remove_var(y, z, x, w) Integer Ring If possible, the term order is kept:: @@ -317,7 +316,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): Be careful with block orders when removing variables:: sage: R. = PolynomialRing(ZZ, order='deglex(2),lex(3)') - sage: R.remove_var(x,y,z) + sage: R.remove_var(x, y, z) Traceback (most recent call last): ... ValueError: impossible to use the original term order (most @@ -345,18 +344,18 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): def univariate_ring(self, x): """ Return a univariate polynomial ring whose base ring comprises all - but one variables of self. + but one variables of ``self``. INPUT: - - ``x`` -- a variable of self. + - ``x`` -- a variable of ``self``. EXAMPLES:: sage: P. = QQ[] sage: P.univariate_ring(y) - Univariate Polynomial Ring in y over Multivariate Polynomial - Ring in x, z over Rational Field + Univariate Polynomial Ring in y + over Multivariate Polynomial Ring in x, z over Rational Field """ return self.remove_var(x)[str(x)] @@ -368,9 +367,9 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): This function can be called in two ways: - 1. interpolation(bound, points, values) + 1. ``interpolation(bound, points, values)`` - 2. interpolation(bound, function) + 2. ``interpolation(bound, function)`` INPUT: @@ -402,7 +401,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): sage: R.interpolation(4, F) # optional - sage.modules x^3*y + z^2 + y + 25 - sage: def F(a,b,c): ....: return a^3*b + b + c^2 + 25 ....: @@ -410,7 +408,6 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): sage: R.interpolation([3,1,2], F) # optional - sage.modules x^3*y + z^2 + y + 25 - sage: def F(a,b,c): ....: return a^3*b + b + c^2 + 25 ....: @@ -438,7 +435,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): without any notice that there are more. Lastly, the interpolation function for univariate polynomial rings - is called ``lagrange_polynomial()``. + is called :meth:`lagrange_polynomial`. .. WARNING:: @@ -447,14 +444,14 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): the given bounds. In particular it will *not* notice or check whether the result yields the correct evaluation for other points as well. So if you give wrong bounds, you will get a wrong answer - without any warning. + without any warning. :: - sage: def F(a,b,c): - ....: return a^3*b + b + c^2 + 25 - ....: - sage: R. = PolynomialRing(QQ) - sage: R.interpolation(3, F) # optional - sage.modules - 1/2*x^3 + x*y + z^2 - 1/2*x + y + 25 + sage: def F(a,b,c): + ....: return a^3*b + b + c^2 + 25 + ....: + sage: R. = PolynomialRing(QQ) + sage: R.interpolation(3, F) # optional - sage.modules + 1/2*x^3 + x*y + z^2 - 1/2*x + y + 25 .. SEEALSO:: @@ -679,7 +676,8 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): EXAMPLES:: - sage: P. = PolynomialRing(QQ,order=TermOrder('degrevlex',1)+TermOrder('lex',2)) + sage: P. = PolynomialRing(QQ, order=TermOrder('degrevlex',1) + ....: + TermOrder('lex',2)) sage: print(P.repr_long()) Polynomial Ring Base Ring : Rational Field @@ -1335,9 +1333,9 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): def change_ring(self, base_ring=None, names=None, order=None): """ - Return a new multivariate polynomial ring which isomorphic to - self, but has a different ordering given by the parameter - 'order' or names given by the parameter 'names'. + Return a new multivariate polynomial ring which is isomorphic to + ``self``, but has a different ordering given by the parameter + ``order`` or names given by the parameter ``names``. INPUT: @@ -1406,7 +1404,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): The number of such monomials equals `\binom{n+k-1}{k}` where `n` is the number of variables and `k` the degree:: - sage: len(mons) == binomial(3+2-1,2) + sage: len(mons) == binomial(3 + 2 - 1, 2) True """ deg_of_gens = [x.degree() for x in self.gens()] @@ -1527,7 +1525,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): def macaulay_resultant(self, *args, **kwds): r""" - This is an implementation of the Macaulay Resultant. It computes + This is an implementation of the Macaulay resultant. It computes the resultant of universal polynomials as well as polynomials with constant coefficients. This is a project done in sage days 55. It's based on the implementation in Maple by @@ -1550,17 +1548,17 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): INPUT: - ``args`` -- a list of `n` homogeneous polynomials in `n` variables. - works when ``args[0]`` is the list of polynomials, - or ``args`` is itself the list of polynomials + works when ``args[0]`` is the list of polynomials, + or ``args`` is itself the list of polynomials kwds: - ``sparse`` -- boolean (optional - default: ``False``) - if ``True`` function creates sparse matrices. + if ``True``, the function creates sparse matrices. OUTPUT: - - the macaulay resultant, an element of the base ring of ``self`` + - the Macaulay resultant, an element of the base ring of ``self`` .. TODO:: Working with sparse matrices should usually give faster results, @@ -1572,20 +1570,18 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): The number of polynomials has to match the number of variables:: sage: R. = PolynomialRing(QQ, 3) - sage: R.macaulay_resultant([y, x+z]) # optional - sage.modules + sage: R.macaulay_resultant([y, x + z]) # optional - sage.modules Traceback (most recent call last): ... - TypeError: number of polynomials(= 2) must equal number of - variables (= 3) + TypeError: number of polynomials(= 2) must equal number of variables (= 3) The polynomials need to be all homogeneous:: - sage: R. = PolynomialRing(QQ,3) - sage: R.macaulay_resultant([y, x+z, z+x^3]) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 3) + sage: R.macaulay_resultant([y, x + z, z + x^3]) # optional - sage.modules Traceback (most recent call last): ... - TypeError: resultant for non-homogeneous polynomials is - not supported + TypeError: resultant for non-homogeneous polynomials is not supported All polynomials must be in the same ring:: @@ -1599,7 +1595,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): The following example recreates Proposition 2.10 in Ch.3 in [CLO2005]:: sage: K. = PolynomialRing(ZZ, 2) - sage: flist,R = K._macaulay_resultant_universal_polynomials([1,1,2]) + sage: flist, R = K._macaulay_resultant_universal_polynomials([1,1,2]) sage: R.macaulay_resultant(flist) # optional - sage.modules u2^2*u4^2*u6 - 2*u1*u2*u4*u5*u6 + u1^2*u5^2*u6 - u2^2*u3*u4*u7 + u1*u2*u3*u5*u7 + u0*u2*u4*u5*u7 - u0*u1*u5^2*u7 + u1*u2*u3*u4*u8 - @@ -1609,7 +1605,7 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): u1^2*u3^2*u11 - 2*u0*u1*u3*u4*u11 + u0^2*u4^2*u11 The following example degenerates into the determinant of - a `3*3` matrix:: + a `3\times 3` matrix:: sage: K. = PolynomialRing(ZZ, 2) sage: flist,R = K._macaulay_resultant_universal_polynomials([1,1,1]) @@ -1629,52 +1625,52 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing): A simple example with constant rational coefficients:: - sage: R. = PolynomialRing(QQ,4) - sage: R.macaulay_resultant([w,z,y,x]) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 4) + sage: R.macaulay_resultant([w, z, y, x]) # optional - sage.modules 1 An example where the resultant vanishes:: - sage: R. = PolynomialRing(QQ,3) - sage: R.macaulay_resultant([x+y,y^2,x]) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 3) + sage: R.macaulay_resultant([x + y, y^2, x]) # optional - sage.modules 0 An example of bad reduction at a prime `p = 5`:: - sage: R. = PolynomialRing(QQ,3) - sage: R.macaulay_resultant([y,x^3+25*y^2*x,5*z]) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 3) + sage: R.macaulay_resultant([y, x^3 + 25*y^2*x, 5*z]) # optional - sage.modules 125 The input can given as an unpacked list of polynomials:: - sage: R. = PolynomialRing(QQ,3) - sage: R.macaulay_resultant(y,x^3+25*y^2*x,5*z) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 3) + sage: R.macaulay_resultant(y, x^3 + 25*y^2*x, 5*z) # optional - sage.modules 125 An example when the coefficients live in a finite field:: sage: F = FiniteField(11) # optional - sage.rings.finite_rings sage: R. = PolynomialRing(F, 4) # optional - sage.rings.finite_rings - sage: R.macaulay_resultant([z,x^3,5*y,w]) # optional - sage.modules sage.rings.finite_rings + sage: R.macaulay_resultant([z, x^3, 5*y, w]) # optional - sage.modules sage.rings.finite_rings 4 Example when the denominator in the algorithm vanishes(in this case the resultant is the constant term of the quotient of char polynomials of numerator/denominator):: - sage: R. = PolynomialRing(QQ,3) - sage: R.macaulay_resultant([y, x+z, z^2]) # optional - sage.modules + sage: R. = PolynomialRing(QQ, 3) + sage: R.macaulay_resultant([y, x + z, z^2]) # optional - sage.modules -1 - When there are only 2 polynomials, macaulay resultant degenerates + When there are only 2 polynomials, the Macaulay resultant degenerates to the traditional resultant:: - sage: R. = PolynomialRing(QQ,1) + sage: R. = PolynomialRing(QQ, 1) sage: f = x^2 + 1; g = x^5 + 1 sage: fh = f.homogenize() sage: gh = g.homogenize() sage: RH = fh.parent() - sage: f.resultant(g) == RH.macaulay_resultant([fh,gh]) # optional - sage.modules + sage: f.resultant(g) == RH.macaulay_resultant([fh, gh]) # optional - sage.modules True """ diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index d5ee0395a35..846ea87ac1b 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -768,13 +768,13 @@ def coefficient_matrix(self, sparse=True): def subs(self, *args, **kwargs): """ Substitute variables for every polynomial in this system and - return a new system. See ``MPolynomial.subs`` for calling + return a new system. See :meth:`MPolynomial.subs` for calling convention. INPUT: - - ``args`` - arguments to be passed to ``MPolynomial.subs`` - - ``kwargs`` - keyword arguments to be passed to ``MPolynomial.subs`` + - ``args`` - arguments to be passed to :meth:`MPolynomial.subs` + - ``kwargs`` - keyword arguments to be passed to :meth:`MPolynomial.subs` EXAMPLES:: @@ -1027,12 +1027,12 @@ def reduced(self): - `(f_1,...,f_n) = (g_1,...,g_s)` - - `LT(g_i) != LT(g_j)` for all `i != j` + - `LT(g_i) \neq LT(g_j)` for all `i \neq j` - `LT(g_i)` does not divide `m` for all monomials `m` of - `\{g_1,...,g_{i-1},g_{i+1},...,g_s\}` + `\{g_1,...,g_{i-1},g_{i+1},...,g_s\}` - - `LC(g_i) == 1` for all `i` if the coefficient ring is a field. + - `LC(g_i) = 1` for all `i` if the coefficient ring is a field. EXAMPLES:: @@ -1167,29 +1167,29 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc with linear leading terms which were used for reduction is also returned (default: ``False``). - - ```use_polybori`` - if ``True`` then ``polybori.ll.eliminate`` is - called. While this is typically faster what is implemented here, it + - ``use_polybori`` - if ``True`` then ``polybori.ll.eliminate`` is + called. While this is typically faster than what is implemented here, it is less flexible (``skip`` is not supported) and may increase the degree (default: ``False``) OUTPUT: - When ``return_reductors==True``, then a pair of sequences of + With ``return_reductors=True``, a pair of sequences of boolean polynomials are returned, along with the promises that: - 1. The union of the two sequences spans the - same boolean ideal as the argument of the method + 1. The union of the two sequences spans the + same boolean ideal as the argument of the method - 2. The second sequence only contains linear polynomials, and - it forms a reduced groebner basis (they all have pairwise - distinct leading variables, and the leading variable of a - polynomial does not occur anywhere in other polynomials). + 2. The second sequence only contains linear polynomials, and + it forms a reduced groebner basis (they all have pairwise + distinct leading variables, and the leading variable of a + polynomial does not occur anywhere in other polynomials). - 3. The leading variables of the second sequence do not occur - anywhere in the first sequence (these variables have been - eliminated). + 3. The leading variables of the second sequence do not occur + anywhere in the first sequence (these variables have been + eliminated). - When ``return_reductors==False``, only the first sequence is + With ``return_reductors=False``, only the first sequence is returned. EXAMPLES:: @@ -1203,7 +1203,7 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc sage: F.eliminate_linear_variables(skip=lambda lm,tail: str(lm)=='a') # optional - sage.rings.polynomial.pbori [a + c + d, a*c + a*d + a + c, c*d + c] - The list of reductors can be requested by setting 'return_reductors' to ``True``:: + The list of reductors can be requested by setting ``return_reductors`` to ``True``:: sage: B. = BooleanPolynomialRing() # optional - sage.rings.polynomial.pbori sage: F = Sequence([a + b + d, a + b + c]) # optional - sage.rings.polynomial.pbori @@ -1214,7 +1214,7 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc [a + b + d, c + d] - If the input system is detected to be inconsistent then [1] is returned + If the input system is detected to be inconsistent then ``[1]`` is returned, and the list of reductors is empty:: sage: R. = BooleanPolynomialRing() # optional - sage.rings.polynomial.pbori @@ -1524,11 +1524,11 @@ def solve(self, algorithm='polybori', n=1, eliminate_linear_variables=True, ver return solutions def reduced(self): - """ - If this sequence is `(f_1, ..., f_n)` this method returns `(g_1, ..., g_s)` such that: + r""" + If this sequence is `f_1, ..., f_n`, return `g_1, ..., g_s` such that: - - ` = ` - - `LT(g_i) != LT(g_j)` for all `i != j`` + - `(f_1,...,f_n) = (g_1,...,g_s)` + - `LT(g_i) \neq LT(g_j)` for all `i \neq j` - `LT(g_i)` does not divide `m` for all monomials `m` of `{g_1,...,g_{i-1},g_{i+1},...,g_s}` @@ -1589,7 +1589,7 @@ def weil_restriction(self): sage: F2 = F.weil_restriction() # optional - sage.rings.finite_rings sage: F2 # optional - sage.rings.finite_rings [x0*y0 + x1*y1 + 1, x1*y0 + x0*y1 + x1*y1, x1 + 1, x0 + x1, x0^2 + x0, - x1^2 + x1, y0^2 + y0, y1^2 + y1] + x1^2 + x1, y0^2 + y0, y1^2 + y1] Another bigger example for a small scale AES:: diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 515338982e2..136b380d2ab 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -152,7 +152,8 @@ cpdef is_Polynomial(f): sage: from sage.rings.polynomial.polynomial_element import is_Polynomial sage: R. = ZZ[] sage: is_Polynomial(x^3 + x + 1) - doctest:...: DeprecationWarning: the function is_Polynomial is deprecated; use isinstance(x, sage.structure.element.Polynomial) instead + doctest:...: DeprecationWarning: the function is_Polynomial is deprecated; + use isinstance(x, sage.structure.element.Polynomial) instead See https://github.com/sagemath/sage/issues/32709 for details. True sage: S. = R[] @@ -313,7 +314,7 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: sage: R. = QQ[] - sage: (x-3).is_one() + sage: (x - 3).is_one() False sage: R(1).is_one() True @@ -412,9 +413,9 @@ cdef class Polynomial(CommutativePolynomial): def subs(self, *x, **kwds): r""" - Identical to self(\*x). + Identical to ``self(*x)``. - See the docstring for ``self.__call__``. + See the docstring for :meth:`__call__`. EXAMPLES:: @@ -1526,10 +1527,11 @@ cdef class Polynomial(CommutativePolynomial): def inverse_mod(a, m): """ - Inverts the polynomial a with respect to m, or raises a ValueError - if no such inverse exists. The parameter m may be either a single - polynomial or an ideal (for consistency with inverse_mod in other - rings). + Invert the polynomial ``a`` with respect to ``m``, or raise a :class:`ValueError` + if no such inverse exists. + + The parameter ``m`` may be either a single polynomial or an ideal + (for consistency with :meth:`inverse_mod` in other rings). .. SEEALSO:: @@ -1576,11 +1578,11 @@ cdef class Polynomial(CommutativePolynomial): ....: for c in poly.coefficients(sparse=False)]) 1.0000000000000004 - ALGORITHM: Solve the system as + mt = 1, returning s as the inverse - of a mod m. + ALGORITHM: Solve the system `as + mt = 1`, returning `s` as the inverse + of `a` mod `m`. Uses the Euclidean algorithm for exact rings, and solves a linear - system for the coefficients of s and t for inexact rings (as the + system for the coefficients of `s` and `t` for inexact rings (as the Euclidean algorithm may not converge in that case). AUTHORS: @@ -2871,7 +2873,7 @@ cdef class Polynomial(CommutativePolynomial): cpdef _floordiv_(self, right): r""" - Quotient of division of self by other. This is denoted //. + Quotient of division of ``self`` by ``other``. This is denoted //. If self = quotient \* right + remainder, this function returns quotient. @@ -2894,7 +2896,7 @@ cdef class Polynomial(CommutativePolynomial): def __mod__(self, other): """ - Remainder of division of self by other. + Remainder of division of ``self`` by ``other``. EXAMPLES:: @@ -2909,7 +2911,7 @@ cdef class Polynomial(CommutativePolynomial): def mod(self, other): """ - Remainder of division of self by other. + Remainder of division of ``self`` by ``other``. EXAMPLES:: @@ -2954,7 +2956,7 @@ cdef class Polynomial(CommutativePolynomial): cpdef _mul_generic(self, right): """ - Compute the product of self and right using the classical quadratic + Compute the product of ``self`` and ``right`` using the classical quadratic algorithm. This method is the default for inexact rings. For two polynomials of degree n and m this method needs @@ -3114,7 +3116,7 @@ cdef class Polynomial(CommutativePolynomial): INPUT: - ``self`` - Polynomial - - ``right`` - Polynomial (over same base ring as self) + - ``right`` - Polynomial (over same base ring as ``self``) - ``K_threshold`` - (optional) Integer. A threshold to fall back to schoolbook algorithm. In the recursion, if one of the polynomials is of degree less that K_threshold then the classic quadratic @@ -3300,22 +3302,22 @@ cdef class Polynomial(CommutativePolynomial): def base_ring(self): """ - Return the base ring of the parent of self. + Return the base ring of the parent of ``self``. EXAMPLES:: sage: R. = ZZ[] sage: x.base_ring() Integer Ring - sage: (2*x+3).base_ring() + sage: (2*x + 3).base_ring() Integer Ring """ return self._parent.base_ring() cpdef base_extend(self, R): """ - Return a copy of this polynomial but with coefficients in R, if - there is a natural map from coefficient ring of self to R. + Return a copy of this polynomial but with coefficients in ``R``, if + there is a natural map from the coefficient ring of ``self`` to ``R``. EXAMPLES:: @@ -3458,8 +3460,9 @@ cdef class Polynomial(CommutativePolynomial): def __copy__(self): """ - Return a "copy" of self. This is just self, since in Sage - polynomials are immutable this just returns self again. + Return a "copy" of ``self``. + + This is just ``self``, since in Sage polynomials are immutable. EXAMPLES: @@ -3537,20 +3540,20 @@ cdef class Polynomial(CommutativePolynomial): def denominator(self): """ - Return a denominator of self. + Return a denominator of ``self``. - First, the lcm of the denominators of the entries of self + First, the lcm of the denominators of the entries of ``self`` is computed and returned. If this computation fails, the - unit of the parent of self is returned. + unit of the parent of ``self`` is returned. Note that some subclasses may implement their own - denominator function. For example, see + :meth:`denominator` method. For example, see :class:`sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint` .. warning:: This is not the denominator of the rational function - defined by self, which would always be 1 since self is a + defined by ``self``, which would always be 1 since ``self`` is a polynomial. EXAMPLES: @@ -3578,7 +3581,7 @@ cdef class Polynomial(CommutativePolynomial): Finally, we try to compute the denominator of a polynomial with coefficients in the real numbers, which is a ring whose elements do - not have a denominator method. + not have a :meth:`denominator` method. :: @@ -3589,7 +3592,7 @@ cdef class Polynomial(CommutativePolynomial): 1.00000000000000 Check that the denominator is an element over the base whenever the base - has no denominator function. This closes :trac:`9063`. :: + has no :meth:`denominator` method. This closes :trac:`9063`. :: sage: R. = GF(5)[] # optional - sage.rings.finite_rings sage: x = R(0) # optional - sage.rings.finite_rings @@ -3625,7 +3628,7 @@ cdef class Polynomial(CommutativePolynomial): def numerator(self): """ - Return a numerator of self computed as self * self.denominator() + Return a numerator of ``self``, computed as ``self * self.denominator()`` Note that some subclasses may implement its own numerator function. For example, see @@ -3634,13 +3637,13 @@ cdef class Polynomial(CommutativePolynomial): .. warning:: This is not the numerator of the rational function - defined by self, which would always be self since self is a + defined by ``self``, which would always be ``self`` since ``self`` is a polynomial. EXAMPLES: First we compute the numerator of a polynomial with - integer coefficients, which is of course self. + integer coefficients, which is of course ``self``. :: @@ -3676,8 +3679,8 @@ cdef class Polynomial(CommutativePolynomial): sage: f.numerator() x + 0.300000000000000 - We check that the computation the numerator and denominator - are valid + We check that the computation of the numerator and denominator + are valid. :: @@ -3695,10 +3698,10 @@ cdef class Polynomial(CommutativePolynomial): def derivative(self, *args): r""" The formal derivative of this polynomial, with respect to variables - supplied in args. + supplied in ``args``. Multiple variables and iteration counts may be supplied; see - documentation for the global derivative() function for more + documentation for the global :func:`derivative` function for more details. .. SEEALSO:: @@ -3962,7 +3965,7 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = QQ[] sage: t = PolynomialRing(R,'t').gen() - sage: f = x*t +5*t^2 + sage: f = x*t + 5*t^2 sage: f.integral(x) 5*x*t^2 + 1/2*x^2*t @@ -4108,11 +4111,14 @@ cdef class Polynomial(CommutativePolynomial): sage: (x^2).factor() # optional - sage.libs.ntl Traceback (most recent call last): ... - NotImplementedError: factorization of polynomials over rings with composite characteristic is not implemented - sage: R.base_ring()._factor_univariate_polynomial = lambda f: f.change_ring(ZZ).factor() - sage: (x^2).factor() # optional - sage.libs.pari + NotImplementedError: factorization of polynomials over rings with + composite characteristic is not implemented + sage: def my_factor(f): + ....: return f.change_ring(ZZ).factor() + sage: R.base_ring()._factor_univariate_polynomial = my_factor # optional - sage.libs.ntl + sage: (x^2).factor() # optional - sage.libs.ntl sage.libs.pari x^2 - sage: del R.base_ring()._factor_univariate_polynomial # clean up # optional - sage.libs.ntl + sage: del R.base_ring()._factor_univariate_polynomial # clean up # optional - sage.libs.ntl Arbitrary precision real and complex factorization:: @@ -4187,9 +4193,11 @@ cdef class Polynomial(CommutativePolynomial): sage: f = (x^2 + 2*R(I))^3 sage: F = f.factor() sage: F # abs tol 3e-5 - (x - 1.0000138879287663 + 1.0000013435286879*I) * (x - 0.9999942196864997 + 0.9999873009803959*I) * (x - 0.9999918923847313 + 1.0000113554909125*I) * (x + 0.9999908759550227 - 1.0000069659624138*I) * (x + 0.9999985293216753 - 0.9999886153831807*I) * (x + 1.0000105947233 - 1.0000044186544053*I) + (x - 1.0000138879287663 + 1.0000013435286879*I) * (x - 0.9999942196864997 + 0.9999873009803959*I) * (x - 0.9999918923847313 + 1.0000113554909125*I) + * (x + 0.9999908759550227 - 1.0000069659624138*I) * (x + 0.9999985293216753 - 0.9999886153831807*I) * (x + 1.0000105947233 - 1.0000044186544053*I) sage: [f(t[0][0]).abs() for t in F] # abs tol 1e-13 - [1.979365054e-14, 1.97936298566e-14, 1.97936990747e-14, 3.6812407475e-14, 3.65211563729e-14, 3.65220890052e-14] + [1.979365054e-14, 1.97936298566e-14, 1.97936990747e-14, + 3.6812407475e-14, 3.65211563729e-14, 3.65220890052e-14] Factoring polynomials over `\ZZ/n\ZZ` for composite `n` is not implemented:: @@ -4878,7 +4886,7 @@ cdef class Polynomial(CommutativePolynomial): The actual algorithm for computing greatest common divisors depends on the base ring underlying the polynomial ring. If the base ring - defines a method ``_gcd_univariate_polynomial``, then this method + defines a method :meth:`_gcd_univariate_polynomial`, then this method will be called (see examples below). EXAMPLES:: @@ -5007,7 +5015,7 @@ cdef class Polynomial(CommutativePolynomial): - (ring theory) A polynomial over a ring is primitive if its coefficients generate the unit ideal. - Calling `is_primitive` on a polynomial over an infinite field will + Calling :meth:`is_primitive` on a polynomial over an infinite field will raise an error. The additional inputs to this function are to speed up computation for @@ -5015,29 +5023,29 @@ cdef class Polynomial(CommutativePolynomial): INPUT: - - ``n`` (default: ``None``) - if provided, should equal - `q-1` where ``self.parent()`` is the field with `q` - elements; otherwise it will be computed. + - ``n`` (default: ``None``) - if provided, should equal + `q-1` where ``self.parent()`` is the field with `q` + elements; otherwise it will be computed. - - ``n_prime_divs`` (default: ``None``) - if provided, should - be a list of the prime divisors of ``n``; otherwise it - will be computed. + - ``n_prime_divs`` (default: ``None``) - if provided, should + be a list of the prime divisors of ``n``; otherwise it + will be computed. .. NOTE:: Computation of the prime divisors of ``n`` can dominate the running time of this method, so performing this computation externally - (e.g. ``pdivs=n.prime_divisors()``) is a good idea for repeated calls + (e.g., ``pdivs = n.prime_divisors()``) is a good idea for repeated calls to is_primitive for polynomials of the same degree. Results may be incorrect if the wrong ``n`` and/or factorization are provided. - EXAMPLES:: + EXAMPLES: - Field semantics examples. + Field semantics examples. - :: + :: sage: R. = GF(2)['x'] # optional - sage.rings.finite_rings sage: f = x^4+x^3+x^2+x+1 # optional - sage.rings.finite_rings @@ -5066,9 +5074,9 @@ cdef class Polynomial(CommutativePolynomial): ... NotImplementedError: is_primitive() not defined for polynomials over infinite fields. - Ring semantics examples. + Ring semantics examples. - :: + :: sage: x=polygen(ZZ) sage: f = 5*x^2+2 @@ -5171,14 +5179,14 @@ cdef class Polynomial(CommutativePolynomial): def is_monomial(self): """ - Return True if self is a monomial, i.e., a power of the generator. + Return True if ``self`` is a monomial, i.e., a power of the generator. EXAMPLES:: sage: R. = QQ[] sage: x.is_monomial() True - sage: (x+1).is_monomial() + sage: (x + 1).is_monomial() False sage: (x^2).is_monomial() True @@ -5219,7 +5227,7 @@ cdef class Polynomial(CommutativePolynomial): True sage: (3*x^5).is_term() True - sage: (1+3*x^5).is_term() + sage: (1 + 3*x^5).is_term() False To require that the coefficient is 1, use :meth:`is_monomial()` @@ -5233,7 +5241,7 @@ cdef class Polynomial(CommutativePolynomial): def root_field(self, names, check_irreducible=True): """ Return the field generated by the roots of the irreducible - polynomial self. The output is either a number field, relative + polynomial ``self``. The output is either a number field, relative number field, a quotient of a polynomial ring over a field, or the fraction field of the base ring. @@ -5317,15 +5325,15 @@ cdef class Polynomial(CommutativePolynomial): def sylvester_matrix(self, right, variable = None): """ - Return the Sylvester matrix of self and right. + Return the Sylvester matrix of ``self`` and ``right``. Note that the Sylvester matrix is not defined if one of the polynomials is zero. INPUT: - - right: a polynomial in the same ring as self. - - variable: optional, included for compatibility with the multivariate + - ``right``: a polynomial in the same ring as ``self``. + - ``variable``: optional, included for compatibility with the multivariate case only. The variable of the polynomials. EXAMPLES:: @@ -5349,7 +5357,7 @@ cdef class Polynomial(CommutativePolynomial): sage: M.determinant() # optional - sage.modules 0 - If self and right are polynomials of positive degree, the determinant + If ``self`` and ``right`` are polynomials of positive degree, the determinant of the Sylvester matrix is the resultant of the polynomials.:: sage: h1 = R._random_nonzero_element() @@ -5359,7 +5367,7 @@ cdef class Polynomial(CommutativePolynomial): True The rank of the Sylvester matrix is related to the degree of the - gcd of self and right:: + gcd of ``self`` and ``right``:: sage: f.gcd(g).degree() == f.degree() + g.degree() - M.rank() # optional - sage.modules True @@ -5636,8 +5644,8 @@ cdef class Polynomial(CommutativePolynomial): sage: R(x).is_gen() True - Important - this function doesn't return True if self equals the - generator; it returns True if self *is* the generator. + Important - this function doesn't return True if ``self`` equals the + generator; it returns True if ``self`` *is* the generator. :: @@ -5808,7 +5816,7 @@ cdef class Polynomial(CommutativePolynomial): INPUT: - ``prec`` -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -5894,7 +5902,7 @@ cdef class Polynomial(CommutativePolynomial): - ``v`` -- a prime or prime ideal of the base ring. - ``prec`` -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -5946,7 +5954,7 @@ cdef class Polynomial(CommutativePolynomial): - ``i`` -- an integer. - ``prec`` -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -6020,7 +6028,7 @@ cdef class Polynomial(CommutativePolynomial): sage: v = f.list(); v [-1/3, 2, 0, -2/5] - Note that v is a list, it is mutable, and each call to the list + Note that ``v`` is a list, it is mutable, and each call to the :meth:`list` method returns a new list:: sage: type(v) @@ -6202,7 +6210,7 @@ cdef class Polynomial(CommutativePolynomial): polynomial, computed using the Newton-Raphson method. The Newton-Raphson method is an iterative root-finding algorithm. - For f(x) a polynomial, as is the case here, this is essentially the + For `f(x)` a polynomial, as is the case here, this is essentially the same as Horner's method. INPUT: @@ -6214,10 +6222,10 @@ cdef class Polynomial(CommutativePolynomial): OUTPUT: A list of numbers hopefully approximating a root of - f(x)=0. + `f(x)=0`. - If one of the iterates is a critical point of f then a - ZeroDivisionError exception is raised. + If one of the iterates is a critical point of `f`, a + :class:`ZeroDivisionError` exception is raised. EXAMPLES:: @@ -6270,13 +6278,13 @@ cdef class Polynomial(CommutativePolynomial): def newton_slopes(self, p, lengths=False): """ - Return the `p`-adic slopes of the Newton polygon of self, + Return the `p`-adic slopes of the Newton polygon of ``self``, when this makes sense. OUTPUT: - If `lengths` is `False`, a list of rational numbers. If `lengths` is - `True`, a list of couples `(s,l)` where `s` is the slope and `l` the + If ``lengths`` is False, a list of rational numbers. If ``lengths`` is + True, a list of couples `(s,l)` where `s` is the slope and `l` the length of the corresponding segment in the Newton polygon. EXAMPLES:: @@ -6294,7 +6302,7 @@ cdef class Polynomial(CommutativePolynomial): sage: (x^2^100 + 27).newton_slopes(3, lengths=True) [(3/1267650600228229401496703205376, 1267650600228229401496703205376)] - ALGORITHM: Uses PARI if `lengths` is `False`. + ALGORITHM: Uses PARI if ``lengths`` is ``False``. """ if not lengths: f = self.__pari__() @@ -6688,7 +6696,7 @@ cdef class Polynomial(CommutativePolynomial): ALGORITHM: - Uses PARI's ``polresultant`` function. For base rings that + Uses PARI's function :pari:`polresultant`. For base rings that are not supported by PARI, the resultant is computed as the determinant of the Sylvester matrix. @@ -6886,8 +6894,8 @@ cdef class Polynomial(CommutativePolynomial): where the roots `a` and `b` are to be considered in the algebraic closure of the fraction field of the coefficients and counted with multiplicities. If the polynomials are not monic this quantity is - multiplied by `\\alpha_1^{deg(p_2)} \\alpha_2^{deg(p_1)}` where - `\\alpha_1` and `\\alpha_2` are the leading coefficients of `p_1` and + multiplied by `\alpha_1^{deg(p_2)} \alpha_2^{deg(p_1)}` where + `\alpha_1` and `\alpha_2` are the leading coefficients of `p_1` and `p_2` respectively. INPUT: @@ -6898,7 +6906,7 @@ cdef class Polynomial(CommutativePolynomial): - ``op`` -- ``operator.OP`` where ``OP=add`` or ``sub`` or ``mul`` or ``truediv``. - - ``algorithm`` -- can be "resultant" or "BFSS"; + - ``algorithm`` -- can be ``"resultant"`` or ``"BFSS"``; by default the former is used when the polynomials have few nonzero coefficients and small degrees or if the base ring is not `\ZZ` or `\QQ`. Otherwise the latter is used. @@ -6910,7 +6918,7 @@ cdef class Polynomial(CommutativePolynomial): ALGORITHM: The computation is straightforward using resultants. Indeed for the - composed sum it would be `Res_y(p1(x-y), p2(y))`. However, the method + composed sum it would be `Res_y(p_1(x-y), p_2(y))`. However, the method from [BFSS2006]_ using series expansions is asymptotically much faster. Note that the algorithm ``BFSS`` with polynomials with coefficients in @@ -7321,8 +7329,8 @@ cdef class Polynomial(CommutativePolynomial): R_n := a_n^{2 n-2} \prod_{1 = QQ[] sage: g = -27*u^14 - 32*u^9 sage: g.roots(CDF, multiplicities=False) # abs tol 2e-15 - [-1.0345637159435719, 0.0, -0.3196977699902601 - 0.9839285635706636*I, -0.3196977699902601 + 0.9839285635706636*I, 0.8369796279620465 - 0.6081012947885318*I, 0.8369796279620465 + 0.6081012947885318*I] + [-1.0345637159435719, 0.0, -0.3196977699902601 - 0.9839285635706636*I, -0.3196977699902601 + 0.9839285635706636*I, + 0.8369796279620465 - 0.6081012947885318*I, 0.8369796279620465 + 0.6081012947885318*I] sage: g.roots(CDF) # abs tol 2e-15 - [(-1.0345637159435719, 1), (0.0, 9), (-0.3196977699902601 - 0.9839285635706636*I, 1), (-0.3196977699902601 + 0.9839285635706636*I, 1), (0.8369796279620465 - 0.6081012947885318*I, 1), (0.8369796279620465 + 0.6081012947885318*I, 1)] + [(-1.0345637159435719, 1), (0.0, 9), (-0.3196977699902601 - 0.9839285635706636*I, 1), (-0.3196977699902601 + 0.9839285635706636*I, 1), + (0.8369796279620465 - 0.6081012947885318*I, 1), (0.8369796279620465 + 0.6081012947885318*I, 1)] This shows that the issue at :trac:`2418` is fixed:: @@ -8538,7 +8580,7 @@ cdef class Polynomial(CommutativePolynomial): Return the complex roots of this polynomial, without multiplicities. - Calls self.roots(ring=CC), unless this is a polynomial with + Calls ``self.roots(ring=CC)``, unless this is a polynomial with floating-point coefficients, in which case it is uses the appropriate precision from the input coefficients. @@ -8582,16 +8624,16 @@ cdef class Polynomial(CommutativePolynomial): def number_of_roots_in_interval(self, a=None, b=None): r""" Return the number of roots of this polynomial in the interval - [a,b], counted without multiplicity. The endpoints a, b default to - -Infinity, Infinity (which are also valid input values). + `[a,b]`, counted without multiplicity. The endpoints `a`, `b` default to + ``-Infinity``, ``Infinity`` (which are also valid input values). Calls the PARI routine :pari:`polsturm`. Note that as of version 2.8, PARI includes the left endpoint of the interval (and no longer uses Sturm's algorithm on exact - inputs). polsturm requires a polynomial with real + inputs). :pari:`polsturm` requires a polynomial with real coefficients; in case PARI returns an error, we try again - after taking the GCD of `self` with its complex conjugate. + after taking the GCD of ``self`` with its complex conjugate. EXAMPLES:: @@ -8856,8 +8898,8 @@ cdef class Polynomial(CommutativePolynomial): - ``self`` -- polynomial with rational or integer coefficients - ``return_q`` -- (default ``False``) if ``True``, return a second value `q` - which is the prime power with respect to which this is `q`-Weil, - or 0 if there is no such value. + which is the prime power with respect to which this is `q`-Weil, + or 0 if there is no such value. EXAMPLES:: @@ -8878,7 +8920,7 @@ cdef class Polynomial(CommutativePolynomial): .. SEEALSO:: - Polynomial rings have a method `weil_polynomials` to compute sets of Weil + Polynomial rings have a method :meth:`weil_polynomials` to compute sets of Weil polynomials. This computation uses the iterator :class:`sage.rings.polynomial.weil.weil_polynomials.WeilPolynomials`. @@ -9004,7 +9046,7 @@ cdef class Polynomial(CommutativePolynomial): The actual algorithm for computing the extended gcd depends on the base ring underlying the polynomial ring. If the base ring defines - a method ``_xgcd_univariate_polynomial``, then this method will be + a method :meth:`_xgcd_univariate_polynomial`, then this method will be called (see examples below). EXAMPLES:: @@ -9018,7 +9060,7 @@ cdef class Polynomial(CommutativePolynomial): x One can easily add xgcd functionality to new rings by providing a - method ``_xgcd_univariate_polynomial``:: + method :meth:`_xgcd_univariate_polynomial`:: sage: R. = QQ[] sage: S. = R[] @@ -9027,12 +9069,13 @@ cdef class Polynomial(CommutativePolynomial): sage: h1.xgcd(h2) Traceback (most recent call last): ... - NotImplementedError: Univariate Polynomial Ring in x over Rational Field does not provide an xgcd implementation for univariate polynomials + NotImplementedError: Univariate Polynomial Ring in x over Rational Field + does not provide an xgcd implementation for univariate polynomials sage: T. = QQ[] - sage: def poor_xgcd(f,g): + sage: def poor_xgcd(f, g): ....: ret = S(T(f).gcd(g)) - ....: if ret == f: return ret,S.one(),S.zero() - ....: if ret == g: return ret,S.zero(),S.one() + ....: if ret == f: return ret, S.one(), S.zero() + ....: if ret == g: return ret, S.zero(), S.one() ....: raise NotImplementedError sage: R._xgcd_univariate_polynomial = poor_xgcd sage: h1.xgcd(h2) @@ -9070,10 +9113,10 @@ cdef class Polynomial(CommutativePolynomial): sage: z = PolynomialRing(QQ, 'z').gen() sage: p = -z**16 - z**15 - z**14 + z**13 + z**12 + z**11 - z**5 - z**4 - z**3 + z**2 + z + 1 sage: m = z**21 - sage: n, d = p.rational_reconstruction(m) - sage: print((n ,d)) - (z^4 + 2*z^3 + 3*z^2 + 2*z + 1, z^10 + z^9 + z^8 + z^7 + z^6 + z^5 + z^4 + z^3 + z^2 + z + 1) - sage: print(((p*d - n) % m ).is_zero()) + sage: n, d = p.rational_reconstruction(m); n, d + (z^4 + 2*z^3 + 3*z^2 + 2*z + 1, + z^10 + z^9 + z^8 + z^7 + z^6 + z^5 + z^4 + z^3 + z^2 + z + 1) + sage: ((p*d - n) % m).is_zero() True Over `\ZZ[z]`:: @@ -9081,10 +9124,10 @@ cdef class Polynomial(CommutativePolynomial): sage: z = PolynomialRing(ZZ, 'z').gen() sage: p = -z**16 - z**15 - z**14 + z**13 + z**12 + z**11 - z**5 - z**4 - z**3 + z**2 + z + 1 sage: m = z**21 - sage: n, d = p.rational_reconstruction(m) - sage: print((n ,d)) - (z^4 + 2*z^3 + 3*z^2 + 2*z + 1, z^10 + z^9 + z^8 + z^7 + z^6 + z^5 + z^4 + z^3 + z^2 + z + 1) - sage: print(((p*d - n) % m ).is_zero()) + sage: n, d = p.rational_reconstruction(m); n, d + (z^4 + 2*z^3 + 3*z^2 + 2*z + 1, + z^10 + z^9 + z^8 + z^7 + z^6 + z^5 + z^4 + z^3 + z^2 + z + 1) + sage: ((p*d - n) % m).is_zero() True Over an integral domain ``d`` might not be monic:: @@ -9093,15 +9136,13 @@ cdef class Polynomial(CommutativePolynomial): sage: x = P.gen() sage: p = 7*x^5 - 10*x^4 + 16*x^3 - 32*x^2 + 128*x + 256 sage: m = x^5 - sage: n, d = p.rational_reconstruction(m, 3, 2) - sage: print((n ,d)) + sage: n, d = p.rational_reconstruction(m, 3, 2); n, d (-32*x^3 + 384*x^2 + 2304*x + 2048, 5*x + 8) - sage: print(((p*d - n) % m ).is_zero()) + sage: ((p*d - n) % m).is_zero() True - sage: n, d = p.rational_reconstruction(m, 4, 0) - sage: print((n ,d)) + sage: n, d = p.rational_reconstruction(m, 4, 0); n, d (-10*x^4 + 16*x^3 - 32*x^2 + 128*x + 256, 1) - sage: print(((p*d - n) % m ).is_zero()) + sage: ((p*d - n) % m).is_zero() True Over `\QQ(t)[z]`:: @@ -9113,8 +9154,7 @@ cdef class Polynomial(CommutativePolynomial): sage: # p = (1 + t^2*z + z^4) / (1 - t*z) sage: p = (1 + t^2*z + z^4)*(1 - t*z).inverse_mod(z^9) sage: m = z^9 - sage: n, d = p.rational_reconstruction(m) - sage: print((n ,d)) + sage: n, d = p.rational_reconstruction(m); n, d (-1/t*z^4 - t*z - 1/t, z - 1/t) sage: print(((p*d - n) % m ).is_zero()) True @@ -9122,8 +9162,9 @@ cdef class Polynomial(CommutativePolynomial): sage: n = -10*t^2*z^4 + (-t^2 + t - 1)*z^3 + (-t - 8)*z^2 + z + 2*t^2 - t sage: d = z^4 + (2*t + 4)*z^3 + (-t + 5)*z^2 + (t^2 + 2)*z + t^2 + 2*t + 1 sage: prec = 9 - sage: nc, dc = Pz((n.subs(z = w)/d.subs(z = w) + O(w^prec)).list()).rational_reconstruction(z^prec) - sage: print( (nc, dc) == (n, d) ) + sage: x = n.subs(z=w)/d.subs(z=w) + O(w^prec) + sage: nc, dc = Pz(x.list()).rational_reconstruction(z^prec) + sage: (nc, dc) == (n, d) True Over `\QQ[t][z]`:: @@ -9308,9 +9349,9 @@ cdef class Polynomial(CommutativePolynomial): `\infty`. If a prime (or non-prime) `p` is given, then the valuation - is the largest power of `p` which divides self. + is the largest power of `p` which divides ``self``. - The valuation at `\infty` is -self.degree(). + The valuation at `\infty` is ``-self.degree()``. EXAMPLES:: @@ -9555,13 +9596,13 @@ cdef class Polynomial(CommutativePolynomial): cpdef Polynomial truncate(self, long n): r""" - Return the polynomial of degree ` < n` which is equivalent + Return the polynomial of degree `< n` which is equivalent to self modulo `x^n`. EXAMPLES:: sage: R. = ZZ[]; S. = PolynomialRing(R, sparse=True) - sage: f = y^3 + x*y -3*x; f + sage: f = y^3 + x*y - 3*x; f y^3 + x*y - 3*x sage: f.truncate(2) x*y - 3*x @@ -9624,13 +9665,13 @@ cdef class Polynomial(CommutativePolynomial): sage: K. = FunctionField(GF(3)) # optional - sage.rings.finite_rings sage: R. = K[] # optional - sage.rings.finite_rings - sage: (x^3-x).is_squarefree() # optional - sage.rings.finite_rings + sage: (x^3 - x).is_squarefree() # optional - sage.rings.finite_rings True - sage: (x^3-1).is_squarefree() # optional - sage.rings.finite_rings + sage: (x^3 - 1).is_squarefree() # optional - sage.rings.finite_rings False - sage: (x^3+t).is_squarefree() # optional - sage.rings.finite_rings + sage: (x^3 + t).is_squarefree() # optional - sage.rings.finite_rings True - sage: (x^3+t^3).is_squarefree() # optional - sage.rings.finite_rings + sage: (x^3 + t^3).is_squarefree() # optional - sage.rings.finite_rings False In the following example, `t^2` is a unit in the base field:: @@ -9743,12 +9784,12 @@ cdef class Polynomial(CommutativePolynomial): def radical(self): """ - Return the radical of self. + Return the radical of ``self``. Over a field, this is the product of - the distinct irreducible factors of self. (This is also sometimes + the distinct irreducible factors of ``self``. (This is also sometimes called the "square-free part" of self, but that term is ambiguous; - it is sometimes used to mean the quotient of self by its maximal + it is sometimes used to mean the quotient of ``self`` by its maximal square factor.) EXAMPLES:: @@ -9996,9 +10037,9 @@ cdef class Polynomial(CommutativePolynomial): INPUT: - ``certificate`` -- boolean, default to ``False``. Only works with - ``algorithm`` set to "pari". + ``algorithm`` set to ``"pari"``. - - ``algorithm`` -- either "pari" or "sage" (default is "pari") + - ``algorithm`` -- either ``"pari"`` or ``"sage"`` (default is ``"pari"``) ALGORITHM: @@ -10282,7 +10323,7 @@ cdef class Polynomial(CommutativePolynomial): The algorithm assumes that the polynomial has rational coefficients. If the polynomial is known to be irreducible, it may be slightly more - efficient to call `is_cyclotomic` instead. + efficient to call :meth:`is_cyclotomic` instead. .. SEEALSO:: @@ -10447,7 +10488,7 @@ cdef class Polynomial(CommutativePolynomial): series. This method works only when the base ring is an integral domain. Moreover, for polynomial whose coefficient of lower degree is different from 1, the elements of the base - ring should have a method ``nth_root`` implemented. + ring should have a method :meth:`nth_root` implemented. EXAMPLES:: @@ -10757,7 +10798,7 @@ cdef class Polynomial(CommutativePolynomial): @coerce_binop def divides(self, p): r""" - Return `True` if this polynomial divides `p`. + Return ``True`` if this polynomial divides `p`. This method is only implemented for polynomials over an integral domain. @@ -10841,7 +10882,7 @@ cdef class Polynomial(CommutativePolynomial): - ``D`` -- dictionary (optional) - - ``phi`` -- SpecializationMorphism (optional) + - ``phi`` -- :class:`SpecializationMorphism` (optional) OUTPUT: a new polynomial @@ -11411,7 +11452,7 @@ cdef class Polynomial_generic_dense(Polynomial): True sage: (3*x^5).is_term() # optional - sage.symbolic True - sage: (1+3*x^5).is_term() # optional - sage.symbolic + sage: (1 + 3*x^5).is_term() # optional - sage.symbolic False """ if not self.__coeffs: @@ -11651,8 +11692,7 @@ cdef class Polynomial_generic_dense(Polynomial): """ Return the constant coefficient of this polynomial. - OUTPUT: - element of base ring + OUTPUT: element of base ring EXAMPLES:: @@ -11753,8 +11793,8 @@ cdef class Polynomial_generic_dense(Polynomial): Return the quotient and remainder of the Euclidean division of ``self`` and ``other``. - Raises a ``ZerodivisionError`` if ``other`` is zero. Raises an - ``ArithmeticError`` if the division is not exact. + Raises a :class:`ZerodivisionError` if ``other`` is zero. Raises an + :class:`ArithmeticError` if the division is not exact. EXAMPLES:: @@ -11854,7 +11894,7 @@ cdef class Polynomial_generic_dense(Polynomial): cpdef Polynomial truncate(self, long n): r""" - Return the polynomial of degree ` < n` which is equivalent + Return the polynomial of degree `< n` which is equivalent to self modulo `x^n`. EXAMPLES:: @@ -12167,7 +12207,7 @@ cdef class ConstantPolynomialSection(Map): """ This class is used for conversion from a polynomial ring to its base ring. - Since :trac:`9944`, it calls the ``constant_coefficient`` method, + Since :trac:`9944`, it calls the :meth:`constant_coefficient` method, which can be optimized for a particular polynomial type. EXAMPLES:: @@ -12222,12 +12262,12 @@ cdef class PolynomialBaseringInjection(Morphism): This class is used for conversion from a ring to a polynomial over that ring. - It calls the _new_constant_poly method on the generator, + It calls the :meth:`_new_constant_poly` method on the generator, which should be optimized for a particular polynomial type. Technically, it should be a method of the polynomial ring, but - few polynomial rings are cython classes, and so, as a method - of a cython polynomial class, it is faster. + few polynomial rings are Cython classes, and so, as a method + of a Cython polynomial class, it is faster. EXAMPLES: @@ -12240,12 +12280,14 @@ cdef class PolynomialBaseringInjection(Morphism): sage: R.coerce_map_from(R.base_ring()) # optional - sage.rings.padics Polynomial base injection morphism: From: 3-adic Field with capped relative precision 20 - To: Univariate Polynomial Ring in x over 3-adic Field with capped relative precision 20 + To: Univariate Polynomial Ring in x over + 3-adic Field with capped relative precision 20 sage: R. = Qp(3)[] # optional - sage.rings.padics sage: R.coerce_map_from(R.base_ring()) # optional - sage.rings.padics Polynomial base injection morphism: From: 3-adic Field with capped relative precision 20 - To: Multivariate Polynomial Ring in x, y over 3-adic Field with capped relative precision 20 + To: Multivariate Polynomial Ring in x, y over + 3-adic Field with capped relative precision 20 sage: R. = QQ[] sage: R.coerce_map_from(R.base_ring()) Polynomial base injection morphism: diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py index 4f7f7d4a04b..19d225cace4 100644 --- a/src/sage/rings/polynomial/polynomial_element_generic.py +++ b/src/sage/rings/polynomial/polynomial_element_generic.py @@ -791,9 +791,9 @@ def quo_rem(self, other): Returns the quotient and remainder of the Euclidean division of ``self`` and ``other``. - Raises ZerodivisionError if ``other`` is zero. + Raises :class:`ZerodivisionError` if ``other`` is zero. - Raises ArithmeticError if ``other`` has a nonunit leading coefficient + Raises :class:`ArithmeticError` if ``other`` has a nonunit leading coefficient and this causes the Euclidean division to fail. EXAMPLES:: @@ -811,7 +811,8 @@ def quo_rem(self, other): sage: f.quo_rem(g) Traceback (most recent call last): ... - ArithmeticError: Division non exact (consider coercing to polynomials over the fraction field) + ArithmeticError: Division non exact + (consider coercing to polynomials over the fraction field) sage: g = 0 sage: f.quo_rem(g) Traceback (most recent call last): @@ -974,7 +975,7 @@ def reverse(self, degree=None): """ Return this polynomial but with the coefficients reversed. - If an optional degree argument is given the coefficient list will be + If an optional degree argument is given, the coefficient list will be truncated or zero padded as necessary and the reverse polynomial will have the specified degree. @@ -996,7 +997,7 @@ def reverse(self, degree=None): def truncate(self, n): """ - Return the polynomial of degree `< n` equal to `self` modulo `x^n`. + Return the polynomial of degree `< n` equal to ``self`` modulo `x^n`. EXAMPLES:: @@ -1061,8 +1062,8 @@ class Polynomial_generic_field(Polynomial_singular_repr, @coerce_binop def quo_rem(self, other): """ - Returns a tuple (quotient, remainder) where - self = quotient * other + remainder. + Returns a tuple ``(quotient, remainder)`` where + ``self = quotient * other + remainder``. EXAMPLES:: diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index db99b06f53f..5367ba96603 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -63,7 +63,7 @@ :trac:`9944` introduced some changes related with coercion. Previously, a dense and a sparse polynomial ring with the same variable name over the same base ring evaluated equal, but of -course they were not identical.Coercion maps are cached - but if a +course they were not identical. Coercion maps are cached - but if a coercion to a dense ring is requested and a coercion to a sparse ring is returned instead (since the cache keys are equal!), all hell breaks loose. @@ -79,9 +79,9 @@ True sage: R.has_coerce_map_from(S) False - sage: (R.0+S.0).parent() + sage: (R.0 + S.0).parent() Univariate Polynomial Ring in x over Rational Field - sage: (S.0+R.0).parent() + sage: (S.0 + R.0).parent() Univariate Polynomial Ring in x over Rational Field It may be that one has rings of dense or sparse polynomials over @@ -107,9 +107,9 @@ sage: R. = PolynomialRing(ZZ, implementation='NTL') # optional - sage.libs.ntl sage: S. = PolynomialRing(ZZ, implementation='FLINT') # optional - sage.libs.flint - sage: (S.0+R.0).parent() is S # optional - sage.libs.flint sage.libs.ntl + sage: (S.0 + R.0).parent() is S # optional - sage.libs.flint sage.libs.ntl True - sage: (R.0+S.0).parent() is S # optional - sage.libs.flint sage.libs.ntl + sage: (R.0 + S.0).parent() is S # optional - sage.libs.flint sage.libs.ntl True TESTS:: @@ -603,7 +603,8 @@ def flattening_morphism(self): sage: QQ['a','b']['x'].flattening_morphism() Flattening morphism: - From: Univariate Polynomial Ring in x over Multivariate Polynomial Ring in a, b over Rational Field + From: Univariate Polynomial Ring in x over + Multivariate Polynomial Ring in a, b over Rational Field To: Multivariate Polynomial Ring in a, b, x over Rational Field sage: QQ['x'].flattening_morphism() @@ -732,9 +733,9 @@ def _coerce_map_from_(self, P): sage: R. = PolynomialRing(QQ, sparse=True) sage: S. = QQ[] - sage: (R.0+S.0).parent() + sage: (R.0 + S.0).parent() Univariate Polynomial Ring in x over Rational Field - sage: (S.0+R.0).parent() + sage: (S.0 + R.0).parent() Univariate Polynomial Ring in x over Rational Field Here we test a feature that was implemented in :trac:`813`:: @@ -743,7 +744,7 @@ def _coerce_map_from_(self, P): sage: Q = Frac(QQ['x'])['y'] sage: Q.has_coerce_map_from(P) True - sage: P.0+Q.0 + sage: P.0 + Q.0 y + x In order to avoid bidirectional coercions (which are generally @@ -1068,8 +1069,8 @@ def change_var(self, var): def extend_variables(self, added_names, order = 'degrevlex'): r""" - Returns a multivariate polynomial ring with the same base ring but - with added_names as additional variables. + Return a multivariate polynomial ring with the same base ring but + with ``added_names`` as additional variables. EXAMPLES:: @@ -1362,7 +1363,7 @@ def random_element(self, degree=(-1,2), *args, **kwds): sage: R.random_element(6).degree() 6 - If a tuple of two integers is given for the degree argument, a degree + If a tuple of two integers is given for the ``degree`` argument, a degree is first uniformly chosen, then a polynomial of that degree is given:: sage: R.random_element(degree=(0, 8)).degree() in range(0, 9) @@ -1374,7 +1375,7 @@ def random_element(self, degree=(-1,2), *args, **kwds): Note that the zero polynomial has degree ``-1``, so if you want to consider it set the minimum degree to ``-1``:: - sage: while R.random_element(degree=(-1,2),x=-1,y=1) != R.zero(): + sage: while R.random_element(degree=(-1,2), x=-1, y=1) != R.zero(): ....: pass TESTS:: @@ -1561,10 +1562,10 @@ def polynomials( self, of_degree = None, max_degree = None ): - ``max_degree`` - an int; the iterator will generate all polynomials which have degree less than or equal to - max_degree + ``max_degree`` - ``of_degree`` - an int; the iterator will generate - all polynomials which have degree of_degree + all polynomials which have degree ``of_degree`` OUTPUT: an iterator @@ -1875,16 +1876,16 @@ def weil_polynomials(self, d, q, sign=1, lead=1): - ``sign`` -- integer (default `1`), the sign `s` of the functional equation - ``lead`` -- integer, list of integers or list of pairs of integers (default `1`), - constraints on the leading few coefficients of the generated polynomials. - If pairs `(a, b)` of integers are given, they are treated as a constraint - of the form `\equiv a \pmod{b}`; the moduli must be in decreasing order by - divisibility, and the modulus of the leading coefficient must be 0. + constraints on the leading few coefficients of the generated polynomials. + If pairs `(a, b)` of integers are given, they are treated as a constraint + of the form `\equiv a \pmod{b}`; the moduli must be in decreasing order by + divisibility, and the modulus of the leading coefficient must be 0. .. SEEALSO:: More documentation and additional options are available using the iterator :class:`sage.rings.polynomial.weil.weil_polynomials.WeilPolynomials` - directly. In addition, polynomials have a method `is_weil_polynomial` to + directly. In addition, polynomials have a method :meth:`is_weil_polynomial` to test whether or not the given polynomial is a Weil polynomial. EXAMPLES:: @@ -1904,9 +1905,9 @@ def weil_polynomials(self, d, q, sign=1, lead=1): sage: l = R.weil_polynomials(4, 2, lead=((1,0), (2,4), (1,2))) # optional - sage.libs.flint sage: l # optional - sage.libs.flint [T^4 + 2*T^3 + 5*T^2 + 4*T + 4, - T^4 + 2*T^3 + 3*T^2 + 4*T + 4, - T^4 - 2*T^3 + 5*T^2 - 4*T + 4, - T^4 - 2*T^3 + 3*T^2 - 4*T + 4] + T^4 + 2*T^3 + 3*T^2 + 4*T + 4, + T^4 - 2*T^3 + 5*T^2 - 4*T + 4, + T^4 - 2*T^3 + 3*T^2 - 4*T + 4] We do not require Weil polynomials to be monic. This example generates Weil polynomials associated to K3 surfaces over `GF(2)` of Picard number at least 12:: @@ -2113,7 +2114,7 @@ def divided_difference(self, points, full_table=False): - ``points`` -- a list of pairs `(x_0, y_0), (x_1, y_1), \dots, (x_n, y_n)` of elements of the base ring of ``self``, where `x_i - x_j` is invertible for `i \neq j`. This method - converts the `x_i` and `y_i` into the base ring of `self`. + converts the `x_i` and `y_i` into the base ring of ``self``. - ``full_table`` -- boolean (default: ``False``): If ``True``, return the full divided-difference table. If ``False``, @@ -2200,7 +2201,7 @@ def lagrange_polynomial(self, points, algorithm="divided_difference", previous_r - ``points`` -- a list of pairs `(x_0, y_0), (x_1, y_1), \dots, (x_n, y_n)` of elements of the base ring of ``self``, where `x_i - x_j` is invertible for `i \neq j`. This method - converts the `x_i` and `y_i` into the base ring of `self`. + converts the `x_i` and `y_i` into the base ring of ``self``. - ``algorithm`` -- (default: ``'divided_difference'``): one of the following: @@ -2551,10 +2552,11 @@ def irreducible_element(self, n, algorithm=None): 2 sage: f.is_irreducible() # optional - sage.rings.finite_rings True - sage: GF(19)['x'].irreducible_element(21, algorithm="first_lexicographic") # optional - sage.rings.finite_rings + sage: R = GF(19)['x'] # optional - sage.rings.finite_rings + sage: R.irreducible_element(21, algorithm="first_lexicographic") # optional - sage.rings.finite_rings x^21 + x + 5 - sage: GF(5**2, 'a')['x'].irreducible_element(17, # optional - sage.rings.finite_rings - ....: algorithm="first_lexicographic") + sage: R = GF(5**2, 'a')['x'] # optional - sage.rings.finite_rings + sage: R.irreducible_element(17, algorithm="first_lexicographic") # optional - sage.rings.finite_rings x^17 + a*x + 4*a + 3 AUTHORS: @@ -3372,13 +3374,13 @@ def irreducible_element(self, n, algorithm=None): Currently available options are: - ``'adleman-lenstra'``: a variant of the Adleman--Lenstra - algorithm as implemented in PARI. + algorithm as implemented in PARI. - ``'conway'``: look up the Conway polynomial of degree `n` over the field of `p` elements in the database; raise a ``RuntimeError`` if it is not found. - - ``'ffprimroot'``: use the ``ffprimroot()`` function from + - ``'ffprimroot'``: use the :pari:`ffprimroot` function from PARI. - ``'first_lexicographic'``: return the lexicographically @@ -3391,7 +3393,7 @@ def irreducible_element(self, n, algorithm=None): - ``'primitive'``: return a polynomial `f` such that a root of `f` generates the multiplicative group of the finite field extension defined by `f`. This uses the Conway polynomial if - possible, otherwise it uses ``ffprimroot``. + possible, otherwise it uses ``'ffprimroot'``. - ``'random'``: try random polynomials until an irreducible one is found. @@ -3399,7 +3401,7 @@ def irreducible_element(self, n, algorithm=None): If ``algorithm`` is ``None``, use `x - 1` in degree 1. In degree > 1, the Conway polynomial is used if it is found in the database. Otherwise, the algorithm ``minimal_weight`` - is used if `p = 2`, and the algorithm ``adleman-lenstra`` if + is used if `p = 2`, and the algorithm ``'adleman-lenstra'`` if `p > 2`. OUTPUT: @@ -3505,9 +3507,9 @@ def polygen(ring_or_element, name="x"): INPUT: - - polygen(base_ring, name="x") + - ``polygen(base_ring, name="x")`` - - polygen(ring_element, name="x") + - ``polygen(ring_element, name="x")`` If the first input is a ring, return a polynomial generator over that ring. If it is a ring element, return a polynomial generator @@ -3523,9 +3525,9 @@ def polygen(ring_or_element, name="x"): .. note:: - If you give a list or comma separated string to polygen, you'll + If you give a list or comma-separated string to :func:`polygen`, you'll get a tuple of indeterminates, exactly as if you called - polygens. + :func:`polygens`. """ if is_RingElement(ring_or_element): base_ring = ring_or_element.parent() @@ -3552,7 +3554,7 @@ def polygens(base_ring, names="x", *args): x^2 + 2*x*y + y^2 + 2*x*z + 2*y*z + z^2 sage: parent(x) Multivariate Polynomial Ring in x, y, z over Rational Field - sage: t = polygens(QQ,['x','yz','abc']) + sage: t = polygens(QQ, ['x','yz','abc']) sage: t (x, yz, abc) diff --git a/src/sage/rings/polynomial/symmetric_ideal.py b/src/sage/rings/polynomial/symmetric_ideal.py index 8f4e684b6af..2ff0381ad60 100644 --- a/src/sage/rings/polynomial/symmetric_ideal.py +++ b/src/sage/rings/polynomial/symmetric_ideal.py @@ -331,7 +331,8 @@ def is_maximal(self): sage: I = R.ideal([x[1] + y[2], x[2] - y[1]]) sage: I = R * I.groebner_basis() # optional - sage.combinat sage: I # optional - sage.combinat - Symmetric Ideal (y_1, x_1) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (y_1, x_1) of + Infinite polynomial ring in x, y over Rational Field sage: I = R.ideal([x[1] + y[2], x[2] - y[1]]) # optional - sage.combinat sage: I.is_maximal() # optional - sage.combinat False @@ -341,7 +342,8 @@ def is_maximal(self): sage: I = R * I.groebner_basis() # optional - sage.combinat sage: I # optional - sage.combinat - Symmetric Ideal (y_1, x_1) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (y_1, x_1) of + Infinite polynomial ring in x, y over Rational Field sage: I.is_maximal() # optional - sage.combinat True @@ -358,7 +360,7 @@ def is_maximal(self): def reduce(self, I, tailreduce=False): r""" - Symmetric reduction of self by another Symmetric Ideal or list of Infinite Polynomials, + Symmetric reduction of ``self`` by another Symmetric Ideal or list of Infinite Polynomials, or symmetric reduction of a given Infinite Polynomial by self. INPUT: @@ -387,9 +389,10 @@ def reduce(self, I, tailreduce=False): EXAMPLES:: sage: X. = InfinitePolynomialRing(QQ) - sage: I = X*(y[1]^2*y[3]+y[1]*x[3]^2) + sage: I = X * (y[1]^2*y[3] + y[1]*x[3]^2) sage: I.reduce([x[1]^2*y[2]]) - Symmetric Ideal (x_3^2*y_1 + y_3*y_1^2) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (x_3^2*y_1 + y_3*y_1^2) of + Infinite polynomial ring in x, y over Rational Field The preceding is correct, since any permutation that turns ``x[1]^2*y[2]`` into a factor of ``x[3]^2*y[2]`` interchanges @@ -398,7 +401,8 @@ def reduce(self, I, tailreduce=False): variable index 1 into 2 and 2 into 3:: sage: I.reduce([x[2]^2*y[1]]) # optional - sage.combinat - Symmetric Ideal (y_3*y_1^2) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (y_3*y_1^2) of + Infinite polynomial ring in x, y over Rational Field The next example shows that tail reduction is not done, unless it is explicitly advised. The input can also be a symmetric @@ -409,7 +413,8 @@ def reduce(self, I, tailreduce=False): Symmetric Ideal (x_3^2*y_1 + y_3*y_1^2) of Infinite polynomial ring in x, y over Rational Field sage: I.reduce(J, tailreduce=True) # optional - sage.combinat - Symmetric Ideal (x_3^2*y_1) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (x_3^2*y_1) of + Infinite polynomial ring in x, y over Rational Field """ if I in self.ring(): # we want to reduce a polynomial by self @@ -425,14 +430,14 @@ def reduce(self, I, tailreduce=False): def interreduction(self, tailreduce=True, sorted=False, report=None, RStrat=None): """ - Return symmetrically interreduced form of self + Return symmetrically interreduced form of ``self`` INPUT: - ``tailreduce`` -- (bool, default ``True``) If True, the interreduction is also performed on the non-leading monomials. - ``sorted`` -- (bool, default ``False``) If True, it is assumed that the - generators of self are already increasingly sorted. + generators of ``self`` are already increasingly sorted. - ``report`` -- (object, default ``None``) If not None, some information on the progress of computation is printed - ``RStrat`` -- (:class:`~sage.rings.polynomial.symmetric_reduction.SymmetricReductionStrategy`, @@ -578,7 +583,7 @@ def interreduced_basis(self): def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=False): """ - Apply permutations to the generators of self and interreduce + Apply permutations to the generators of ``self`` and interreduce INPUT: @@ -591,7 +596,7 @@ def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=F - ``report`` -- (object, default ``None``) If not ``None``, report on the progress of computations. - ``use_full_group`` (optional) -- If True, apply *all* elements of - `Sym(N)` to the generators of self (this is what [AB2008]_ + `Sym(N)` to the generators of ``self`` (this is what [AB2008]_ originally suggests). The default is to apply all elementary transpositions to the generators of ``self.squeezed()``, interreduce, and repeat until the result stabilises, which is @@ -601,7 +606,7 @@ def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=F OUTPUT: A symmetrically interreduced symmetric ideal with respect to - which any `Sym(N)`-translate of a generator of self is + which any `Sym(N)`-translate of a generator of ``self`` is symmetrically reducible, where by default ``N`` is the maximal variable index that occurs in the generators of ``self.interreduction().squeezed()``. @@ -666,7 +671,7 @@ def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=F def symmetric_basis(self): """ - A symmetrised generating set (type :class:`~sage.structure.sequence.Sequence`) of self. + A symmetrised generating set (type :class:`~sage.structure.sequence.Sequence`) of ``self``. This does essentially the same as :meth:`symmetrisation` with the option 'tailreduce', and it returns a @@ -694,7 +699,8 @@ def normalisation(self): sage: X. = InfinitePolynomialRing(QQ) sage: I = X*(1/2*x[1] + 2/3*x[2], 0, 4/5*x[1]*x[2]) sage: I.normalisation() - Symmetric Ideal (x_2 + 3/4*x_1, x_2*x_1) of Infinite polynomial ring in x over Rational Field + Symmetric Ideal (x_2 + 3/4*x_1, x_2*x_1) of + Infinite polynomial ring in x over Rational Field """ return SymmetricIdeal(self.ring(), [X/X.lc() for X in self.gens() if X._p!=0]) @@ -718,7 +724,8 @@ def squeezed(self): sage: X. = InfinitePolynomialRing(QQ, implementation='sparse') sage: I = X * (x[1000]*y[100], x[50]*y[1000]) sage: I.squeezed() - Symmetric Ideal (x_2*y_1, x_1*y_2) of Infinite polynomial ring in x, y over Rational Field + Symmetric Ideal (x_2*y_1, x_1*y_2) of + Infinite polynomial ring in x, y over Rational Field """ return SymmetricIdeal(self.ring(), [X.squeezed() for X in self.gens()]) diff --git a/src/sage/rings/polynomial/symmetric_reduction.pyx b/src/sage/rings/polynomial/symmetric_reduction.pyx index 75d3e4c4261..c8384b72977 100644 --- a/src/sage/rings/polynomial/symmetric_reduction.pyx +++ b/src/sage/rings/polynomial/symmetric_reduction.pyx @@ -60,7 +60,8 @@ Strategy object:: sage: from sage.rings.polynomial.symmetric_reduction import SymmetricReductionStrategy sage: S = SymmetricReductionStrategy(X, [y[2]^2*x[1]]) sage: S - Symmetric Reduction Strategy in Infinite polynomial ring in x, y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in x, y over Rational Field, modulo x_1*y_2^2 sage: S.reduce(p) x_3*y_1^2 + y_3*y_1 @@ -74,7 +75,8 @@ change variable index 1 into 2 and 2 into 3. So, we add this to sage: S.add_generator(y[1]^2*x[2]) sage: S - Symmetric Reduction Strategy in Infinite polynomial ring in x, y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in x, y over Rational Field, modulo x_2*y_1^2, x_1*y_2^2 sage: S.reduce(p) # optional - sage.combinat @@ -93,7 +95,8 @@ Symmetric Reduction Strategy is created:: sage: S2 = SymmetricReductionStrategy(X, [y[2]^2*x[1],y[1]^2*x[2]], tailreduce=True) sage: S2 - Symmetric Reduction Strategy in Infinite polynomial ring in x, y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in x, y over Rational Field, modulo x_2*y_1^2, x_1*y_2^2 with tailreduction @@ -265,7 +268,8 @@ cdef class SymmetricReductionStrategy: sage: from sage.rings.polynomial.symmetric_reduction import SymmetricReductionStrategy sage: S = SymmetricReductionStrategy(X, [y[2]^2*y[1],y[1]^2*y[2]]) sage: S - Symmetric Reduction Strategy in Infinite polynomial ring in y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in y over Rational Field, modulo y_2*y_1^2, y_2^2*y_1 sage: S.gens() @@ -295,7 +299,8 @@ cdef class SymmetricReductionStrategy: sage: R = SymmetricReductionStrategy(X) sage: R.setgens(S.gens()) sage: R - Symmetric Reduction Strategy in Infinite polynomial ring in y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in y over Rational Field, modulo y_2*y_1^2, y_2^2*y_1 sage: R.gens() is S.gens() @@ -316,7 +321,8 @@ cdef class SymmetricReductionStrategy: sage: from sage.rings.polynomial.symmetric_reduction import SymmetricReductionStrategy sage: S = SymmetricReductionStrategy(X, [y[2]^2*y[1],y[1]^2*y[2]]) sage: S - Symmetric Reduction Strategy in Infinite polynomial ring in y over Rational Field, modulo + Symmetric Reduction Strategy in + Infinite polynomial ring in y over Rational Field, modulo y_2*y_1^2, y_2^2*y_1 sage: S.reset() @@ -336,7 +342,7 @@ cdef class SymmetricReductionStrategy: sage: from sage.rings.polynomial.symmetric_reduction import SymmetricReductionStrategy sage: X. = InfinitePolynomialRing(QQ) - sage: S = SymmetricReductionStrategy(X, [y[2]^2*y[1],y[1]^2*y[2]], tailreduce=True) + sage: S = SymmetricReductionStrategy(X, [y[2]^2*y[1], y[1]^2*y[2]], tailreduce=True) sage: S # indirect doctest Symmetric Reduction Strategy in Infinite polynomial ring in x, y over Rational Field, modulo y_2*y_1^2, diff --git a/src/sage/rings/polynomial/term_order.py b/src/sage/rings/polynomial/term_order.py index 92cd909fab3..cd0238eceb9 100644 --- a/src/sage/rings/polynomial/term_order.py +++ b/src/sage/rings/polynomial/term_order.py @@ -313,7 +313,7 @@ :: - sage: P. = PolynomialRing(QQ, 6,order='degrevlex(4),neglex(2)') + sage: P. = PolynomialRing(QQ, 6, order='degrevlex(4),neglex(2)') sage: a > c^4 False sage: a > e^4 @@ -341,7 +341,7 @@ Traceback (most recent call last): ... ValueError: unknown term order 'royalorder' - sage: T = TermOrder("royalorder",force=True) + sage: T = TermOrder("royalorder", force=True) sage: T royalorder term order sage: T.singular_str() @@ -647,7 +647,7 @@ def __init__(self, name='lex', n=0, force=False): :trac:`12748`):: sage: T = TermOrder('degrevlex', 6) + TermOrder('degrevlex',10) - sage: R. = PolynomialRing(QQ,order=T) + sage: R. = PolynomialRing(QQ, order=T) Traceback (most recent call last): ... ValueError: the length of the given term order (16) differs from the number of variables (15) @@ -2170,8 +2170,8 @@ def termorder_from_singular(S): sage: termorder_from_singular(singular) # optional - sage.libs.singular Block term order with blocks: (Matrix term order with matrix - [1 2] - [3 0], + [1 2] + [3 0], Weighted degree reverse lexicographic term order with weights (2, 3), Lexicographic term order of length 2) diff --git a/src/sage/rings/polynomial/toy_buchberger.py b/src/sage/rings/polynomial/toy_buchberger.py index e01dada2479..c70cf1f90aa 100644 --- a/src/sage/rings/polynomial/toy_buchberger.py +++ b/src/sage/rings/polynomial/toy_buchberger.py @@ -384,8 +384,8 @@ def select(P): sage: from sage.rings.polynomial.toy_buchberger import select sage: R. = PolynomialRing(QQ, order='lex') - sage: ps = [x^3 - z -1, z^3 - y - 1, x^5 - y - 2] - sage: pairs = [[ps[i], ps[j]] for i in range(3) for j in range(i+1, 3)] + sage: ps = [x^3 - z - 1, z^3 - y - 1, x^5 - y - 2] + sage: pairs = [[ps[i], ps[j]] for i in range(3) for j in range(i + 1, 3)] sage: select(pairs) [x^3 - z - 1, -y + z^3 - 1] """ @@ -403,10 +403,10 @@ def inter_reduction(Q): OUTPUT: - if ``Q`` is the set `(f_1, ..., f_n)`, this method returns `(g_1, - ..., g_s)` such that: + if ``Q`` is the set `f_1, ..., f_n`, this method returns `g_1, + ..., g_s` such that: - - ` = ` + - `(f_1,...,f_n) = (g_1,...,g_s)` - `LM(g_i) \neq LM(g_j)` for all `i \neq j` - `LM(g_i)` does not divide `m` for all monomials `m` of `\{g_1,...,g_{i-1}, g_{i+1},...,g_s\}` @@ -422,7 +422,7 @@ def inter_reduction(Q): sage: P. = QQ[] sage: reduced = inter_reduction(set([x^2 - 5*y^2, x^3])) # optional - sage.libs.singular - sage: reduced == set([x*y^2, x^2-5*y^2]) # optional - sage.libs.singular + sage: reduced == set([x*y^2, x^2 - 5*y^2]) # optional - sage.libs.singular True sage: reduced == inter_reduction(set([2*(x^2 - 5*y^2), x^3])) # optional - sage.libs.singular True diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 3101ae239b9..660922aaf64 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -52,7 +52,7 @@ Another example. This one is from the Magma Handbook:: sage: P. = PolynomialRing(IntegerRing(), 3, order='lex') - sage: I = ideal( x^2 - 1, y^2 - 1, 2*x*y - z) + sage: I = ideal(x^2 - 1, y^2 - 1, 2*x*y - z) sage: I = Ideal(d_basis(I)) sage: x.reduce(I) x @@ -61,7 +61,7 @@ To compute modulo 4, we can add the generator 4 to our basis.:: - sage: I = ideal( x^2 - 1, y^2 - 1, 2*x*y - z, 4) + sage: I = ideal(x^2 - 1, y^2 - 1, 2*x*y - z, 4) sage: gb = d_basis(I) sage: R = P.change_ring(IntegerModRing(4)) sage: gb = [R(f) for f in gb if R(f)]; gb @@ -79,7 +79,7 @@ there are 4 equations in 3 unknowns). :: sage: P. = PolynomialRing(IntegerRing(), 3, order='degneglex') - sage: I = ideal( x^2 - 3*y, y^3 - x*y, z^3 - x, x^4 - y*z + 1 ) + sage: I = ideal(x^2 - 3*y, y^3 - x*y, z^3 - x, x^4 - y*z + 1) sage: I.change_ring(P.change_ring(RationalField())).groebner_basis() [1] @@ -96,19 +96,19 @@ sage: factor(282687803443) 101 * 103 * 27173681 - sage: I.change_ring( P.change_ring( GF(101) ) ).groebner_basis() + sage: I.change_ring(P.change_ring(GF(101))).groebner_basis() [z - 33, y + 48, x + 19] - sage: I.change_ring( P.change_ring( GF(103) ) ).groebner_basis() + sage: I.change_ring(P.change_ring(GF(103))).groebner_basis() [z - 18, y + 8, x + 39] - sage: I.change_ring( P.change_ring( GF(27173681) ) ).groebner_basis() + sage: I.change_ring( P.change_ring(GF(27173681))).groebner_basis() [z + 10380032, y + 3186055, x - 536027] Of course, modulo any other prime the Groebner basis is trivial so there are no other solutions. For example:: - sage: I.change_ring( P.change_ring( GF(3) ) ).groebner_basis() + sage: I.change_ring(P.change_ring(GF(3))).groebner_basis() [1] AUTHOR: diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 2be981c7ea0..08eda1849a0 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -1116,7 +1116,7 @@ cdef class Rational(sage.structure.element.FieldElement): def content(self, other): """ - Return the content of ``self`` and ``other``, i.e. the unique positive + Return the content of ``self`` and ``other``, i.e., the unique positive rational number `c` such that ``self/c`` and ``other/c`` are coprime integers. @@ -1193,7 +1193,7 @@ cdef class Rational(sage.structure.element.FieldElement): - ``p`` -- a prime number - ``prec`` (int) -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1230,7 +1230,7 @@ cdef class Rational(sage.structure.element.FieldElement): INPUT: - ``prec`` (int) -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1266,7 +1266,7 @@ cdef class Rational(sage.structure.element.FieldElement): INPUT: - ``prec`` (int) -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1309,7 +1309,7 @@ cdef class Rational(sage.structure.element.FieldElement): INPUT: - ``prec`` (int) -- desired floating point precision (default: - default RealField precision). + default :class:`RealField` precision). OUTPUT: @@ -1404,11 +1404,11 @@ cdef class Rational(sage.structure.element.FieldElement): INPUT: - - ``L`` -- a number field - - ``element`` -- (default: ``False``) boolean whether to also output - an element of which ``self`` is a norm - - proof -- If ``True``, then the output is correct unconditionally. - If ``False``, then the output assumes GRH. + - ``L`` -- a number field + - ``element`` -- (default: ``False``) boolean whether to also output + an element of which ``self`` is a norm + - ``proof`` -- If ``True``, then the output is correct unconditionally. + If ``False``, then the output assumes GRH. OUTPUT: @@ -1420,7 +1420,7 @@ cdef class Rational(sage.structure.element.FieldElement): ALGORITHM: - Uses PARI's bnfisnorm. See ``_bnfisnorm()``. + Uses the PARI function :pari:`bnfisnorm`. See :meth:`_bnfisnorm()`. EXAMPLES:: @@ -1612,9 +1612,9 @@ cdef class Rational(sage.structure.element.FieldElement): This test makes sure we workaround a bug in GMP (see :trac:`4612`):: - sage: [ -a for a in srange(100) if not QQ(-a^3).is_perfect_power() ] + sage: [-a for a in srange(100) if not QQ(-a^3).is_perfect_power()] [] - sage: [ -a for a in srange(100) if not QQ(-a^3).is_perfect_power(True) ] + sage: [-a for a in srange(100) if not QQ(-a^3).is_perfect_power(True)] [] """ cdef int s @@ -2971,7 +2971,7 @@ cdef class Rational(sage.structure.element.FieldElement): def numerator(self): """ Return the numerator of this rational number. - numer is an alias of numerator. + ``numer`` is an alias of ``numerator``. EXAMPLES:: @@ -3021,7 +3021,7 @@ cdef class Rational(sage.structure.element.FieldElement): def denominator(self): """ Return the denominator of this rational number. - denom is an alias of denominator. + ``denom`` is an alias of ``denominator``. EXAMPLES:: @@ -3344,7 +3344,7 @@ cdef class Rational(sage.structure.element.FieldElement): def round(Rational self, mode="away"): """ Return the nearest integer to ``self``, rounding away from 0 by - default, for consistency with the builtin Python round. + default, for consistency with the builtin Python :func:`round`. INPUT: @@ -3557,7 +3557,7 @@ cdef class Rational(sage.structure.element.FieldElement): def is_integral(self): r""" - Determine if a rational number is integral (i.e is in + Determine if a rational number is integral (i.e., is in `\ZZ`). OUTPUT: bool diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index a76e648f6db..5ef6b7522a0 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -11,7 +11,7 @@ Rational Field Values of various types can be converted to rational numbers by using the -``__call__`` method of ``RationalField`` (that is, by treating ``QQ`` as a +:meth:`__call__` method of :class:`RationalField` (that is, by treating ``QQ`` as a function). :: @@ -304,7 +304,7 @@ def __len__(self): def construction(self): r""" - Returns a pair ``(functor, parent)`` such that ``functor(parent)`` + Return a pair ``(functor, parent)`` such that ``functor(parent)`` returns ``self``. This is the construction of `\QQ` as the fraction field of `\ZZ`. @@ -460,7 +460,7 @@ def range_by_height(self, start, end=None): Returns a Python generator for the list of rational numbers with heights in ``range(start, end)``. Follows the same - convention as Python range, see ``range?`` for details. + convention as Python :func:`range`, type ``range?`` for details. See also ``__iter__()``. @@ -741,7 +741,7 @@ def residue_field(self, p, check=True): def hilbert_symbol_negative_at_S(self, S, b, check=True): r""" - Returns an integer that has a negative Hilbert symbol with respect + Return an integer that has a negative Hilbert symbol with respect to a given rational number and a given set of primes (or places). The function is algorithm 3.4.1 in [Kir2016]_. It finds an integer `a` @@ -915,7 +915,7 @@ def phi(x): def gens(self): r""" - Return a tuple of generators of `\QQ` which is only ``(1,)``. + Return a tuple of generators of `\QQ`, which is only ``(1,)``. EXAMPLES:: @@ -928,7 +928,7 @@ def gen(self, n=0): r""" Return the ``n``-th generator of `\QQ`. - There is only the 0-th generator which is 1. + There is only the 0-th generator, which is 1. EXAMPLES:: @@ -942,7 +942,7 @@ def gen(self, n=0): def degree(self): r""" - Return the degree of `\QQ` which is 1. + Return the degree of `\QQ`, which is 1. EXAMPLES:: @@ -953,7 +953,7 @@ def degree(self): def absolute_degree(self): r""" - Return the absolute degree of `\QQ` which is 1. + Return the absolute degree of `\QQ`, which is 1. EXAMPLES:: @@ -964,7 +964,7 @@ def absolute_degree(self): def ngens(self): r""" - Return the number of generators of `\QQ` which is 1. + Return the number of generators of `\QQ`, which is 1. EXAMPLES:: @@ -1087,7 +1087,7 @@ def algebraic_closure(self): def order(self): r""" - Return the order of `\QQ` which is `\infty`. + Return the order of `\QQ`, which is `\infty`. EXAMPLES:: diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index 235446af376..7e19380441e 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -140,7 +140,7 @@ def two_squares_pyx(uint32_t n): .. SEEALSO:: - :func:`~sage.arith.all.two_squares` is much more suited for large inputs + :func:`~sage.arith.misc.two_squares` is much more suited for large inputs EXAMPLES:: @@ -278,7 +278,7 @@ def four_squares_pyx(uint32_t n): .. SEEALSO:: - :func:`~sage.arith.all.four_squares` is much more suited for large input + :func:`~sage.arith.misc.four_squares` is much more suited for large input EXAMPLES:: diff --git a/src/sage/sets/set_from_iterator.py b/src/sage/sets/set_from_iterator.py index a99a559b691..fbbbbe4c9a0 100644 --- a/src/sage/sets/set_from_iterator.py +++ b/src/sage/sets/set_from_iterator.py @@ -460,7 +460,7 @@ def _instancedoc_(self): sage: print(sage_getdoc(d)) # indirect doctest Test whether "self" is prime. ... - Calls the PARI "isprime" function. + Calls the PARI ...isprime... """ # Duplicates sage.misc.cachefunc.CachedFunction._instancedoc_ from sage.misc.sageinspect import sage_getsourcelines, sage_getfile_relative, _extract_embedded_position