Thank you Justin and Carl. Martin Albrecht came up with a solution: sage: Z.numerator().reduce(I2) 0
David On Mar 6, 6:32 pm, Carl Witty <[EMAIL PROTECTED]> wrote: > On Mar 6, 11:20 am, David <[EMAIL PROTECTED]> wrote: > > > I am trying to use the reduce() command on a rational pollynomial. I > > first clear the denominator by multiplying by the denominator but when > > I use reduce() I get an error. When I print out the polynomial it is > > no longer rational but SAGE doesn't like it. I would appriciate any > > advice. Below is an example script with ouput. Thank you. > > The resulting polynomial does not print as rational, but Sage still > considers it to be a rational polynomial with denominator 1. (You can > see this by printing parent(Z).) > > The general principle for this sort of situation in Sage is that you > should be able to get the polynomial you want by treating your ring as > a function and calling your rational polynomial; that is, I would > expect R1(Z) to give you your polynomial. Unfortunately, it doesn't; > I've reported this as a bug here:http://sagetrac.org/sage_trac/ticket/2411 > > Instead, there's a somewhat ugly workaround you can use: R1(str(Z)) > converts your polynomial to a string, then parses it again, giving you > a polynomial in the correct ring. And R1(str(Z)).reduce(I2) returns > 0. > > > > > > > Untitled > > system:sage > > > {{{id=0| > > R1 = PolynomialRing(RationalField(),9, > > ["x0","x1","x2","y0","y1","y2","a0","a1","a2"], "lex") > > x0,x1,x2,y0,y1,y2,a0,a1,a2=R1.gens() > > X=[ > > x0*y0 - x2*y1 + x1*y2, > > a2*y0 + a1*y1 - a0*y2, > > a1*x0 - a0*x1 - a2*x2 > > ] > > I=R1.ideal(X) > > I2 = I.groebner_basis() > > print X[2].reduce(I2) > > Y=X[2]/a1 > > Z=a1*Y > > print Z > > print Z.reduce(I2) > > /// > > > 0 > > > -x1*a0 + x0*a1 - x2*a2 > > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > File "/home/notebook/sage_notebook/worksheets/admin/61/code/3.py", > > line 17, in <module> > > exec compile(ur'print Z.reduce(I2)' + '\n', '', 'single') > > File "/usr/local/sage/data/extcode/sage/", line 1, in <module> > > > TypeError: reduce() takes exactly 1 argument (2 given) > > > }}} > > > {{{id=1| > > > }}} > > Carl- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---