[sage-devel] Re: issue with division in fraction field of univ poly

2023-07-02 Thread 'Travis Scrimshaw' via sage-devel
When I first tried Ben's OP code, it worked as there. Then when trying 
Nil's code, I get the same output as Ben, but when I immediate after run

sage: D2 / D1
...Same traceback as above...
ZeroDivisionError: fraction field element division by zero

Now in a fresh Sage session, I immediately get the zero division error for 
D2 / D1, but then running Nil's code, I now get:

sage: Kp = parent(1/D1)
sage: r = Kp(D2)
sage: s = Kp(1/D1)
sage: r.numerator().gcd(s.denominator())
a*x^3 + (-a)*x^2*y + (-a^2 + 3*a - 1)*x*y^2 + (2*a^2 - 3*a + 1)*y^3
sage: r * s
ZeroDivisionError
sage: r.numerator().gcd(s.denominator())
0

So I think Nil's correctly identified the main symptom, but Ben's diagnosis 
is almost correct. It is not something being cached but an internal 
property being changed in some place where it believes it is safe to mutate 
it. I have created a new issue 
https://github.com/sagemath/sage/issues/35886 and put some additional 
observations.

Best,
Travis
On Wednesday, June 28, 2023 at 1:42:35 AM UTC+9 Ben Hutz wrote:

> I'm not getting 0 with that code:
>
> sage: K. = Frac(QQ['a'])
> sage: P. = ProjectiveSpace(K, 1)
> sage: D2=-x^5 + (-3*a^2 + 7*a - 2)/a*x^4*y + (6*a^2 - 12*a + 4)/a*x^3*y^2 
> + (3*a^4 - 19*a^3 + 29*a^2 - 14*a + 2)/(a^2)*x^2*y^3 + (-8*a^4 + 30*a^3 - 
> 37*a^2 + 18*a - 3)/(a^2)*x*y^4 + (4*a^4 - 12*a^3 + 13*a^2 - 6*a + 
> 1)/(a^2)*y^5
> sage: D1=-x^3 + x^2*y + (a^2 - 3*a + 1)/a*x*y^2 + (-2*a^2 + 3*a - 1)/a*y^3
>
> sage: K=parent(1/D2)
> sage: r=K(D1)
> sage: s=K(1/D2)
> sage: r.numerator().gcd(s.denominator())
> a*x^3 + (-a)*x^2*y + (-a^2 + 3*a - 1)*x*y^2 + (2*a^2 - 3*a + 1)*y^3 
>
>
> However, if I run 
> sage: K. = Frac(QQ['a'])
> sage: P. = ProjectiveSpace(K, 1)
> sage: f = x^2 + (a + 1/a - 3)*x*y - (2*a + 1/a - 3)*y^2
> sage: phi = DynamicalSystem_projective([f,x^2])
> sage: phi.dynatomic_polynomial(2)
> 0
>
> and *then* run the code I get zero.
>
> sage: K. = Frac(QQ['a'])
> sage: P. = ProjectiveSpace(K, 1)
> sage: D2=-x^5 + (-3*a^2 + 7*a - 2)/a*x^4*y + (6*a^2 - 12*a + 4)/a*x^3*y^2 
> + (3*a^4 - 19*a^3 + 29*a^2 - 14*a + 2)/(a^2)*x^2*y^3 + (-8*a^4 + 30*a^3 - 
> 37*a^2 + 18*a - 3)/(a^2)*x*y^4 + (4*a^4 - 12*a^3 + 13*a^2 - 6*a + 
> 1)/(a^2)*y^5
> sage: D1=-x^3 + x^2*y + (a^2 - 3*a + 1)/a*x*y^2 + (-2*a^2 + 3*a - 1)/a*y^3
>
> sage: K=parent(1/D2)
> sage: r=K(D1)
> sage: s=K(1/D2)
> sage: r.numerator().gcd(s.denominator()) 
> 0
>
>
> So I still find that weird. Is there something being oddly cached?
> On Monday, June 26, 2023 at 4:04:18 PM UTC-5 Nils Bruin wrote:
>
>> With your data, we get:
>>
>> sage: K=parent(1/D2)
>> sage: r=K(D1)
>> sage: s=K(1/D2)
>> sage: r.numerator().gcd(s.denominator())
>> 0
>>
>> and I think that's the zero which leads to the division-by-zero error. Of 
>> course, a 0 returned as gcd is just a bug. It doesn't look like the 
>> coercion framework is really involved here.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/111d5aa6-6a17-4acf-8576-e676db709192n%40googlegroups.com.


