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