Polynomial Interfaces to Singular

AUTHORS:

TESTS:

sage: R = PolynomialRing(GF(2**8,'a'),10,'x', order='invlex')
sage: R == loads(dumps(R))
True
sage: P.<a,b> = PolynomialRing(GF(7), 2)
sage: f = (a^3 + 2*b^2*a)^7; f
a^21 + 2*a^7*b^14
class sage.rings.polynomial.polynomial_singular_interface.PolynomialRing_singular_repr

Implements methods to convert polynomial rings to Singular.

This class is a base class for all univariate and multivariate polynomial rings which support conversion from and to Singular rings.

_singular_(singular=Singular)

Returns a singular ring for this polynomial ring. Currently \QQ, {\rm GF}(p), {\rm GF}(p^n), \CC, \RR, \ZZ and \ZZ/n\ZZ are supported.

INPUT:

  • singular - Singular instance

OUTPUT: Singular ring matching this ring

EXAMPLES:

sage: R.<x,y> = PolynomialRing(CC,'x',2)
sage: singular(R)
//   characteristic : 0 (complex:15 digits, additional 0 digits)
//   1 parameter    : I
//   minpoly        : (I^2+1)
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C
sage: R.<x,y> = PolynomialRing(RealField(100),'x',2)
sage: singular(R)
//   characteristic : 0 (real:29 digits, additional 0 digits)
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C

sage: w = var('w')
sage: R.<x> = PolynomialRing(NumberField(w^2+1,'s'))
sage: singular(R)
//   characteristic : 0
//   1 parameter    : s
//   minpoly        : (s^2+1)
//   number of vars : 1
//        block   1 : ordering lp
//                  : names    x
//        block   2 : ordering C

sage: R = PolynomialRing(GF(127),1,'x')
sage: singular(R)
//   characteristic : 127
//   number of vars : 1
//        block   1 : ordering lp
//                  : names    x
//        block   2 : ordering C

sage: R = PolynomialRing(QQ,1,'x')
sage: singular(R)
//   characteristic : 0
//   number of vars : 1
//        block   1 : ordering lp
//                  : names    x
//        block   2 : ordering C

sage: R = PolynomialRing(QQ,'x')
sage: singular(R)
//   characteristic : 0
//   number of vars : 1
//        block   1 : ordering lp
//                  : names    x
//        block   2 : ordering C

sage: R = PolynomialRing(GF(127),'x')
sage: singular(R)
//   characteristic : 127
//   number of vars : 1
//        block   1 : ordering lp
//                  : names    x
//        block   2 : ordering C

sage: R = Frac(ZZ['a,b'])['x,y']
sage: singular(R)
//   characteristic : 0
//   2 parameter    : a b 
//   minpoly        : 0
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y 
//        block   2 : ordering C


sage: R = IntegerModRing(1024)['x,y']
sage: singular(R)
//   coeff. ring is : Z/2^10
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C

sage: R = IntegerModRing(15)['x,y']
sage: singular(R)
//   coeff. ring is : Z/15
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C

sage: R = ZZ['x,y']
sage: singular(R)
//   coeff. ring is : Integers
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C

Warning

  • If the base ring is a finite extension field or a number field the ring will not only be returned but also be set as the current ring in Singular.
  • Singular represents precision of floating point numbers base 10 while Sage represents floating point precision base 2.
_singular_init_(singular=Singular)
Return a newly created Singular ring matching this ring.
class sage.rings.polynomial.polynomial_singular_interface.Polynomial_singular_repr

Implements coercion of polynomials to Singular polynomials.

This class is a base class for all (univariate and multivariate) polynomial classes which support conversion from and to Singular polynomials.

Due to the incompatibility of Python extension classes and multiple inheritance, this just defers to module-level functions.

_singular_(singular=Singular, have_ring=False)
_singular_init_func(singular=Singular, have_ring=False)
lcm(singular=Singular, have_ring=False)
resultant(other, variable=None)
sage.rings.polynomial.polynomial_singular_interface._singular_func(self, singular=Singular, have_ring=False)