[sage-devel] Re: issue with division in fraction field of univ poly

2023-06-27 Thread Ben Hutz
I'm not getting 0 with that code:

sage: K. = Frac(QQ['a'])
sage: P. = ProjectiveSpace(K, 1)
sage: D2=-x^5 + (-3*a^2 + 7*a - 2)/a*x^4*y + (6*a^2 - 12*a + 4)/a*x^3*y^2 + 
(3*a^4 - 19*a^3 + 29*a^2 - 14*a + 2)/(a^2)*x^2*y^3 + (-8*a^4 + 30*a^3 - 
37*a^2 + 18*a - 3)/(a^2)*x*y^4 + (4*a^4 - 12*a^3 + 13*a^2 - 6*a + 
1)/(a^2)*y^5
sage: D1=-x^3 + x^2*y + (a^2 - 3*a + 1)/a*x*y^2 + (-2*a^2 + 3*a - 1)/a*y^3
sage: K=parent(1/D2)
sage: r=K(D1)
sage: s=K(1/D2)
sage: r.numerator().gcd(s.denominator())
a*x^3 + (-a)*x^2*y + (-a^2 + 3*a - 1)*x*y^2 + (2*a^2 - 3*a + 1)*y^3 


However, if I run 
sage: K. = Frac(QQ['a'])
sage: P. = ProjectiveSpace(K, 1)
sage: f = x^2 + (a + 1/a - 3)*x*y - (2*a + 1/a - 3)*y^2
sage: phi = DynamicalSystem_projective([f,x^2])
sage: phi.dynatomic_polynomial(2)
0

and *then* run the code I get zero.

sage: K. = Frac(QQ['a'])
sage: P. = ProjectiveSpace(K, 1)
sage: D2=-x^5 + (-3*a^2 + 7*a - 2)/a*x^4*y + (6*a^2 - 12*a + 4)/a*x^3*y^2 + 
(3*a^4 - 19*a^3 + 29*a^2 - 14*a + 2)/(a^2)*x^2*y^3 + (-8*a^4 + 30*a^3 - 
37*a^2 + 18*a - 3)/(a^2)*x*y^4 + (4*a^4 - 12*a^3 + 13*a^2 - 6*a + 
1)/(a^2)*y^5
sage: D1=-x^3 + x^2*y + (a^2 - 3*a + 1)/a*x*y^2 + (-2*a^2 + 3*a - 1)/a*y^3
sage: K=parent(1/D2)
sage: r=K(D1)
sage: s=K(1/D2)
sage: r.numerator().gcd(s.denominator()) 
0


So I still find that weird. Is there something being oddly cached?
On Monday, June 26, 2023 at 4:04:18 PM UTC-5 Nils Bruin wrote:

> With your data, we get:
>
> sage: K=parent(1/D2)
> sage: r=K(D1)
> sage: s=K(1/D2)
> sage: r.numerator().gcd(s.denominator())
> 0
>
> and I think that's the zero which leads to the division-by-zero error. Of 
> course, a 0 returned as gcd is just a bug. It doesn't look like the 
> coercion framework is really involved here.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/041e855b-0773-45f8-bd17-b7a5c4a03a12n%40googlegroups.com.


[sage-devel] Re: issue with division in fraction field of univ poly

2023-06-26 Thread Nils Bruin
With your data, we get:

sage: K=parent(1/D2)
sage: r=K(D1)
sage: s=K(1/D2)
sage: r.numerator().gcd(s.denominator())
0

and I think that's the zero which leads to the division-by-zero error. Of 
course, a 0 returned as gcd is just a bug. It doesn't look like the 
coercion framework is really involved here.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/57c8457c-311c-420f-855b-ad7b562ec427n%40googlegroups.com.