"/" is the constructor for fraction field elements where reduce has a
different meaning (btw. FractionFieldElement.reduce is undocumented and might
be good doc day material). In that context it reduce means to interreduce the
denominator and the numerator.
Cheers,
Martin
--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: martinr...@jabber.ccc.de
>
> 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