Return Singular polynomial matching this polynomial.

INPUT:

  • singular - Singular instance to use.
  • have_ring - if True we will not attempt to set this element’s ring as the current Singular ring. This is useful to speed up a batch of f._singular_() calls. However, it’s dangerous as it might lead to wrong results if another ring is singular.current_ring(). (Default: False)

EXAMPLES:

sage: P.<a,b> = PolynomialRing(GF(7), 2)
sage: f = (a^3 + 2*b^2*a)^7; f
a^21 + 2*a^7*b^14
sage: h = f._singular_(); h
a^21+2*a^7*b^14
sage: P(h)
a^21 + 2*a^7*b^14
sage: P(h^20) == f^20
True

sage: R.<x> = PolynomialRing(GF(7))
sage: f = (x^3 + 2*x^2*x)^7
sage: f
3*x^21
sage: h = f._singular_(); h
3*x^21
sage: R(h)
3*x^21
sage: R(h^20) == f^20
True
sage.rings.polynomial.polynomial_singular_interface._singular_init_func(self, singular=Singular, have_ring=False)

Return corresponding Singular polynomial but enforce that a new instance is created in the Singular interpreter.

Use self._singular_() instead.

sage.rings.polynomial.polynomial_singular_interface.can_convert_to_singular(R)

Returns True if this ring’s base field or ring can be represented in Singular, and the polynomial ring has at least one generator. If this is True then this polynomial ring can be represented in Singular.

The following base rings are supported: finite fields, rationals, number fields, and real and complex fields.

EXAMPLES:

sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
sage: can_convert_to_singular(PolynomialRing(QQ, names=['x']))
True

sage: can_convert_to_singular(PolynomialRing(QQ, names=[]))
False
sage.rings.polynomial.polynomial_singular_interface.lcm_func(self, right, have_ring=False)

Returns the least common multiple of this element and the right element.

INPUT:

  • right - multivariate polynomial
  • have_ring - see self._singular_(). (Default:False)

OUTPUT: multivariate polynomial representing the least common multiple of self and right

ALGORITHM: Singular

EXAMPLES:

sage: r.<x,y> = PolynomialRing(GF(2**8,'a'),2)
sage: a = r.base_ring().0
sage: f = (a^2+a)*x^2*y + (a^4+a^3+a)*y + a^5
sage: f.lcm(x^4)
(a^2 + a)*x^6*y + (a^4 + a^3 + a)*x^4*y + (a^5)*x^4

sage: w = var('w')
sage: r.<x,y> = PolynomialRing(NumberField(w^4+1,'a'),2)
sage: a = r.base_ring().0
sage: f = (a^2+a)*x^2*y + (a^4+a^3+a)*y + a^5
sage: f.lcm(x^4)
(a^2 + a)*x^6*y + (a^3 + a - 1)*x^4*y + (-a)*x^4

TESTS:

sage: R.<X>=QQ[]
sage: a=R(1)
sage: b=X
sage: lcm(b,a)
X
sage: lcm(a,b)
X
sage.rings.polynomial.polynomial_singular_interface.resultant_func(self, other, variable=None)

computes the resultant of self and the first argument with respect to the variable given as the second argument.

If a second argument is not provide the first variable of self.parent() is chosen.

INPUT:

  • other - polynomial in self.parent()
  • variable - optional variable (of type polynomial) in self.parent(). (Default: None)

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQ,2)
sage: a = x+y
sage: b = x^3-y^3
sage: c = a.resultant(b); c
-2*y^3
sage: d = a.resultant(b,y); d
2*x^3

TESTS:

sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain
sage: P.<x,y> = MPolynomialRing_polydict_domain(QQ,2,order='degrevlex')
sage: a = x+y
sage: b = x^3-y^3
sage: c = a.resultant(b); c
-2*y^3
sage: d = a.resultant(b,y); d
2*x^3

Previous topic

Dense univariate polynomials over \RR, implemented using MPFR

Next topic

Isolate Real Roots of Real Polynomials

This Page