Crash using Python when calling integrate
nasser1 opened this issue · comments
This could be because I am using latest sympy 1.10.1 with mathics 4.0? I do not know. But thought to post it
This is on Ubuntu 22.04
>mathics
Mathics 4.0.0
on CPython 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
using SymPy 1.10.1, mpmath 1.2.1, numpy 1.22.4
Copyright (C) 2011-2021 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.
Quit by evaluating Quit[] or by pressing CONTROL-D.
In[1]:= Integrate[ArcSec[x],x]
Traceback (most recent call last):
File "/home/me/.local/bin/mathics", line 8, in <module>
sys.exit(main())
File "/home/me/.local/lib/python3.10/site-packages/mathics/main.py", line 402, in main
result = evaluation.evaluate(query, timeout=settings.TIMEOUT)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/evaluation.py", line 361, in evaluate
result = run_with_timeout_and_stack(evaluate, timeout, self)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/evaluation.py", line 118, in run_with_timeout_and_stack
return request()
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/evaluation.py", line 332, in evaluate
self.last_eval = query.evaluate(self)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/expression.py", line 1315, in evaluate
expr, reevaluate = expr.evaluate_next(evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/expression.py", line 1449, in evaluate_next
result = rule.apply(new, evaluation, fully=False)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 67, in apply
self.pattern.match(yield_match, expression, {}, evaluation, fully=fully)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 291, in match
self.head.match(yield_head, expression.get_head(), vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 159, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 281, in yield_head
self.get_pre_choices(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 429, in get_pre_choices
yield_func(vars)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 258, in yield_choice
self.match_leaf(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 655, in match_leaf
self.get_wrappings(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 456, in get_wrappings
yield_func(items[0])
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 643, in yield_wrapping
leaf.match(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 852, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 1050, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 623, in match_yield
self.match_leaf(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 655, in match_leaf
self.get_wrappings(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 456, in get_wrappings
yield_func(items[0])
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 643, in yield_wrapping
leaf.match(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 852, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 1110, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 623, in match_yield
self.match_leaf(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 655, in match_leaf
self.get_wrappings(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 467, in get_wrappings
yield_func(sequence)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 643, in yield_wrapping
leaf.match(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 1439, in match
yield_func(new_vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 640, in match_yield
yield_func(new_vars, items_rest)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 616, in leaf_yield
yield_func(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 616, in leaf_yield
yield_func(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 42, in yield_match
new_expression = self.do_replace(expression, vars, options, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 129, in do_replace
return self.function(evaluation=evaluation, options=options, **vars_noctx)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/calculus.py", line 664, in apply
result = Expression("Simplify", result, assuming).evaluate(evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/expression.py", line 1315, in evaluate
expr, reevaluate = expr.evaluate_next(evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/expression.py", line 1449, in evaluate_next
result = rule.apply(new, evaluation, fully=False)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 67, in apply
self.pattern.match(yield_match, expression, {}, evaluation, fully=fully)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 291, in match
self.head.match(yield_head, expression.get_head(), vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 159, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 281, in yield_head
self.get_pre_choices(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 429, in get_pre_choices
yield_func(vars)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 258, in yield_choice
self.match_leaf(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 655, in match_leaf
self.get_wrappings(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 456, in get_wrappings
yield_func(items[0])
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 643, in yield_wrapping
leaf.match(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 852, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 1050, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 623, in match_yield
self.match_leaf(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 655, in match_leaf
self.get_wrappings(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 456, in get_wrappings
yield_func(items[0])
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 643, in yield_wrapping
leaf.match(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 852, in match
self.pattern.match(yield_func, expression, new_vars, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/patterns.py", line 1050, in match
yield_func(vars, None)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 640, in match_yield
yield_func(new_vars, items_rest)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/pattern.py", line 616, in leaf_yield
yield_func(
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 42, in yield_match
new_expression = self.do_replace(expression, vars, options, evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/rules.py", line 131, in do_replace
return self.function(evaluation=evaluation, **vars_noctx)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/algebra.py", line 404, in apply_assuming
return dynamic_scoping(
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/scoping.py", line 62, in dynamic_scoping
result = func(evaluation)
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/algebra.py", line 405, in <lambda>
lambda ev: self.apply(expr, ev),
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/algebra.py", line 417, in apply
leaves = [self.apply(leaf, evaluation) for leaf in expr._leaves]
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/algebra.py", line 417, in <listcomp>
leaves = [self.apply(leaf, evaluation) for leaf in expr._leaves]
File "/home/me/.local/lib/python3.10/site-packages/mathics/builtin/numbers/algebra.py", line 424, in apply
sympy_result = sympy.simplify(sympy_expr)
File "/home/me/.local/lib/python3.10/site-packages/sympy/simplify/simplify.py", line 647, in simplify
expr2 = shorter(together(expr, deep=True), together(expr1, deep=True))
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 85, in together
return _together(sympify(expr))
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in _together
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in <listcomp>
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in _together
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in <listcomp>
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in _together
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in <listcomp>
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in _together
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in <listcomp>
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/sympy/polys/rationaltools.py", line 79, in _together
return expr.__class__(*[ _together(arg) for arg in expr.args ])
File "/home/me/.local/lib/python3.10/site-packages/mathics/core/convert.py", line 51, in __new__
raise TypeError
TypeError
>
Thanks, yes this is indeed a bug. It looks like Mathics needs to get more sophisticated about detecting SymPy expressions.
(_Mathics_User_System`Or, _Mathics_User_Global`x > 1, _Mathics_User_Global`x < -1)
here.
BTW, development of Mathics has moved over to https://github.com/Mathics3/mathics-core/
Works in Mathics3. If there is something more. Continue in the issue tracker there.