That sort of gets my expressions nicer. It doesn't quite solve the issue with the computation time but works for now.
Would it be too difficult to have such fractions normalized automatically to some normal form, e.g. monic denominator polynomial, if the coefficient ring is a field? Thanks, Stefan Am 24.01.2010 um 17:51 schrieb William Stein: > On Sun, Jan 24, 2010 at 3:45 PM, Yann <yannlaiglecha...@gmail.com> wrote: >> >> >> On Jan 24, 9:17 pm, William Stein <wst...@gmail.com> wrote: >>> >>> Here's a potentially good way to do this right now :-) >>> >>> Define this function: >>> >>> def normalize_denoms(f): >>> n, d = f.numerator(), f.denominator() >>> a = [vector(x.coefficients()).denominator() for x in [n,d]] >>> return (n*a[0])/(d*a[1]) >>> >>> Then: >>> >>> sage: R.<x,y>=PolynomialRing(QQ, 2) >>> sage: F=FractionField(R) >>> sage: f=(x/2)/(3*y/17) >>> sage: f >>> 1/2*x/(3/17*y) >>> sage: normalize_denoms(f) >>> x/(3*y) >> >> I guess you meant: >> >> sage: def normalize_denoms(f): >> n, d = f.numerator(), f.denominator() >> a = lcm([vector(x.coefficients()).denominator() for x in [n,d]]) >> return (n*a)/(d*a) >> >> We then obtain: >> >> sage: R.<x,y>=PolynomialRing(QQ, 2) >> sage: F=FractionField(R) >> sage: f=(x/2)/(3*y/17) >> sage: f >> 1/2*x/(3/17*y) >> sage: normalize_denoms(f) >> 17*x/(6*y) >> >> which seems to be a better result to me... > > Yes, of course. Thanks. I was getting rid of the denoms at the > expense of computing a different fraction! > > -- William > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org