Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
> > > var('x') > R=LaurentPolynomialRing(QQ,'x') > R(1+1/x) > > That is the interface that makes sense to me. That is, enable conversion. So, would it make sense to enable it by a `convert_method_name` ? -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Thursday, May 12, 2016 at 4:56:54 AM UTC-7, Ralf Stephan wrote: > > On Thu, May 12, 2016 at 10:48 AM mmarco > > wrote: > >> But even if we implement expression.laurent_polynomial(), it wouldn't >> automatically allow conversion from SR to LaurentPolynomialRing, would it? >> > > Right, it's conversion on demand. > The thing that should probably be and probably is in place is: var('x') R=LaurentPolynomialRing(QQ,'x') R(1+1/x) That way the user knows exactly what to expect. The interface that .laurent_polynomial(QQ) would implement would be more of the type "convert into a laurent polynomial in some suitable ring". That's very prone to unpredictable results, e.g.: var('x,y') (1/x+1/y).laurent_polynomial() (1/x+1/y-1/y).laurent_polynomial() ( (x+y)/(x*y) -1/y ).laurent_polynomial() so I would be hesitant to offer the routine in the first place. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Thu, May 12, 2016 at 10:48 AM mmarco wrote: > But even if we implement expression.laurent_polynomial(), it wouldn't > automatically allow conversion from SR to LaurentPolynomialRing, would it? > Right, it's conversion on demand. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
But even if we implement expression.laurent_polynomial(), it wouldn't automatically allow conversion from SR to LaurentPolynomialRing, would it? We would need to populate the conversion list somehow. El jueves, 12 de mayo de 2016, 5:33:50 (UTC+2), Ralf Stephan escribió: > > Then making it Expression.laurent_polynomial() but allowing > polynomial with ring=LaurentPolyRing as argument seems to be > the best interface. > > On Wed, May 11, 2016, 22:26 Nils Bruin > > wrote: > >> On Tuesday, May 10, 2016 at 10:55:20 PM UTC-7, Ralf Stephan wrote: >>> >>> On Tuesday, May 10, 2016 at 10:48:10 PM UTC+2, mmarco wrote: Thanks for the answer. So you propose that Expression.polynomial() should return either a polynomial or a laurent polynomial depending on the expression? >>> >>> Depending on expression and ring argument: >>> >> >> >> I think people missed the double definition of `x`, particularly because >> the reassignment of `x` gets hidden by doing in the RHS of an assignment. >> To be clearer: >> >> >>> >>> sage: R = PolynomialRing(QQ,'x') #to avoid confusion about what x is >>> sage: S = LaurentPolynomialRing(QQ, 'y') >>> sage: var('x,y,z') >>> >> sage: parent((z).polynomial(QQ)) >>> Univariate Polynomial Ring in z over Rational Field >>> sage: parent((1/z+z).polynomial(QQ)) >>> Univariate Laurent Polynomial Ring in z over Rational Field >>> >> >> I would say this is an error, because 1/z+z is not a polynomial over QQ >> in most normal senses of the word. Where would you stop? what would >> >> (1/(z+1) + z).polynomial(QQ) >> >> do? Will that return an answer in QQ[z,U]/((z+1)*U-1) ? >> >> I know that in symbolics you have to read off return types from >> properties of the input, not just from its type, but I think this going a >> little too far. "SR.polynomial(...)" should return polynomials in variables >> that are algebraically independent over the base ring. So no laurent >> polynomials. >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "sage-devel" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/sage-devel/WjH8mbsDg2Y/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> sage-devel+...@googlegroups.com . >> To post to this group, send email to sage-...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/sage-devel. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
Then making it Expression.laurent_polynomial() but allowing polynomial with ring=LaurentPolyRing as argument seems to be the best interface. On Wed, May 11, 2016, 22:26 Nils Bruin wrote: > On Tuesday, May 10, 2016 at 10:55:20 PM UTC-7, Ralf Stephan wrote: >> >> On Tuesday, May 10, 2016 at 10:48:10 PM UTC+2, mmarco wrote: >>> >>> Thanks for the answer. So you propose that Expression.polynomial() >>> should return either a polynomial or a laurent polynomial depending on the >>> expression? >>> >> >> Depending on expression and ring argument: >> > > > I think people missed the double definition of `x`, particularly because > the reassignment of `x` gets hidden by doing in the RHS of an assignment. > To be clearer: > > >> >> sage: R = PolynomialRing(QQ,'x') #to avoid confusion about what x is >> sage: S = LaurentPolynomialRing(QQ, 'y') >> sage: var('x,y,z') >> > sage: parent((z).polynomial(QQ)) >> Univariate Polynomial Ring in z over Rational Field >> sage: parent((1/z+z).polynomial(QQ)) >> Univariate Laurent Polynomial Ring in z over Rational Field >> > > I would say this is an error, because 1/z+z is not a polynomial over QQ in > most normal senses of the word. Where would you stop? what would > > (1/(z+1) + z).polynomial(QQ) > > do? Will that return an answer in QQ[z,U]/((z+1)*U-1) ? > > I know that in symbolics you have to read off return types from properties > of the input, not just from its type, but I think this going a little too > far. "SR.polynomial(...)" should return polynomials in variables that are > algebraically independent over the base ring. So no laurent polynomials. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sage-devel" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sage-devel/WjH8mbsDg2Y/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Tuesday, May 10, 2016 at 10:55:20 PM UTC-7, Ralf Stephan wrote: > > On Tuesday, May 10, 2016 at 10:48:10 PM UTC+2, mmarco wrote: >> >> Thanks for the answer. So you propose that Expression.polynomial() should >> return either a polynomial or a laurent polynomial depending on the >> expression? >> > > Depending on expression and ring argument: > I think people missed the double definition of `x`, particularly because the reassignment of `x` gets hidden by doing in the RHS of an assignment. To be clearer: > > sage: R = PolynomialRing(QQ,'x') #to avoid confusion about what x is > sage: S = LaurentPolynomialRing(QQ, 'y') > sage: var('x,y,z') > sage: parent((z).polynomial(QQ)) > Univariate Polynomial Ring in z over Rational Field > sage: parent((1/z+z).polynomial(QQ)) > Univariate Laurent Polynomial Ring in z over Rational Field > I would say this is an error, because 1/z+z is not a polynomial over QQ in most normal senses of the word. Where would you stop? what would (1/(z+1) + z).polynomial(QQ) do? Will that return an answer in QQ[z,U]/((z+1)*U-1) ? I know that in symbolics you have to read off return types from properties of the input, not just from its type, but I think this going a little too far. "SR.polynomial(...)" should return polynomials in variables that are algebraically independent over the base ring. So no laurent polynomials. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
>> sage: R. = PolynomialRing(QQ) >> sage: (x + 1/x).parent() >> Fraction Field of Univariate Polynomial Ring in x over Rational Field > > Is it really expected by all users (I see a sum, > not a fraction)? I thought algebraists don't touch > symbolics with a long stick... I would certainly yes! If f is in k[x] then I expect Sage to accept 1/f as the respective element in k(x). It would be annoying to have to convert explicitly (though, admittedly, the magic coercion sometimes causes computation being done in k(x) by mistake). And of course, adding an element in k(x) with one from k[x] gives something in k(x) without warning. Best, Johan -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Wednesday, May 11, 2016 at 2:21:45 PM UTC+2, vdelecroix wrote: > On 11/05/16 00:55, Ralf Stephan wrote: > > sage: parent((z).polynomial(QQ)) > > Univariate Polynomial Ring in z over Rational Field > > sage: parent((1/z+z).polynomial(QQ)) > > Univariate Laurent Polynomial Ring in z over Rational Field > > This behavior would not fit well with > > sage: R. = PolynomialRing(QQ) > sage: (x + 1/x).parent() > Fraction Field of Univariate Polynomial Ring in x over Rational Field Is it really expected by all users (I see a sum, not a fraction)? I thought algebraists don't touch symbolics with a long stick... -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On 11/05/16 00:55, Ralf Stephan wrote: sage: parent((z).polynomial(QQ)) Univariate Polynomial Ring in z over Rational Field sage: parent((1/z+z).polynomial(QQ)) Univariate Laurent Polynomial Ring in z over Rational Field This behavior would not fit well with sage: R. = PolynomialRing(QQ) sage: (x + 1/x).parent() Fraction Field of Univariate Polynomial Ring in x over Rational Field -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Tuesday, May 10, 2016 at 10:48:10 PM UTC+2, mmarco wrote: > > Thanks for the answer. So you propose that Expression.polynomial() should > return either a polynomial or a laurent polynomial depending on the > expression? > Depending on expression and ring argument: sage: R. = QQ[] sage: S = LaurentPolynomialRing(QQ, 'y') sage: _ = var('x,y,z') sage: parent((z).polynomial(QQ)) Univariate Polynomial Ring in z over Rational Field sage: parent((1/z+z).polynomial(QQ)) Univariate Laurent Polynomial Ring in z over Rational Field sage: parent((x).polynomial(ring=R)) Univariate Polynomial Ring in x over Rational Field sage: parent((y).polynomial(ring=R)) TypeError: z is not a variable of... sage: parent((y).polynomial(ring=S)) Univariate Laurent Polynomial Ring in y over Rational Field sage: parent((1/y+y).polynomial(ring=S)) Univariate Laurent Polynomial Ring in y over Rational Field -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
Thanks for the answer. So you propose that Expression.polynomial() should return either a polynomial or a laurent polynomial depending on the expression? El martes, 10 de mayo de 2016, 20:35:24 (UTC+2), Ralf Stephan escribió: > > On Monday, May 9, 2016 at 2:40:02 PM UTC+2, mmarco wrote: > > Right now Sage can convert seamlessly between polynomial rings and > symbolic ring. I am trying to extend this ability to Laurent polynomial > rings. > > > > > > I have already worked out the conversion to symbolic ring, by defining a > method called _symbolic_ in the LaurentPolynomial classes. But now I am not > sure which whould be the right way to proceed. I have considered the > following options: > > > > > > 1) Modifying the LaurentPolynomialRing to declare a convert_method_name > during creation, and then implement this convert method in symbolic > expressions. > > > > > > 2) Modify the element constructor of LaurentPolynomials to check if the > input is a symbolic expression and then try to construct the polynomial > from it. > > > > > > Which is the recommended one? > > I am not sure if either is necessary. My first attempt would > be to change Expression.polynomial() to catch all relevant > cases, shift right, convert to normal polynomial, convert that > to a Laurent polynomial, and finally shift left. > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: How to implement conversion between LaurentPolynomial and Symbolic rings?
On Monday, May 9, 2016 at 2:40:02 PM UTC+2, mmarco wrote: > Right now Sage can convert seamlessly between polynomial rings and symbolic > ring. I am trying to extend this ability to Laurent polynomial rings. > > > I have already worked out the conversion to symbolic ring, by defining a > method called _symbolic_ in the LaurentPolynomial classes. But now I am not > sure which whould be the right way to proceed. I have considered the > following options: > > > 1) Modifying the LaurentPolynomialRing to declare a convert_method_name > during creation, and then implement this convert method in symbolic > expressions. > > > 2) Modify the element constructor of LaurentPolynomials to check if the input > is a symbolic expression and then try to construct the polynomial from it. > > > Which is the recommended one? I am not sure if either is necessary. My first attempt would be to change Expression.polynomial() to catch all relevant cases, shift right, convert to normal polynomial, convert that to a Laurent polynomial, and finally shift left. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.