Processing math: 100%
Ask Your Question
2

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 )

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

slelievre gravatar image

The reported bug can be reproduced in conda-installed Sage 10.5 on Linux Mint.

Simpler trigger:

sage: R = PolynomialRing(QQ, 'x')
sage: R.inject_variables(verbose=False)
sage: S = PolynomialRing(R, 'u, v')
sage: S.inject_variables(verbose=False)
sage: d = u - 1
sage: f =  1 / x * d
sage: f / d
Traceback (most recent call last):
...
ZeroDivisionError: fraction field element division by zero
Preview: (hide)
link

Comments

FWIW, after running the previous example minus the last line :

sage: f.factor()/d
1/x

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 0 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 0 years ago

Seen: 101 times

Last updated: Apr 10