Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pretty print factorizations as fractions

Hi all,

If I have an object whose factorization makes sense when expressed as a fraction, how do I get Sage to pretty print its factorization as a fraction instead of a product of factors? For example,

sage: R.<x> = PolynomialRing(QQ)
sage: f = (x - 1)^2 / (x + 1)
sage: f
(x^2 - 2*x + 1)/(x + 1)
sage: f.factor()
(x + 1)^-1 * (x - 1)^2

but ideally I would like some way to pretty print f as (x - 1)^2/(x + 1).

Thanks,

Henry