Changes between Version 1 and Version 2 of Ticket #8969


Ignore:
Timestamp:
06/14/11 17:59:49 (10 years ago)
Author:
kcrisman
Comment:

DSM, is this really all one ticket? It's kind of confusing.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8969 – Description

    v1 v2  
    1 'Sage Version 4.4.1, Release Date: 2010-05-02'[[BR]]mac 10.4 32 bit running on 10.5.8.
     1'Sage Version 4.4.1, Release Date: 2010-05-02'
    22
    3 sage: solve([2*x==3, x < 10], x)[[BR]][[x == (3/2)]][[BR]]sage: solve([2*x==3, x > 10], x)[[BR]][][[BR]]sage: solve([2*x==3, x == 10], x)[[BR]][][[BR]]sage: solve([2*x==3, x == 3/2], x)[[BR]][[x == (3/2)]]
     3mac 10.4 32 bit running on 10.5.8.
     4{{{
     5sage: solve([2*x==3, x < 10], x)
     6[[x == (3/2)]]
     7sage: solve([2*x==3, x > 10], x)
     8[]
     9sage: solve([2*x==3, x == 10], x)
     10[]
     11sage: solve([2*x==3, x == 3/2], x)
     12[[x == (3/2)]]
    413
    5 sage: solve([2*x==3, x < 4, x > 4], x)[[BR]][][[BR]]
     14sage: solve([2*x==3, x < 4, x > 4], x)
     15[]
     16}}}
     17all work as expected, but:
     18{{{
     19sage: solve([2*x==3, x != 5], x)
     20-----------------------------------------------------------
     21!TypeError                                 Traceback (most recent call last)
    622
    7 all work as expected, but:
    8 
    9 sage: solve([2*x==3, x != 5], x)[[BR]]---------------------------------------------------------------------------[[BR]]!TypeError                                 Traceback (most recent call last)[[BR]][[BR]]/Applications/sage/devel/sage-main/build/sage/<ipython console> in <module>()[[BR]][[BR]]/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)[[BR]]    670                 s = [][[BR]]    671 [[BR]]--> 672         sol_list = string_to_list_of_solutions(repr(s))[[BR]]    673         if 'solution_dict' in kwds and kwds!['solution_dict']==True:[[BR]]    674             if isinstance(sol_list![0], list):[[BR]][[BR]]/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc in string_to_list_of_solutions(s)[[BR]]    455     from sage.structure.sequence import Sequence[[BR]]    456     from sage.calculus.calculus import symbolic_expression_from_maxima_string[[BR]]--> 457     v = symbolic_expression_from_maxima_string(s, equals_sub=True)[[BR]]    458     return Sequence(v, universe=Objects(), cr_str=True)[[BR]]    459 [[BR]][[BR]]/Applications/sage/local/lib/python2.6/site-packages/sage/calculus/calculus.py in symbolic_expression_from_maxima_string(x, equals_sub, maxima)[[BR]]   1527         return symbolic_expression_from_string(s, syms, accept_sequence=True)[[BR]]   1528     except !!!!SyntaxError:[[BR]]-> 1529         raise !TypeError, "unable to make sense of Maxima expression '%s' in Sage"%s[[BR]]   1530     finally:[[BR]]   1531         is_simplified = False[[BR]][[BR]]!TypeError: unable to make sense of Maxima expression '[[x==3/2,-7/2!==0]]' in Sage
    10 
     23/Applications/sage/devel/sage-main/build/sage/<ipython console> in <module>()
     24/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
     25    670                 s = []
     26    671
     27--> 672         sol_list = string_to_list_of_solutions(repr(s))
     28    673         if 'solution_dict' in kwds and kwds!['solution_dict']==True:
     29    674             if isinstance(sol_list![0], list):
     30]/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc in string_to_list_of_solutions(s)
     31    455     from sage.structure.sequence import Sequence
     32    456     from sage.calculus.calculus import symbolic_expression_from_maxima_string
     33--> 457     v = symbolic_expression_from_maxima_string(s, equals_sub=True)
     34    458     return Sequence(v, universe=Objects(), cr_str=True)
     35    459
     36/Applications/sage/local/lib/python2.6/site-packages/sage/calculus/calculus.py in symbolic_expression_from_maxima_string(x, equals_sub, maxima)
     37   1527         return symbolic_expression_from_string(s, syms, accept_sequence=True)
     38   1528     except !!!!SyntaxError:
     39-> 1529         raise !TypeError, "unable to make sense of Maxima expression '%s' in Sage"%s
     40   1530     finally:
     41   1531         is_simplified = False
     42!TypeError: unable to make sense of Maxima expression '[[x==3/2,-7/2!==0]]' in Sage
     43}}}
    1144--
    1245
    13 The "!==" which is causing trouble is due to the
    14 
    15 if equals_sub:[[BR]]            s = s.replace('=','==')
    16 
    17 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.
     46The `!==` which is causing trouble is due to the
     47{{{
     48if equals_sub:
     49            s = s.replace('=','==')
     50}}}
     51lines 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.
    1852
    1953This deals with the obvious problem but not the underlying one, which is that the result is still IMHO underprocessed:
    20 
     54{{{
    2155MODIFIED_sage: solve([2*x==3, x != 4], x)[[BR]][[x == (3/2), (-5/2) != 0]]
    2256
     
    2660
    2761when I wanted [].
    28 
     62}}}
    2963In fact, even in cases not involving "!=", it's possible for maxima output -- %union([x = 3/2,  -5/2 # 0]) --  to be insufficiently processed,IMHO:
    30 
    31 MODIFIED_sage: solve([2*x==3, (x-4)!^2 > 0], x)[[BR]][[x == (3/2), (-5/2) != 0]]
    32 
     64{{{
     65MODIFIED_sage: solve([2*x==3, (x-4)!^2 > 0], x)
     66[[x == (3/2), (-5/2) != 0]]
     67}}}
    3368ISTM the extra information about what condition maxima used isn't worth the inconvenience of having to postprocess the solutions to see if one exists.