ZeroDivisionError and segmentation fault when subtracting rational functions

asked 0 years ago

D.W. gravatar image

I have been running into an error when trying to subtract two rational functions from one another, when the base ring is itself a field of rational functions. A short Sage example where this error occurs is the following:

R.<y1, y2, v_0> = PolynomialRing(QQ)

S.<r_0, r_1> = PolynomialRing(R)

f = ((-6*y1^2*y2^2 + 6*y1^2*y2*v_0 + 15*y1^2*y2 + 6*y1^2*v_0^2 - 24*y1*y2*v_0^2 - 12*v_0^4)/(2*y1^3*y2 + 2*y1^2*v_0^2)*r_0^2 + (6*y1^2*y2^2 - 15*y1^2*y2 - 6*y1^2*v_0^2 + 24*y1*y2*v_0^2 + 12*v_0^4)/(y1^3*y2 + y1^2*v_0^2)*r_0 + (-6*y1^2*y2^2 + 6*y1^2*y2*v_0 + 15*y1^2*y2 + 6*y1^2*v_0^2 - 24*y1*y2*v_0^2 - 12*v_0^4)/(2*y1^3*y2 + 2*y1^2*v_0^2))/(r_0^2 - 2*r_0 + 1)

g = ((-3*y1^2*y2 - 3*y1*y2^2 + 3*y1*y2*v_0 + 15*y1*y2 - 6*y2*v_0^2)/(y1^2*y2 + y1*v_0^2)*r_0^2 + (6*y1^2*y2 + 6*y1*y2^2 - 30*y1*y2 + 12*y2*v_0^2)/(y1^2*y2 + y1*v_0^2)*r_0 + (-3*y1^2*y2 - 3*y1*y2^2 + 3*y1*y2*v_0 + 15*y1*y2 - 6*y2*v_0^2)/(y1^2*y2 + y1*v_0^2))/(r_0^2 - 2*r_0 + 1)

f - g

The output is a ZeroDivisionError. Moreover, attempting certain further computations (for example 1/f - 1/g) causes a segmentation fault.

I guess the problem is somehow due to the way that fg simplifies.

Remark: The problem disappears either by "flattening" the polynomial ring to R.<y1,y2,v_0,r_0,r_1> = PolynomialRing(QQ), or by observing that f and g are independent of r1 and making S a univariate polynomial ring.

Preview: (hide)

Comments

Please report the issue at https://github.com/sagemath/sage/issues

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )
1

I reported this as suggested.

D.W. gravatar imageD.W. ( 0 years ago )
1

Thanks! Direct link just for the record: https://github.com/sagemath/sage/issu...

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )