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

problems with maxima inequalities #8969

Closed
sagetrac-dsm mannequin opened this issue May 14, 2010 · 13 comments
Closed

problems with maxima inequalities #8969

sagetrac-dsm mannequin opened this issue May 14, 2010 · 13 comments

Comments

@sagetrac-dsm
Copy link
Mannequin

sagetrac-dsm mannequin commented May 14, 2010

'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.

Component: symbolics

Keywords: sd40.5

Author: Douglas McNeil

Reviewer: Karl-Dieter Crisman

Merged: sage-5.1.beta5

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

@sagetrac-dsm sagetrac-dsm mannequin assigned burcin May 14, 2010
@sagetrac-dsm

This comment has been minimized.

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

comment:2

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

@sagetrac-dsm
Copy link
Mannequin Author

sagetrac-dsm mannequin commented May 25, 2012

Changed keywords from none to sd40.5

@sagetrac-dsm

This comment has been minimized.

@sagetrac-dsm
Copy link
Mannequin Author

sagetrac-dsm mannequin commented May 25, 2012

Author: Douglas McNeil

@sagetrac-dsm sagetrac-dsm mannequin added the s: needs review label May 25, 2012
@sagetrac-dsm
Copy link
Mannequin Author

sagetrac-dsm mannequin commented May 25, 2012

comment:4

It was all one ticket in my head, but maybe it makes more sense to separate them. Might as well address the low-hanging fruit.

@kcrisman
Copy link
Member

comment:5

The problem wasn't really our translation of Maxima's inequality (#, which we finally fixed a while ago) but rather that we then had this little hack already.

But all of your tests already work in Sage 5.0, because of the # replacement. It really has to test the original bug report example, otherwise this is trivial. I suggest

sage: from sage.calculus.calculus import symbolic_expression_from_maxima_string as sefms 
sage: sefms("x != 3") == SR(x != 3) 
True
sage: sefms("x # 3") == SR(x != 3) 
True
sage:  solve([2*x==3, x != 5], x)
[[x == (3/2), (-7/2) != 0]]

@sagetrac-dsm
Copy link
Mannequin Author

sagetrac-dsm mannequin commented May 26, 2012

comment:6

Oy, you're right that I truncated the original bug test (!). But we do need to fix !== to round-trip neq, so I think it's worth doing.

@sagetrac-dsm
Copy link
Mannequin Author

sagetrac-dsm mannequin commented May 26, 2012

revised version

@kcrisman
Copy link
Member

comment:7

Attachment: trac_8969_allow_neq_maxima_strings_v2.patch.gz

Positive review.

@kcrisman
Copy link
Member

Reviewer: Karl-Dieter Crisman

@jdemeyer jdemeyer added this to the sage-5.1 milestone May 28, 2012
@jdemeyer
Copy link

Merged: sage-5.1.beta5

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

3 participants