Skip to content

Sagemath-Fricas issue: TypeError: ECL says: Memory limit reached calling integrate #37816

@nasser1

Description

@nasser1

Steps To Reproduce

Using sagemath 10.3 with Fricas :

sage --version
SageMath version 10.3, Release Date: 2024-03-19

>fricas --version
FriCAS 1.3.10
based on sbcl 2.3.11
>

Sagemath gives

TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.

When calling integrate with fricas. But using Fricas directly there is no problem and no error


>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.3, Release Date: 2024-03-19                    │
│ Using Python 3.11.8. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘

sage: print(fricas.eval(")lisp |$build_version|"))

Value = "FriCAS 1.3.10"

sage: var('x a b c')
(x, a, b, c)


sage: integrate(x/(x+(c+(a*x+b)^(1/2))^(1/2)),x, algorithm="fricas")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:749, in InterfaceElement.__init__(self, parent, value, is_name, name)
    748 try:
--> 749     self._name = parent._create(value, name=name)
    750 except (TypeError, RuntimeError, ValueError) as x:

File ~/TMP/sage-10.3/src/sage/interfaces/maxima_lib.py:632, in MaximaLib._create(self, value, name)
    631     else:
--> 632         self.set(name, value)
    633 except RuntimeError as error:

File ~/TMP/sage-10.3/src/sage/interfaces/maxima_lib.py:540, in MaximaLib.set(self, var, value)
    539 cmd = '%s : %s$' % (var, value.rstrip(';'))
--> 540 self.eval(cmd)

File ~/TMP/sage-10.3/src/sage/interfaces/maxima_lib.py:486, in MaximaLib._eval_line(self, line, locals, reformat, **kwds)
    485         if statement:
--> 486             maxima_eval("#$%s$" % statement)
    487 if not reformat:

File ~/TMP/sage-10.3/src/sage/libs/ecl.pyx:838, in sage.libs.ecl.EclObject.__call__()
    837 lispargs = EclObject(list(args))
--> 838 return ecl_wrap(ecl_safe_apply(self.obj, (<EclObject>lispargs).obj))
    839 

File ~/TMP/sage-10.3/src/sage/libs/ecl.pyx:358, in sage.libs.ecl.ecl_safe_apply()
    357     else:
--> 358         raise RuntimeError("ECL says: {}".format(message))
    359 else:

RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 integrate(x/(x+(c+(a*x+b)**(Integer(1)/Integer(2)))**(Integer(1)/Integer(2))),x, algorithm="fricas")

File ~/TMP/sage-10.3/src/sage/misc/functional.py:788, in integral(x, *args, **kwds)
    655 """
    656 Return an indefinite or definite integral of an object ``x``.
    657 
   (...)
    785 
    786 """
    787 if hasattr(x, 'integral'):
--> 788     return x.integral(*args, **kwds)
    789 else:
    790     from sage.symbolic.ring import SR

File ~/TMP/sage-10.3/src/sage/symbolic/expression.pyx:13268, in sage.symbolic.expression.Expression.integral()
  13266                 R = SR
  13267         return R(integral(f, v, a, b, **kwds))
> 13268     return integral(self, *args, **kwds)
  13269 
  13270 integrate = integral

File ~/TMP/sage-10.3/src/sage/symbolic/integration/integral.py:1062, in integrate(expression, v, a, b, algorithm, hold)
   1060     if not integrator:
   1061         raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1062     return integrator(expression, v, a, b)
   1063 if a is None:
   1064     return indefinite_integral(expression, v, hold=hold)

File ~/TMP/sage-10.3/src/sage/symbolic/integration/external.py:207, in fricas_integrator(expression, v, a, b, noPole)
    204     else:
    205         result = e_fricas.integrate(seg)
--> 207 result = result.sage()
    209 if result == "failed":
    210     result = expression.integrate(v, a, b, hold=True)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:1123, in InterfaceElement.sage(self, *args, **kwds)
   1104 def sage(self, *args, **kwds):
   1105     """
   1106     Attempt to return a Sage version of this object.
   1107 
   (...)
   1121         [0 0]
   1122     """
-> 1123     return self._sage_(*args, **kwds)

File ~/TMP/sage-10.3/src/sage/interfaces/fricas.py:2056, in FriCASElement._sage_(self)
   2051     return FriCASElement._sage_expression(P.get_InputForm(self._name))
   2053 if head == "Expression" or head == "Pi":
   2054     # we treat Expression Integer and Expression Complex
   2055     # Integer just the same
