# Simplifying rational expressions

I am working with a power series with coefficients being rational functions of several variables (everything over QQ). Is there any way to make sage automatically simplify the coefficients?

Here is an example of what is going on

k=RR.zero()+(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)

print k

print u

print u-k

print (simplify(u))

print u

print parent(u)

print parent(k)

print factor(u.numerator())/factor(u.denominator())

And results:

(1/2*x^2 + x*y + 1/2*y^2 - 1/2*x*z - 1/2*y*z)/z^2

(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)

0

(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)

(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)

Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field

Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field

(-1/2) * z^-2 * (-x - y + z) * (x + y)

You should rather use ZZ than QQ, namely

Welcome to Ask Sage!

To display inline code, use backticks. To display blocks of code or error messages, separate them by a blank line from the rest of the text, and indent them with 4 spaces, or select code lines and click the "code" button (the icon with '101 010').

For instance, typing

will produce:

Can you edit your question to do that?