On Nov 16, 12:28 pm, Niels <niels.lub...@gmail.com> wrote: > Hi, > > I would like to compute the gcd of two bi-variate polynomials over a number > field: > > sage: R = PolynomialRing( QQ, var( 't' ), order = 'lex' ) > sage: t = R.gens()[0] > sage: T = NumberFieldTower( [t ** 2 - t + 1], 'a0' ) > sage: a0 = T.gens()[0] > sage: R = R.change_ring( T ) > sage: > sage: P = PolynomialRing( T, var( 'x,y' ), order = 'lex' ) > sage: x, y = P.gens() > sage: > sage: gcd( [( a0 + 1 ) * x , ( a0 + 1 ) * x * y] ) > x > > # This should be ( a0 + 1 ) * x.
I disagree, the gcd of two polynomials is defined up to constant multiplication. Probably the answer is monic wrt the monomial order. > sage: > sage: t = R.gens()[0] > sage: T = NumberFieldTower( [ t ** 2 - a0], 'a1' ) > sage: a1 = T.gens()[0] > sage: > sage: P = PolynomialRing( T, var( 'x,y' ), order = 'lex' ) > sage: x, y = P.gens() > sage: > > # Computing the gcd in QQ(a0,a1)[x,y] gives problems. > # (btw qou_rem and divides also don't work over this ring) multivariate polynomials over towers of number fields are currently generic multivariate polynomials and there is no gcd implemented in Sage for multivariate polynomials over generic fields. Try to compute in this case a primitive element and pass to a simple extension so it will use Singular. > sage: gcd( [( a0 + 1 ) * x , ( a0 + 1 ) * x * y] ) > > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > /home/niels/<ipython console> in <module>() > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/rings/arith.pyc > in gcd(a, b, **kwargs) > 1434 if U is ZZ or U is int or U is long:# ZZ.has_coerce_map_from(U): > 1435 return sage.rings.integer.GCD_list(a) > -> 1436 return __GCD_sequence(seq, **kwargs) > 1437 > 1438 GCD = gcd > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/rings/arith.pyc > in __GCD_sequence(v, **kwargs) > 1476 one = v.universe()(1) > 1477 for vi in v: > -> 1478 g = vi.gcd(g, **kwargs) > 1479 if g == one: > 1480 return g > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/structure/element.so > in sage.structure.element.Element.__getattr__ > (sage/structure/element.c:2666)() > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/structure/parent.so > in sage.structure.parent.getattr_from_other_class > (sage/structure/parent.c:2840)() > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/structure/parent.so > in sage.structure.parent.raise_attribute_error > (sage/structure/parent.c:2638)() > > AttributeError: 'MPolynomial_polydict' object has no attribute 'gcd' > sage: > --------------------------------------------------------------------------- > > # giving 2 elements to gcd instead of a list, gives rise to different > exception > > sage: gcd( ( a0 + 1 ) * x , ( a0 + 1 ) * x * y ) > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > > /home/niels/<ipython console> in <module>() > > /home/niels/Desktop/n/app/sage/local/lib/python2.6/site-packages/sage/rings/arith.pyc > in gcd(a, b, **kwargs) > 1427 return ZZ(a).gcd(ZZ(b)) > 1428 except TypeError: > -> 1429 raise TypeError, "unable to find gcd of %s and > %s"%(a,b) > 1430 > 1431 from sage.structure.sequence import Sequence > > TypeError: unable to find gcd of (a0 + 1)*x and (a0 + 1)*x*y > sage: > --------------------------------------------------------------------------- > > Kind regards, > > Niels > > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org