On Mar 6, 2008, at 11:20 AM, David 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 following may help explain the issue:

sage: v = 6/7
sage: type(v)
<type 'sage.rings.rational.Rational'>
sage: type(7*v)
<type 'sage.rings.rational.Rational'>

Just "clearing denominators" doesn't change the ring to which the  
elements belong.  All you did was produce a rational polynomial whose  
coefficients all have denominator 1 :-}

Sage makes a distinction between "ZZ" (integers) and  
"QQ" (rationals).  Even though "QQ" contains "ZZ" (at some level),  
Sage doesn't always switch from one ring to a larger or smaller ring  
(or homomorphic image, more generally).  There are rules for when and  
how this is done (search for coercion on this or the sage-devel lists  
for the seamy underbelly of this subject :-}), but these only apply  
when "combining" elements from different "parents".

You can do something like this, if you need to.

sage: Zx.<x>=PolynomialRing(ZZ)
sage: Qx.<x>=PolynomialRing(QQ)
sage: f=x-v
sage: type(f)
<class  
'sage.rings.polynomial.polynomial_element_generic.Polynomial_rational_de 
nse'>
sage: type(7*f)
<class  
'sage.rings.polynomial.polynomial_element_generic.Polynomial_rational_de 
nse'>
sage: g=Zx(7*f)
sage: g
7*x - 6
sage: type(g)
<type  
'sage.rings.polynomial.polynomial_integer_dense_ntl.Polynomial_integer_d 
ense_ntl'>

HTH

Justin

--
Justin C. Walker, Curmudgeon-at-Large
() The ASCII Ribbon Campaign
/\ Help Cure HTML Email




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to