-> 2056     return FriCASElement._sage_expression(P.get_InputForm(self._name))
   2058 if head == 'DistributedMultivariatePolynomial':
   2059     base_ring = self._get_sage_type(domain[2])

File ~/TMP/sage-10.3/src/sage/interfaces/fricas.py:1759, in FriCASElement._sage_expression(fricas_InputForm)
   1754 del rootOf[var]
   1755 if evars:
   1756     # we just need any root per FriCAS specification -
   1757     # however, if there are extra variables, we cannot
   1758     # use QQbar.any_root
-> 1759     rootOf_ev[var] = poly.roots(var, multiplicities=False)[0]
   1760 else:
   1761     R = PolynomialRing(QQbar, "x")

File ~/TMP/sage-10.3/src/sage/symbolic/expression.pyx:12306, in sage.symbolic.expression.Expression.roots()
  12304     return p.roots(ring=ring, multiplicities=multiplicities)
  12305 
> 12306 S, mul = self.solve(x, multiplicities=True, explicit_solutions=explicit_solutions)
  12307 if len(mul) == 0 and explicit_solutions:
  12308     raise RuntimeError("no explicit roots found")

File ~/TMP/sage-10.3/src/sage/symbolic/expression.pyx:12379, in sage.symbolic.expression.Expression.solve()
  12377 """
  12378 from sage.symbolic.relation import solve
> 12379 return solve(self, x, multiplicities=multiplicities,
  12380                       solution_dict=solution_dict,
  12381                       explicit_solutions=explicit_solutions,

File ~/TMP/sage-10.3/src/sage/symbolic/relation.py:1068, in solve(f, *args, **kwds)
   1063         raise TypeError("The first argument to solve() should be a "
   1064                         "symbolic expression or a list of symbolic "
   1065                         "expressions.")
   1067 if isinstance(f, Expression):  # f is a single expression
-> 1068     return _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
   1070 if not isinstance(f, (list, tuple)):
   1071     raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")

File ~/TMP/sage-10.3/src/sage/symbolic/relation.py:1338, in _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
   1336 try:
   1337     if to_poly_solve != 'force':
-> 1338         s = m.solve(x).str()
   1339     else:  # omit Maxima's solve command
   1340         s = str([])

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:697, in InterfaceFunctionElement.__call__(self, *args, **kwds)
    696 def __call__(self, *args, **kwds):
--> 697     return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:617, in Interface.function_call(self, function, args, kwds)
    613 self._check_valid_function_name(function)
    614 s = self._function_call_string(function,
    615                                [s.name() for s in args],
    616                                ['%s=%s' % (key, value.name()) for key, value in kwds.items()])
--> 617 return self.new(s)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:386, in Interface.new(self, code)
    385 def new(self, code):
--> 386     return self(code)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:299, in Interface.__call__(self, x, name)
    296         pass
    298 if isinstance(x, str):
--> 299     return cls(self, x, name=name)
    300 try:
    301     # Special methods do not and should not have an option to
    302     # set the name directly, as the identifier assigned by the
    303     # interface should stay consistent. An identifier with a
    304     # user-assigned name might change its value, so we return a
    305     # new element.
    306     result = self._coerce_from_special_method(x)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:751, in InterfaceElement.__init__(self, parent, value, is_name, name)
    749     self._name = parent._create(value, name=name)
    750 except (TypeError, RuntimeError, ValueError) as x:
--> 751     raise TypeError(x)

TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.
sage: 

Same command work OK using Fricas directly (output not show as long)


>fricas
FRICAS="/usr/local/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
foreign routines found
openServer result 0
                       FriCAS Computer Algebra System 
                Version: FriCAS 1.3.10 built with sbcl 2.3.11
                 Timestamp: Wed Jan 10 09:37:52 PM CST 2024
integrate(x/(x+(c+(a*x+b)^(1/2))^(1/2)),x)
%no error


Expected Behavior

No exception is expected as that is what happens when calling Fricas directly

Actual Behavior

Exception is generated

Additional Information

No response

Environment

Linux on Virtual box

lsb_release -a
LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	23.1.4
Codename:	Vulcan


sage --version
SageMath version 10.3, Release Date: 2024-03-19

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions