On Friday, June 12, 2015 at 11:17:37 AM UTC+2, Néstor wrote:
> Hello,
>
> I've got a rational expression in sage and I would like to convert it to a
> polynomial with coefficients in some fraction field.
>
> More precisely, I've got something like this:
>
> a , x = var( 'a , x' ) ;
> P = x/a ;
>
> and I would like to see it like a polynomial in the polynomial ring in the
> variable x with coefficients on the fraction field Q(a) of rational
> expressions in the variable a:
>
> C.<a> = PolynomialRing(QQ) ;
> B = FractionField(C) ;
> A.<x> = PolynomialRing(B) ;
>
> But when I try
>
> P.polynomial(A)
>
> I get the following error
>
> TypeError: unable to coerce since the denominator is not 1
>
>
try
sage: A(P)
1/a*x
sage: _.parent()
Univariate Polynomial Ring in x over Fraction Field of Univariate
Polynomial Ring in a over Rational Field
Sometimes, when Sage is not smart enough to perform a conversion between
complicated rings, I where able to perform the conversion with the ugly
hack:
sage: A(str(P))
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.