Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

very serious infinite loop in coercion somewhere #365

Closed
williamstein opened this issue May 17, 2007 · 1 comment
Closed

very serious infinite loop in coercion somewhere #365

williamstein opened this issue May 17, 2007 · 1 comment

Comments

@williamstein
Copy link
Contributor

On 5/17/07, Prof. J. E. Cremona <john.cremona@nottingham.ac.uk> wrote:
> 
> Problem:  when executing the following, the last line takes forever and
> had to be killed:
> 
> R = PolynomialRing(QQ, ['a','b','c','d','e'], 5)
> K = R.fraction_field()
> a,b,c,d,e = K.gens()
> 
> ig = 12*a*e-3*b*d+c^2
> jg = 72*a*c*e+9*b*c*d-27*a*d^2-27*e*b^2-2*c^3
> hg = 8*a*c-3*b^2
> deltag = 4*ig^3-jg^2
> 
> Ky.<y> = PolynomialRing(K,'y')
> phipoly = y^3-3*ig*y+jg
> 
> What am I missing?

Nothing --  You have found a subtle bug in SAGE's coercion code.  
If you make the coercion that is going on in the last line very explicit,
then the above line works, e.g., this works (note that I've used some
more compact notation at the beginning, but it's equivalent to
what you wrote):

{{{
R.<a,b,c,d,e> = QQ[]
K = R.fraction_field()
a,b,c,d,e = K.gens()
ig = 12*a*e-3*b*d+c^2
jg = 72*a*c*e+9*b*c*d-27*a*d^2-27*e*b^2-2*c^3
hg = 8*a*c-3*b^2
deltag = 4*ig^3-jg^2
}}}

{{{
Ky.<y> = PolynomialRing(K,'y')
phipoly = y^3-3*ig*y+Ky([jg])
phipoly
///
y^3 + (-3*c^2 + 9*b*d - 36*a*e)*y + -2*c^3 + 9*b*c*d - 27*b^2*e - 27*a*d^2 + 72*a*c*e
}}}

The difference is that I put Ky([jg]) explicitly instead of jg.  

Whatever is causing this is a serious bug, and I hope somebody fixes
it soon (or that I do).  It's trac #

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/365

@williamstein
Copy link
Contributor Author

comment:1

This is fixed now. It was a problem in the __call__ method of polynomial ring.

@@ -156,6 +163,8 @@ class PolynomialRing_general(sage.algebr
         C = self.__polynomial_class
         if isinstance(x, C) and x.parent() is self:
             return x
+        elif is_Element(x) and x.parent() == self.base_ring():
+            return self([x])
         elif is_SingularElement(x) and self._has_singular:
             self._singular_().set_ring()
             try:

tobiasdiez pushed a commit to tobiasdiez/sage that referenced this issue Feb 22, 2024
Building such recipes requires conda-build >=3.20.5
See conda/grayskull#348
tobiasdiez pushed a commit to tobiasdiez/sage that referenced this issue Feb 22, 2024
* Revert "Use "compatible release" operator ~= (sagemath#365)"

This reverts commit ac33392.

* Fix "compatible release" operator

See sagemath#348

* Use dev0 instead of a0 as suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant