Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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()+(-524288x^2 - 1048576xy - 524288y^2 + 524288xz + 524288yz)/(-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/2x^2 + xy + 1/2y^2 - 1/2xz - 1/2y*z)/z^2

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

0

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

(-524288x^2 - 1048576xy - 524288y^2 + 524288xz + 524288yz)/(-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)

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()+(-524288x^2

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

524288*y*z)/(-1048576*z^2) print k

k print u

u print u-k

u-k print (simplify(u))

(simplify(u)) print u

u print parent(u)

parent(u) print parent(k)

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

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

And results:

(1/2x^2

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

(-524288x^2 1/2*y*z)/z^2 (-524288*x^2 - 1048576xy 1048576*x*y - 524288y^2 524288*y^2 + 524288xz 524288*x*z + 524288yz)/(-1048576*z^2)

0

(-524288x^2 524288*y*z)/(-1048576*z^2) 0 (-524288*x^2 - 1048576xy 1048576*x*y - 524288y^2 524288*y^2 + 524288xz 524288*x*z + 524288yz)/(-1048576*z^2)

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

524288*y*z)/(-1048576*z^2) Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field

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

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

y)