#13645: PolynomialRing variables are not generic symbolic variables
---------------------------------+------------------------------------------
       Reporter:  llpamies       |         Owner:  burcin      
           Type:  defect         |        Status:  needs_review
       Priority:  trivial        |     Milestone:  sage-5.4    
      Component:  symbolics      |    Resolution:              
       Keywords:                 |   Work issues:              
Report Upstream:  N/A            |     Reviewers:              
        Authors:  Burcin Erocal  |     Merged in:              
   Dependencies:                 |      Stopgaps:              
---------------------------------+------------------------------------------
Changes (by {'newvalue': u'Burcin Erocal', 'oldvalue': ''}):

  * priority:  major => trivial
  * reviewer:  Burcin Erocal =>
  * milestone:  sage-duplicate/invalid/wontfix => sage-5.4
  * author:  => Burcin Erocal


Old description:

> Consider the following Sage code:
>
> {{{
> sage: a,b=var('a,b')
> sage: solve([a+b+a*b == 1], a)
> [a == -(b - 1)/(b + 1)]
> }}}
>
> If I want to do something similar with elements of a PolynomialRing the
> code crashes:
> {{{
> sage: poly.<a,b> = PolynomialRing(RR)
> sage: solve([a+b+a*b == 1], a)
> }}}

New description:

 Consider the following Sage code:

 {{{
 sage: a,b=var('a,b')
 sage: solve([a+b+a*b == 1], a)
 [a == -(b - 1)/(b + 1)]
 }}}

 If I want to do something similar with elements of a PolynomialRing the
 code crashes:
 {{{
 sage: poly.<a,b> = PolynomialRing(RR)
 sage: solve([a+b+a*b == 1], a)
 }}}


 Apply: [attachment:trac_13645-solve_input_handling.patch]

--

Comment:

 OK. I attached a patch to fix the error message. Now we have:

 {{{
 sage: poly.<a,b> = PolynomialRing(RR)
 sage: solve([a+b+a*b == 1], a)
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /home/burcin/sage/sage-5.2/<ipython console> in <module>()

 /home/burcin/sage/sage-5.2/local/lib/python2.7/site-
 packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
     681             return f[0].solve(*args,**kwds)
     682         # otherwise complain

 --> 683         raise TypeError("The first argument to solve() should be a
 symbolic expression or a list of symbolic expressions, cannot handle
 %s"%repr(type(f[0])))
     684
     685     # f is a list of such expressions or equations


 TypeError: The first argument to solve() should be a symbolic expression
 or a list of symbolic expressions, cannot handle <type 'bool'>
 }}}

 Please review.

 Replying to [comment:2 llpamies]:
 > If you say that,
 > > The comparison operator for polynomial rings is important (think
 monomial orders and Groebner bases), we cannot change it to keep the
 relations symbolic.
 >
 > Shouldn't Sage raise an exception when evaluating "a+b+a*b == 1", saying
 something like "Symbolic comparisons are not allowed for polynomial
 rings.", instead of returning False.

 No, that operations checks for equality of polynomials. That polynomial is
 not equal to `1`. As I wrote before, we cannot modify the comparison of
 polynomials.

 > And besides that, why is "solve([False], a)" raising such a
 incomprehensible "TypeError" exception ?

 This was caused by a typo. Python was complaining about a different issue
 when it said `TypeError: not all arguments converted during string
 formatting`. I hope the new error message is more useful.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13645#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to