Opened 4 years ago

#25949 new defect

Erroneous "scientific notation" conversion in Maxima expression

Reported by: Ian Johnson Owned by:
Priority: minor Milestone: sage-8.4
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The following code produces a rather strange error in Sage 8.1:

var('t1e t1n')
solve([t1n == t1e + 2], t1n)

The error given is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_18.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("c29sdmUoW3Qxbj09dDFlICsgMl0sIHQxbik="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmppibxj7/___code___.py", line 3, in <module>
    exec compile(u'solve([t1n==t1e + _sage_const_2 ], t1n)
  File "", line 1, in <module>
    
  File "/usr/lib/python2.7/dist-packages/sage/symbolic/relation.py", line 998, in solve
    return _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict)
  File "/usr/lib/python2.7/dist-packages/sage/symbolic/relation.py", line 1203, in _solve_expression
    X = string_to_list_of_solutions(s) # our initial list of solutions
  File "/usr/lib/python2.7/dist-packages/sage/symbolic/relation.py", line 580, in string_to_list_of_solutions
    v = symbolic_expression_from_maxima_string(s, equals_sub=True)
  File "/usr/lib/python2.7/dist-packages/sage/calculus/calculus.py", line 2159, in symbolic_expression_from_maxima_string
    raise TypeError("unable to make sense of Maxima expression '%s' in Sage"%s)
TypeError: unable to make sense of Maxima expression '[_SAGE_VAR_t1n==_SAGE_VAR_t100.000000000000]' in Sage

It seems that the Maxima output parser is seeing the sequence '1e+2' and converting it to a decimal, even though that's not syntactically correct. I found the offending code in the master branch on GitHub: https://github.com/sagemath/sage/blob/master/src/sage/calculus/calculus.py#L2125-L2130. I haven't gotten a chance to try fixing anything yet, but I wonder if removing that code would have any negative impact (since it seems like the parser already implements scientific notation in a syntactically-aware way).

Change History (0)

Note: See TracTickets for help on using tickets.