#8969: problems with maxima inequalities
----------------------------------+-----------------------------------------
       Reporter:  dsm             |         Owner:  burcin      
           Type:  defect          |        Status:  needs_review
       Priority:  minor           |     Milestone:              
      Component:  symbolics       |    Resolution:              
       Keywords:  sd40.5          |   Work issues:              
Report Upstream:  N/A             |     Reviewers:              
        Authors:  Douglas McNeil  |     Merged in:              
   Dependencies:                  |      Stopgaps:              
----------------------------------+-----------------------------------------
Changes (by {'newvalue': u'Douglas McNeil', 'oldvalue': ''}):

  * keywords:  => sd40.5
  * status:  new => needs_review
  * author:  => Douglas McNeil


Old description:

> 'Sage Version 4.4.1, Release Date: 2010-05-02'
>
> mac 10.4 32 bit running on 10.5.8.
> {{{
> sage: solve([2*x==3, x < 10], x)
> [[x == (3/2)]]
> sage: solve([2*x==3, x > 10], x)
> []
> sage: solve([2*x==3, x == 10], x)
> []
> sage: solve([2*x==3, x == 3/2], x)
> [[x == (3/2)]]
>
> sage: solve([2*x==3, x < 4, x > 4], x)
> []
> }}}
> all work as expected, but:
> {{{
> sage: solve([2*x==3, x != 5], x)
> -----------------------------------------------------------
> !TypeError                                 Traceback (most recent call
> last)
>
> /Applications/sage/devel/sage-main/build/sage/<ipython console> in
> <module>()
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
>     670                 s = []
>     671
> --> 672         sol_list = string_to_list_of_solutions(repr(s))
>     673         if 'solution_dict' in kwds and
> kwds!['solution_dict']==True:
>     674             if isinstance(sol_list![0], list):
> ]/Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/relation.pyc in string_to_list_of_solutions(s)
>     455     from sage.structure.sequence import Sequence
>     456     from sage.calculus.calculus import
> symbolic_expression_from_maxima_string
> --> 457     v = symbolic_expression_from_maxima_string(s,
> equals_sub=True)
>     458     return Sequence(v, universe=Objects(), cr_str=True)
>     459
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/calculus/calculus.py in
> symbolic_expression_from_maxima_string(x, equals_sub, maxima)
>    1527         return symbolic_expression_from_string(s, syms,
> accept_sequence=True)
>    1528     except !!!!SyntaxError:
> -> 1529         raise !TypeError, "unable to make sense of Maxima
> expression '%s' in Sage"%s
>    1530     finally:
>    1531         is_simplified = False
> !TypeError: unable to make sense of Maxima expression
> '[[x==3/2,-7/2!==0]]' in Sage
> }}}
> --
>
> The `!==` which is causing trouble is due to the
> {{{
> if equals_sub:
>             s = s.replace('=','==')
> }}}
> lines in  `symbolic_expression_from_maxima_string`.  This could be fixed
> by changing the replace to a regexp, or adding a hack `s =
> s.replace('!==', '!=')` afterwards.
>
> This deals with the obvious problem but not the underlying one, which is
> that the result is still IMHO underprocessed:
> {{{
> MODIFIED_sage: solve([2*x==3, x != 4], x)[[BR]][[x == (3/2), (-5/2) !=
> 0]]
>
> when I wanted [[x == (3/2)]], or
>
> MODIFIED_sage: solve([2*x==3, x != 3/2], x)[[BR]][[x == (3/2), 0 != 0]]
>
> when I wanted [].
> }}}
> In fact, even in cases not involving "!=", it's possible for maxima
> output -- %union([x = 3/2,  -5/2 # 0]) --  to be insufficiently
> processed,IMHO:
> {{{
> MODIFIED_sage: solve([2*x==3, (x-4)!^2 > 0], x)
> [[x == (3/2), (-5/2) != 0]]
> }}}
> ISTM the extra information about what condition maxima used isn't worth
> the inconvenience of having to postprocess the solutions to see if one
> exists.

New description:

 'Sage Version 4.4.1, Release Date: 2010-05-02'

 mac 10.4 32 bit running on 10.5.8.
 {{{
 sage: solve([2*x==3, x < 10], x)
 [[x == (3/2)]]
 sage: solve([2*x==3, x > 10], x)
 []
 sage: solve([2*x==3, x == 10], x)
 []
 sage: solve([2*x==3, x == 3/2], x)
 [[x == (3/2)]]

 sage: solve([2*x==3, x < 4, x > 4], x)
 []
 }}}
 all work as expected, but:
 {{{
 sage: solve([2*x==3, x != 5], x)
 -----------------------------------------------------------
 !TypeError                                 Traceback (most recent call
 last)

 /Applications/sage/devel/sage-main/build/sage/<ipython console> in
 <module>()
 /Applications/sage/local/lib/python2.6/site-
 packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
     670                 s = []
     671
 --> 672         sol_list = string_to_list_of_solutions(repr(s))
     673         if 'solution_dict' in kwds and
 kwds!['solution_dict']==True:
     674             if isinstance(sol_list![0], list):
 ]/Applications/sage/local/lib/python2.6/site-
 packages/sage/symbolic/relation.pyc in string_to_list_of_solutions(s)
     455     from sage.structure.sequence import Sequence
     456     from sage.calculus.calculus import
 symbolic_expression_from_maxima_string
 --> 457     v = symbolic_expression_from_maxima_string(s, equals_sub=True)
     458     return Sequence(v, universe=Objects(), cr_str=True)
     459
 /Applications/sage/local/lib/python2.6/site-
 packages/sage/calculus/calculus.py in
 symbolic_expression_from_maxima_string(x, equals_sub, maxima)
    1527         return symbolic_expression_from_string(s, syms,
 accept_sequence=True)
    1528     except !!!!SyntaxError:
 -> 1529         raise !TypeError, "unable to make sense of Maxima
 expression '%s' in Sage"%s
    1530     finally:
    1531         is_simplified = False
 !TypeError: unable to make sense of Maxima expression
 '[[x==3/2,-7/2!==0]]' in Sage
 }}}
 --

 The `!==` which is causing trouble is due to the
 {{{
 if equals_sub:
             s = s.replace('=','==')
 }}}
 lines in  `symbolic_expression_from_maxima_string`.  This could be fixed
 by changing the replace to a regexp, or adding a hack `s =
 s.replace('!==', '!=')` afterwards.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8969#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